diff --git a/common/djangoapps/student/views.py b/common/djangoapps/student/views.py index e36bcf4b96..15d50d3ee4 100644 --- a/common/djangoapps/student/views.py +++ b/common/djangoapps/student/views.py @@ -35,9 +35,10 @@ from xmodule.modulestore.exceptions import ItemNotFoundError from models import Registration, UserProfile, PendingNameChange, PendingEmailChange, CourseEnrollment from datetime import date +from collections import namedtuple log = logging.getLogger("mitx.student") - +Article = namedtuple('Article', 'title url author image deck publication publish_date') def csrf_token(context): ''' A csrf token that can be included in a form. @@ -84,6 +85,19 @@ def course_from_id(id): course_loc = CourseDescriptor.id_to_location(id) return modulestore().get_item(course_loc) +def press(request): + json_articles = cache.get("student_press_json_articles") + if json_articles == None: + if hasattr(settings, 'RSS_URL'): + content = urllib.urlopen(settings.PRESS_URL).read() + json_articles = json.loads(content) + else: + content = open(settings.PROJECT_ROOT / "templates" / "press.json").read() + json_articles = json.loads(content) + cache.set("student_press_json_articles", json_articles) + articles = [Article(**article) for article in json_articles] + return render_to_response('static_templates/press.html', {'articles': articles}) + @login_required @ensure_csrf_cookie def dashboard(request): diff --git a/lms/djangoapps/dashboard/__init__.py b/lms/djangoapps/dashboard/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/lms/djangoapps/dashboard/models.py b/lms/djangoapps/dashboard/models.py new file mode 100644 index 0000000000..71a8362390 --- /dev/null +++ b/lms/djangoapps/dashboard/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/lms/djangoapps/dashboard/tests.py b/lms/djangoapps/dashboard/tests.py new file mode 100644 index 0000000000..501deb776c --- /dev/null +++ b/lms/djangoapps/dashboard/tests.py @@ -0,0 +1,16 @@ +""" +This file demonstrates writing tests using the unittest module. These will pass +when you run "manage.py test". + +Replace this with more appropriate tests for your application. +""" + +from django.test import TestCase + + +class SimpleTest(TestCase): + def test_basic_addition(self): + """ + Tests that 1 + 1 always equals 2. + """ + self.assertEqual(1 + 1, 2) diff --git a/lms/djangoapps/dashboard/views.py b/lms/djangoapps/dashboard/views.py new file mode 100644 index 0000000000..c4446bceaa --- /dev/null +++ b/lms/djangoapps/dashboard/views.py @@ -0,0 +1,31 @@ +# Create your views here. +import json +from datetime import datetime +from django.http import HttpResponse, Http404 + +def dictfetchall(cursor): + '''Returns all rows from a cursor as a dict. + Borrowed from Django documentation''' + desc = cursor.description + return [ + dict(zip([col[0] for col in desc], row)) + for row in cursor.fetchall() + ] + +def dashboard(request): + """ + Quick hack to show staff enrollment numbers. This should be + replaced with a real dashboard later. This version is a short-term + bandaid for the next couple weeks. + """ + if not request.user.is_staff: + raise Http404 + + query = "select count(user_id) as students, course_id from student_courseenrollment group by course_id order by students desc" + + from django.db import connection + cursor = connection.cursor() + cursor.execute(query) + results = dictfetchall(cursor) + + return HttpResponse(json.dumps(results, indent=4)) diff --git a/lms/envs/common.py b/lms/envs/common.py index 3b005c5dbe..8475cfa9a9 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -105,6 +105,7 @@ LIB_URL = '/static/js/' # BOOK_URL = '/static/book/' BOOK_URL = 'https://mitxstatic.s3.amazonaws.com/book_images/' # For AWS deploys # RSS_URL = r'lms/templates/feed.rss' +# PRESS_URL = r'' RSS_TIMEOUT = 600 # Configuration option for when we want to grab server error pages diff --git a/lms/static/images/press/bloomberg_logo_178x138.jpeg b/lms/static/images/press/bloomberg_logo_178x138.jpeg new file mode 100644 index 0000000000..d87819b7cd Binary files /dev/null and b/lms/static/images/press/bloomberg_logo_178x138.jpeg differ diff --git a/lms/static/images/press/chroniclehighered_logo_178x138.jpeg b/lms/static/images/press/chroniclehighered_logo_178x138.jpeg new file mode 100644 index 0000000000..95dce54e2e Binary files /dev/null and b/lms/static/images/press/chroniclehighered_logo_178x138.jpeg differ diff --git a/lms/static/images/press/harvardcrimson_logo_178x138.jpeg b/lms/static/images/press/harvardcrimson_logo_178x138.jpeg new file mode 100644 index 0000000000..7fa3bef5e1 Binary files /dev/null and b/lms/static/images/press/harvardcrimson_logo_178x138.jpeg differ diff --git a/lms/static/images/press/harvardgazette_logo_178x138.jpeg b/lms/static/images/press/harvardgazette_logo_178x138.jpeg new file mode 100644 index 0000000000..1f0bfac70b Binary files /dev/null and b/lms/static/images/press/harvardgazette_logo_178x138.jpeg differ diff --git a/lms/static/images/press/harvardmagazine_logo_178x138.jpeg b/lms/static/images/press/harvardmagazine_logo_178x138.jpeg new file mode 100644 index 0000000000..58b29a5596 Binary files /dev/null and b/lms/static/images/press/harvardmagazine_logo_178x138.jpeg differ diff --git a/lms/static/images/press/harvarduniv_logo_178x138.jpeg b/lms/static/images/press/harvarduniv_logo_178x138.jpeg new file mode 100644 index 0000000000..66dd05fb88 Binary files /dev/null and b/lms/static/images/press/harvarduniv_logo_178x138.jpeg differ diff --git a/lms/static/images/press/latimes_logo_178x138.jpeg b/lms/static/images/press/latimes_logo_178x138.jpeg new file mode 100644 index 0000000000..fed922f846 Binary files /dev/null and b/lms/static/images/press/latimes_logo_178x138.jpeg differ diff --git a/lms/static/images/press/mercurynews_logo_178x138.jpeg b/lms/static/images/press/mercurynews_logo_178x138.jpeg new file mode 100644 index 0000000000..798749ab22 Binary files /dev/null and b/lms/static/images/press/mercurynews_logo_178x138.jpeg differ diff --git a/lms/static/sass/base/_extends.scss b/lms/static/sass/base/_extends.scss index 7f6078252a..9dc10aed5f 100644 --- a/lms/static/sass/base/_extends.scss +++ b/lms/static/sass/base/_extends.scss @@ -85,7 +85,7 @@ } .success-message-colors { - background: rgb(99, 236, 137); - border: 1px solid rgb(17, 202, 54); - color: rgb(35, 143, 14); + background: rgb(19, 159, 58); + border: 1px solid rgb(6, 65, 18); + color: rgb(255, 255, 255); } diff --git a/lms/static/sass/multicourse/_course_about.scss b/lms/static/sass/multicourse/_course_about.scss index f96d12f7a3..fcf4382109 100644 --- a/lms/static/sass/multicourse/_course_about.scss +++ b/lms/static/sass/multicourse/_course_about.scss @@ -27,14 +27,17 @@ max-width: 1200px; min-width: 760px; position: relative; - width: 100%; z-index: 2; - + > div.table { + display: table; + width: 100%; + } .intro { @include box-sizing(border-box); @include clearfix; - float: left; + display: table-cell; + vertical-align: middle; padding: 20px 20px; position: relative; width: flex-grid(8) + flex-gutter(); @@ -130,9 +133,7 @@ .media { background: transparent; @include box-sizing(border-box); - display: block; - float: right; - height: 180px; + display: table-cell; padding: 20px; position: relative; width: flex-grid(4); @@ -273,6 +274,24 @@ } } } + + .faq { + @include clearfix; + + .responses { + float: left; + } + + .response { + margin-bottom: 40px; + + h3 { + font-family: $sans-serif; + font-weight: 700; + margin-bottom: 15px; + } + } + } } } diff --git a/lms/static/sass/multicourse/_dashboard.scss b/lms/static/sass/multicourse/_dashboard.scss index a3d21cb1b3..9c2b71f5c0 100644 --- a/lms/static/sass/multicourse/_dashboard.scss +++ b/lms/static/sass/multicourse/_dashboard.scss @@ -2,6 +2,27 @@ @include clearfix; padding: 60px 0px 120px; + .dashboard-banner { + background: $yellow; + border: 1px solid rgb(200,200,200); + @include box-shadow(0 1px 0 0 rgba(255,255,255, 0.6)); + padding: 10px; + margin-bottom: 30px; + + &:empty { + display: none; + background-color: #FFF; + } + + h2 { + margin-bottom: 0; + } + + p { + margin-bottom: 0; + } + } + .profile-sidebar { background: transparent; float: left; diff --git a/lms/templates/dashboard.html b/lms/templates/dashboard.html index b0d4308253..160b453853 100644 --- a/lms/templates/dashboard.html +++ b/lms/templates/dashboard.html @@ -34,10 +34,11 @@
-
- ${message} -
-
+ %if message: +
+ ${message} +
+ %endif
diff --git a/lms/templates/index.html b/lms/templates/index.html index 2b03e51280..d8b0394927 100644 --- a/lms/templates/index.html +++ b/lms/templates/index.html @@ -126,7 +126,10 @@ Huffington Post, GigaOM, MIT News, - IEEE Spectrum + ##IEEE Spectrum, + Harvard Magazine, + Bloomberg + ## The Chronicle of Higher Education Read More →
diff --git a/lms/templates/portal/course_about.html b/lms/templates/portal/course_about.html index bb00a6abf0..e6359d0542 100644 --- a/lms/templates/portal/course_about.html +++ b/lms/templates/portal/course_about.html @@ -51,6 +51,7 @@
+

${course.number}: ${get_course_about_section(course, "title")}${get_course_about_section(course, "university")}

@@ -84,6 +85,7 @@
% endif
+
@@ -107,7 +109,7 @@