Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion common/djangoapps/student/tests/test_course_listing.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ def test_errored_course_regular_access(self):
courses_list = list(get_course_enrollment_pairs(self.student, None, []))
self.assertEqual(courses_list, [])

@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
def test_course_listing_errored_deleted_courses(self):
"""
Create good courses, courses that won't load, and deleted courses which still have
Expand Down
26 changes: 8 additions & 18 deletions common/djangoapps/student/views.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"""
Student Views
"""
import datetime
import logging
import re
import uuid
import time
import json
from collections import defaultdict
from datetime import datetime
from pytz import UTC

from django.conf import settings
Expand Down Expand Up @@ -42,7 +42,6 @@
from mako.exceptions import TopLevelLookupException

from course_modes.models import CourseMode

from student.models import (
Registration, UserProfile, PendingNameChange,
PendingEmailChange, CourseEnrollment, unique_id_for_user,
Expand All @@ -65,7 +64,6 @@

from courseware.courses import get_courses, sort_by_announcement
from courseware.access import has_access
from courseware.models import course_modified_times

from django_comment_common.models import Role

Expand Down Expand Up @@ -228,7 +226,7 @@ def single_course_reverification_info(user, course, enrollment): # pylint: disa
ReverifyInfo: (course_id, course_name, course_number, date, status)
OR, None: None if there is no re-verification info for this enrollment
"""
window = MidcourseReverificationWindow.get_window(course.id, datetime.now(UTC))
window = MidcourseReverificationWindow.get_window(course.id, datetime.datetime.now(UTC))

# If there's no window OR the user is not verified, we don't get reverification info
if (not window) or (enrollment.mode != "verified"):
Expand All @@ -246,8 +244,6 @@ def get_course_enrollment_pairs(user, course_org_filter, org_filter_out_set):
Get the relevant set of (Course, CourseEnrollment) pairs to be displayed on
a student's dashboard.
"""
pairs = []

for enrollment in CourseEnrollment.enrollments_for_user(user):
course = modulestore().get_course(enrollment.course_id)
if course and not isinstance(course, ErrorDescriptor):
Expand All @@ -261,18 +257,12 @@ def get_course_enrollment_pairs(user, course_org_filter, org_filter_out_set):
elif course.location.org in org_filter_out_set:
continue

pairs.append((course, enrollment))
yield (course, enrollment)
else:
log.error("User {0} enrolled in {2} course {1}".format(
user.username, enrollment.course_id, "broken" if course else "non-existent"
))

## Sort pairs in order of courseware access. If I am actively using a course, it should bubble up to the top.
modified_times_map = course_modified_times(user, [p[0].scope_ids.usage_id for p in pairs])
def key_function(x):
return modified_times_map.get(unicode(x[0].scope_ids.usage_id), datetime.min)
pairs.sort(key=key_function, reverse=True)
return pairs

def _cert_info(user, course, cert_status):
"""
Expand Down Expand Up @@ -439,7 +429,7 @@ def complete_course_mode_info(course_id, enrollment):
mode_info['show_upsell'] = True
# if there is an expiration date, find out how long from now it is
if modes['verified'].expiration_datetime:
today = datetime.now(UTC).date()
today = datetime.datetime.now(UTC).date()
mode_info['days_for_upsell'] = (modes['verified'].expiration_datetime.date() - today).days

return mode_info
Expand Down Expand Up @@ -1177,7 +1167,7 @@ def disable_account_ajax(request):
context['message'] = _("Unexpected account status")
return JsonResponse(context, status=400)
user_account.changed_by = request.user
user_account.standing_last_changed_at = datetime.now(UTC)
user_account.standing_last_changed_at = datetime.datetime.now(UTC)
user_account.save()

return JsonResponse(context)
Expand Down Expand Up @@ -1562,7 +1552,7 @@ def create_account(request, post_override=None): # pylint: disable-msg=too-many

if do_external_auth:
eamap.user = new_user
eamap.dtsignup = datetime.now(UTC)
eamap.dtsignup = datetime.datetime.now(UTC)
eamap.save()
AUDIT_LOG.info("User registered with external_auth %s", post_vars['username'])
AUDIT_LOG.info('Updated ExternalAuthMap for %s to be %s', post_vars['username'], eamap)
Expand Down Expand Up @@ -1990,7 +1980,7 @@ def confirm_email_change(request, key): # pylint: disable=unused-argument
meta = u_prof.get_meta()
if 'old_emails' not in meta:
meta['old_emails'] = []
meta['old_emails'].append([user.email, datetime.now(UTC).isoformat()])
meta['old_emails'].append([user.email, datetime.datetime.now(UTC).isoformat()])
u_prof.set_meta(meta)
u_prof.save()
# Send it to the old email...
Expand Down Expand Up @@ -2110,7 +2100,7 @@ def accept_name_change_by_id(uid):
meta = u_prof.get_meta()
if 'old_names' not in meta:
meta['old_names'] = []
meta['old_names'].append([u_prof.name, pnc.rationale, datetime.now(UTC).isoformat()])
meta['old_names'].append([u_prof.name, pnc.rationale, datetime.datetime.now(UTC).isoformat()])
u_prof.set_meta(meta)

