Commit a64ddc77 by Matthew Mongeau

Display courses in university related columns.

parent 9ec8c993
...@@ -7,6 +7,7 @@ import sys ...@@ -7,6 +7,7 @@ import sys
import uuid import uuid
import feedparser import feedparser
import urllib import urllib
import itertools
from django.conf import settings from django.conf import settings
from django.contrib.auth import logout, authenticate, login from django.contrib.auth import logout, authenticate, login
...@@ -49,8 +50,13 @@ def csrf_token(context): ...@@ -49,8 +50,13 @@ def csrf_token(context):
@ensure_csrf_cookie @ensure_csrf_cookie
@cache_if_anonymous @cache_if_anonymous
def index(request): def index(request):
''' Redirects to main page -- info page if user authenticated, or marketing if not ''' Redirects to main page -- info page if user authenticated, or marketing if not
''' '''
if settings.COURSEWARE_ENABLED and request.user.is_authenticated():
return redirect(reverse('dashboard'))
feed_data = cache.get("students_index_rss_feed_data") feed_data = cache.get("students_index_rss_feed_data")
if feed_data == None: if feed_data == None:
if hasattr(settings, 'RSS_URL'): if hasattr(settings, 'RSS_URL'):
...@@ -65,11 +71,13 @@ def index(request): ...@@ -65,11 +71,13 @@ def index(request):
soup = BeautifulSoup(entry.description) soup = BeautifulSoup(entry.description)
entry.image = soup.img['src'] if soup.img else None entry.image = soup.img['src'] if soup.img else None
if settings.COURSEWARE_ENABLED and request.user.is_authenticated(): courses = modulestore().get_courses()
return redirect(reverse('dashboard')) universities = dict()
else: for university, group in itertools.groupby(courses, lambda course: course.org):
# TODO: Clean up how 'error' is done. universities.setdefault(university, [])
return render_to_response('index.html', {'courses': modulestore().get_courses(), 'entries': entries}) [universities[university].append(course) for course in group]
return render_to_response('index.html', {'universities': universities, 'entries': entries})
@login_required @login_required
......
...@@ -3,22 +3,27 @@ ...@@ -3,22 +3,27 @@
@include clearfix; @include clearfix;
padding: 40px 0px 15px; padding: 40px 0px 15px;
.university-column {
width: flex-grid(4);
margin-right: flex-gutter();
float: left;
&:nth-child(3n+3) {
margin-right: 0;
}
}
.course { .course {
background: rgb(250,250,250); background: rgb(250,250,250);
border: 1px solid rgb(180,180,180); border: 1px solid rgb(180,180,180);
@include border-radius(2px); @include border-radius(2px);
@include box-sizing(border-box); @include box-sizing(border-box);
@include box-shadow(0 1px 10px 0 rgba(0,0,0, 0.15), inset 0 0 0 1px rgba(255,255,255, 0.9)); @include box-shadow(0 1px 10px 0 rgba(0,0,0, 0.15), inset 0 0 0 1px rgba(255,255,255, 0.9));
float: left;
margin-right: flex-gutter();
margin-bottom: 30px; margin-bottom: 30px;
position: relative; position: relative;
width: flex-grid(4); width: 100%;
@include transition(all, 0.15s, linear); @include transition(all, 0.15s, linear);
&:nth-child(3n+3) {
margin-right: 0;
}
.meta-info { .meta-info {
background: rgba(0,0,0, 0.6); background: rgba(0,0,0, 0.6);
......
...@@ -78,9 +78,21 @@ ...@@ -78,9 +78,21 @@
</section> </section>
<section class="courses"> <section class="courses">
%for course in courses: <section class='university-column'>
<%include file="course.html" args="course=course" /> %for course in universities['MITx']:
%endfor <%include file="course.html" args="course=course" />
%endfor
</section>
<section class='university-column'>
%for course in universities['HarvardX']:
<%include file="course.html" args="course=course" />
%endfor
</section>
<section class='university-column'>
%for course in universities['BerkeleyX']:
<%include file="course.html" args="course=course" />
%endfor
</section>
</section> </section>
</section> </section>
</section> </section>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment