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/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 ca3b273fc3..480568a5b9 100644 --- a/lms/templates/dashboard.html +++ b/lms/templates/dashboard.html @@ -34,10 +34,11 @@
-
- ${message} -
-
+ %if message: +
+ ${message} +
+ %endif
diff --git a/lms/urls.py b/lms/urls.py index 783e9f3fce..3d222d92b9 100644 --- a/lms/urls.py +++ b/lms/urls.py @@ -14,6 +14,8 @@ urlpatterns = ('', url(r'^$', 'student.views.index', name="root"), # Main marketing page, or redirect to courseware url(r'^dashboard$', 'student.views.dashboard', name="dashboard"), + url(r'^admin_dashboard$', 'dashboard.views.dashboard'), + url(r'^change_email$', 'student.views.change_email_request'), url(r'^email_confirm/(?P[^/]*)$', 'student.views.confirm_email_change'), url(r'^change_name$', 'student.views.change_name_request'),