u_prof.name = pnc.new_name
Expand Down
4 changes: 2 additions & 2 deletions common/test/acceptance/pages/lms/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ def is_browser_on_page(self):
return self.q(css='section.my-courses').present

@property
def courses_text(self):
text_items = self.q(css='section#my-courses span.my-courses-title-label').text
def current_courses_text(self):
text_items = self.q(css='section#my-courses').text
if len(text_items) > 0:
return text_items[0]
else:
Expand Down
12 changes: 6 additions & 6 deletions common/test/acceptance/tests/test_lms.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ def setUp(self):
self.dashboard_page = DashboardPage(self.browser)

self.test_new_lang = 'eo'
# This string is unicode for "ÇØÜRSÉS", which should appear in our Dummy Esperanto page
# This string is unicode for "ÇÜRRÉNT ÇØÜRSÉS", which should appear in our Dummy Esperanto page
# We store the string this way because Selenium seems to try and read in strings from
# the HTML in this format. Ideally we could just store the raw ÇÜRRÉNT ÇØÜRSÉS string here
self.courses_text = u'\xc7\xd6\xdcRS\xc9S'
self.current_courses_text = u'\xc7\xdcRR\xc9NT \xc7\xd6\xdcRS\xc9S'

self.username = "test"
self.password = "testpass"
Expand All @@ -92,10 +92,10 @@ def test_change_lang(self):
# Change language to Dummy Esperanto
self.dashboard_page.change_language(self.test_new_lang)

changed_text = self.dashboard_page.courses_text
changed_text = self.dashboard_page.current_courses_text

# We should see the dummy-language text on the page
self.assertIn(self.courses_text, changed_text)
self.assertIn(self.current_courses_text, changed_text)

def test_language_persists(self):
auto_auth_page = AutoAuthPage(self.browser, username=self.username, password=self.password, email=self.email, course_id=self.course_id)
Expand All @@ -113,10 +113,10 @@ def test_language_persists(self):

self.dashboard_page.visit()

changed_text = self.dashboard_page.courses_text
changed_text = self.dashboard_page.current_courses_text

# We should see the dummy-language text on the page
self.assertIn(self.courses_text, changed_text)
self.assertIn(self.current_courses_text, changed_text)


class HighLevelTabTest(UniqueCourseTest):
Expand Down
6 changes: 0 additions & 6 deletions lms/djangoapps/courseware/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,6 @@ def __unicode__(self):
return unicode(repr(self))


def course_modified_times(user, ids):
''' Returns the times when a given studentmodule was last modified.
'''
results = StudentModule.objects.filter(student=user, module_state_key__in=ids).values_list('module_state_key', 'modified')
return dict(results)

class StudentModuleHistory(models.Model):
"""Keeps a complete history of state changes for a given XModule for a given
Student. Right now, we restrict this to problems so that the table doesn't
Expand Down
22 changes: 0 additions & 22 deletions lms/static/sass/multicourse/_dashboard.scss
Original file line number Diff line number Diff line change
Expand Up @@ -308,28 +308,6 @@
margin-bottom: 30px;
}

// my courses title
.my-courses-title {
@include clearfix();
}

.my-courses-title-label {
display: inline-block;
vertical-align: middle;
width: flex-grid(6, 9);
}

.my-courses-title-description {
@extend %t-title7;
display: inline-block;
vertical-align: middle;
width: flex-grid(3, 9);
text-transform: lowercase;
text-align: right;
letter-spacing: 0;
color: $lighter-base-font-color;
}

.empty-dashboard-message {
padding: 60px 0px;
text-align: center;
Expand Down
5 changes: 1 addition & 4 deletions lms/templates/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,7 @@ <h1 class="user-name">${ user.username }</h1>

<section class="my-courses" id="my-courses">
<header>
<h2 class="my-courses-title">
<span class="my-courses-title-label">${_("Courses")}</span>
<span class="my-courses-title-description">${_("ordered by recent activity")}</span>
</h2>
<h2>${_("Current Courses")}</h2>
</header>

% if len(course_enrollment_pairs) > 0:
Expand Down