From c8b2b4d464ff1fba507862a9e0fe2bf5499ef298 Mon Sep 17 00:00:00 2001 From: Piotr Mitros Date: Fri, 27 Jul 2012 10:14:07 -0400 Subject: [PATCH 1/7] Miniture staff dashboard. Not really tested, but should be safe to merge --- lms/djangoapps/dashboard/views.py | 29 +++++++++++++++++++++++++++++ lms/urls.py | 1 + 2 files changed, 30 insertions(+) create mode 100644 lms/djangoapps/dashboard/views.py diff --git a/lms/djangoapps/dashboard/views.py b/lms/djangoapps/dashboard/views.py new file mode 100644 index 0000000000..ba6c8ca152 --- /dev/null +++ b/lms/djangoapps/dashboard/views.py @@ -0,0 +1,29 @@ +# 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): + """ + Simple view that a loadbalancer can check to verify that the app is up + """ + 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() + results = dictfetchall(cursor.execute(query)) + + + return HttpResponse(json.dumps(results, indent=4)) diff --git a/lms/urls.py b/lms/urls.py index 0785cd96d0..3667397c8c 100644 --- a/lms/urls.py +++ b/lms/urls.py @@ -13,6 +13,7 @@ if settings.DEBUG: 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'), From 6db146f6b49a1a5310cf1be04bace51090ec5fba Mon Sep 17 00:00:00 2001 From: Piotr Mitros Date: Fri, 27 Jul 2012 10:19:51 -0400 Subject: [PATCH 2/7] Missing files --- lms/djangoapps/dashboard/__init__.py | 0 lms/djangoapps/dashboard/models.py | 3 +++ lms/djangoapps/dashboard/tests.py | 16 ++++++++++++++++ 3 files changed, 19 insertions(+) create mode 100644 lms/djangoapps/dashboard/__init__.py create mode 100644 lms/djangoapps/dashboard/models.py create mode 100644 lms/djangoapps/dashboard/tests.py 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) From 2df7e02e310516bbf2649988edb58e79b829ccf4 Mon Sep 17 00:00:00 2001 From: Piotr Mitros Date: Fri, 27 Jul 2012 10:23:44 -0400 Subject: [PATCH 3/7] Fixed comment --- lms/djangoapps/dashboard/views.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lms/djangoapps/dashboard/views.py b/lms/djangoapps/dashboard/views.py index ba6c8ca152..5cf3fa72c1 100644 --- a/lms/djangoapps/dashboard/views.py +++ b/lms/djangoapps/dashboard/views.py @@ -14,7 +14,9 @@ def dictfetchall(cursor): def dashboard(request): """ - Simple view that a loadbalancer can check to verify that the app is up + 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 From c51f78bdfad4900e9e112f9d1abf831e5a226a79 Mon Sep 17 00:00:00 2001 From: Kyle Fiedler Date: Tue, 24 Jul 2012 16:54:31 -0400 Subject: [PATCH 4/7] Added styles for course images to always the right dimentions --- lms/static/sass/multicourse/_course_about.scss | 13 +++++++------ lms/templates/portal/course_about.html | 2 ++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lms/static/sass/multicourse/_course_about.scss b/lms/static/sass/multicourse/_course_about.scss index f96d12f7a3..de09505252 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); diff --git a/lms/templates/portal/course_about.html b/lms/templates/portal/course_about.html index bb00a6abf0..7780d939de 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
+
From b402cde65014f1d078e85505622bd4389c7fdced Mon Sep 17 00:00:00 2001 From: Kyle Fiedler Date: Tue, 24 Jul 2012 13:48:20 -0400 Subject: [PATCH 5/7] Added some style for the dashboard message --- lms/static/sass/multicourse/_dashboard.scss | 21 +++++++++++++++++++++ lms/templates/dashboard.html | 1 - 2 files changed, 21 insertions(+), 1 deletion(-) 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..f1e19b6e5f 100644 --- a/lms/templates/dashboard.html +++ b/lms/templates/dashboard.html @@ -36,7 +36,6 @@
${message} -
From a2271d4e48992682d14b8c436a22d18fae6a2b09 Mon Sep 17 00:00:00 2001 From: Bridger Maxwell Date: Tue, 24 Jul 2012 13:52:13 -0400 Subject: [PATCH 6/7] The message div will only show up when there is a message to display. --- lms/templates/dashboard.html | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lms/templates/dashboard.html b/lms/templates/dashboard.html index f1e19b6e5f..160b453853 100644 --- a/lms/templates/dashboard.html +++ b/lms/templates/dashboard.html @@ -34,9 +34,11 @@
-
- ${message} -
+ %if message: +
+ ${message} +
+ %endif
From 442fb6e839ab77c9eda524ace487b671fc7b8dcf Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Wed, 1 Aug 2012 16:19:29 -0400 Subject: [PATCH 7/7] Pass the cursor, rather than the output of cursor.execute, to dictfetchall --- lms/djangoapps/dashboard/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lms/djangoapps/dashboard/views.py b/lms/djangoapps/dashboard/views.py index 5cf3fa72c1..c4446bceaa 100644 --- a/lms/djangoapps/dashboard/views.py +++ b/lms/djangoapps/dashboard/views.py @@ -25,7 +25,7 @@ def dashboard(request): from django.db import connection cursor = connection.cursor() - results = dictfetchall(cursor.execute(query)) - + cursor.execute(query) + results = dictfetchall(cursor) return HttpResponse(json.dumps(results, indent=4))