Merge pull request #214 from MITx/mm-course-columns
Display courses in university related columns.
This commit is contained in:
@@ -7,6 +7,7 @@ import sys
|
||||
import uuid
|
||||
import feedparser
|
||||
import urllib
|
||||
import itertools
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.auth import logout, authenticate, login
|
||||
@@ -49,8 +50,13 @@ def csrf_token(context):
|
||||
@ensure_csrf_cookie
|
||||
@cache_if_anonymous
|
||||
def index(request):
|
||||
|
||||
''' 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")
|
||||
if feed_data == None:
|
||||
if hasattr(settings, 'RSS_URL'):
|
||||
@@ -65,11 +71,13 @@ def index(request):
|
||||
soup = BeautifulSoup(entry.description)
|
||||
entry.image = soup.img['src'] if soup.img else None
|
||||
|
||||
if settings.COURSEWARE_ENABLED and request.user.is_authenticated():
|
||||
return redirect(reverse('dashboard'))
|
||||
else:
|
||||
# TODO: Clean up how 'error' is done.
|
||||
return render_to_response('index.html', {'courses': modulestore().get_courses(), 'entries': entries})
|
||||
courses = modulestore().get_courses()
|
||||
universities = dict()
|
||||
for university, group in itertools.groupby(courses, lambda course: course.org):
|
||||
universities.setdefault(university, [])
|
||||
[universities[university].append(course) for course in group]
|
||||
|
||||
return render_to_response('index.html', {'universities': universities, 'entries': entries})
|
||||
|
||||
|
||||
@login_required
|
||||
|
||||
@@ -3,22 +3,27 @@
|
||||
@include clearfix;
|
||||
padding: 40px 0px 15px;
|
||||
|
||||
.university-column {
|
||||
width: flex-grid(4);
|
||||
margin-right: flex-gutter();
|
||||
float: left;
|
||||
|
||||
&:nth-child(3n+3) {
|
||||
margin-right: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.course {
|
||||
background: rgb(250,250,250);
|
||||
border: 1px solid rgb(180,180,180);
|
||||
@include border-radius(2px);
|
||||
@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));
|
||||
float: left;
|
||||
margin-right: flex-gutter();
|
||||
margin-bottom: 30px;
|
||||
position: relative;
|
||||
width: flex-grid(4);
|
||||
width: 100%;
|
||||
@include transition(all, 0.15s, linear);
|
||||
|
||||
&:nth-child(3n+3) {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
.meta-info {
|
||||
background: rgba(0,0,0, 0.6);
|
||||
|
||||
@@ -78,9 +78,21 @@
|
||||
</section>
|
||||
|
||||
<section class="courses">
|
||||
%for course in courses:
|
||||
<%include file="course.html" args="course=course" />
|
||||
%endfor
|
||||
<section class='university-column'>
|
||||
%for course in universities['MITx']:
|
||||
<%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>
|
||||
|
||||
Reference in New Issue
Block a user