Skip to content
Snippets Groups Projects
Commit 9542b0a8 authored by David Baumgold's avatar David Baumgold
Browse files

Revert "Puts course listings in a sane order"

This reverts commit 1955aade36675289bdbc01554b6f74242754a746.
parent 45512442
No related merge requests found
...@@ -88,7 +88,6 @@ class TestCourseListing(ModuleStoreTestCase): ...@@ -88,7 +88,6 @@ class TestCourseListing(ModuleStoreTestCase):
courses_list = list(get_course_enrollment_pairs(self.student, None, [])) courses_list = list(get_course_enrollment_pairs(self.student, None, []))
self.assertEqual(courses_list, []) self.assertEqual(courses_list, [])
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
def test_course_listing_errored_deleted_courses(self): def test_course_listing_errored_deleted_courses(self):
""" """
Create good courses, courses that won't load, and deleted courses which still have Create good courses, courses that won't load, and deleted courses which still have
......
""" """
Student Views Student Views
""" """
import datetime
import logging import logging
import re import re
import uuid import uuid
import time import time
import json import json
from collections import defaultdict from collections import defaultdict
from datetime import datetime
from pytz import UTC from pytz import UTC
from django.conf import settings from django.conf import settings
...@@ -42,7 +42,6 @@ from edxmako.shortcuts import render_to_response, render_to_string ...@@ -42,7 +42,6 @@ from edxmako.shortcuts import render_to_response, render_to_string
from mako.exceptions import TopLevelLookupException from mako.exceptions import TopLevelLookupException
from course_modes.models import CourseMode from course_modes.models import CourseMode
from student.models import ( from student.models import (
Registration, UserProfile, PendingNameChange, Registration, UserProfile, PendingNameChange,
PendingEmailChange, CourseEnrollment, unique_id_for_user, PendingEmailChange, CourseEnrollment, unique_id_for_user,
...@@ -65,7 +64,6 @@ from collections import namedtuple ...@@ -65,7 +64,6 @@ from collections import namedtuple
from courseware.courses import get_courses, sort_by_announcement from courseware.courses import get_courses, sort_by_announcement
from courseware.access import has_access from courseware.access import has_access
from courseware.models import course_modified_times
from django_comment_common.models import Role from django_comment_common.models import Role
...@@ -228,7 +226,7 @@ def single_course_reverification_info(user, course, enrollment): # pylint: disa ...@@ -228,7 +226,7 @@ def single_course_reverification_info(user, course, enrollment): # pylint: disa
ReverifyInfo: (course_id, course_name, course_number, date, status) ReverifyInfo: (course_id, course_name, course_number, date, status)
OR, None: None if there is no re-verification info for this enrollment 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 there's no window OR the user is not verified, we don't get reverification info
if (not window) or (enrollment.mode != "verified"): if (not window) or (enrollment.mode != "verified"):
...@@ -246,8 +244,6 @@ def get_course_enrollment_pairs(user, course_org_filter, org_filter_out_set): ...@@ -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 Get the relevant set of (Course, CourseEnrollment) pairs to be displayed on
a student's dashboard. a student's dashboard.
""" """
pairs = []
for enrollment in CourseEnrollment.enrollments_for_user(user): for enrollment in CourseEnrollment.enrollments_for_user(user):
course = modulestore().get_course(enrollment.course_id) course = modulestore().get_course(enrollment.course_id)
if course and not isinstance(course, ErrorDescriptor): if course and not isinstance(course, ErrorDescriptor):
...@@ -261,18 +257,12 @@ def get_course_enrollment_pairs(user, course_org_filter, org_filter_out_set): ...@@ -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: elif course.location.org in org_filter_out_set:
continue continue
pairs.append((course, enrollment)) yield (course, enrollment)
else: else:
log.error("User {0} enrolled in {2} course {1}".format( log.error("User {0} enrolled in {2} course {1}".format(
user.username, enrollment.course_id, "broken" if course else "non-existent" 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): def _cert_info(user, course, cert_status):
""" """
...@@ -439,7 +429,7 @@ def complete_course_mode_info(course_id, enrollment): ...@@ -439,7 +429,7 @@ def complete_course_mode_info(course_id, enrollment):
mode_info['show_upsell'] = True mode_info['show_upsell'] = True
# if there is an expiration date, find out how long from now it is # if there is an expiration date, find out how long from now it is
if modes['verified'].expiration_datetime: 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 mode_info['days_for_upsell'] = (modes['verified'].expiration_datetime.date() - today).days
return mode_info return mode_info
...@@ -1177,7 +1167,7 @@ def disable_account_ajax(request): ...@@ -1177,7 +1167,7 @@ def disable_account_ajax(request):
context['message'] = _("Unexpected account status") context['message'] = _("Unexpected account status")
return JsonResponse(context, status=400) return JsonResponse(context, status=400)
user_account.changed_by = request.user 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() user_account.save()
return JsonResponse(context) return JsonResponse(context)
...@@ -1562,7 +1552,7 @@ def create_account(request, post_override=None): # pylint: disable-msg=too-many ...@@ -1562,7 +1552,7 @@ def create_account(request, post_override=None): # pylint: disable-msg=too-many
if do_external_auth: if do_external_auth:
eamap.user = new_user eamap.user = new_user
eamap.dtsignup = datetime.now(UTC) eamap.dtsignup = datetime.datetime.now(UTC)
eamap.save() eamap.save()
AUDIT_LOG.info("User registered with external_auth %s", post_vars['username']) 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) AUDIT_LOG.info('Updated ExternalAuthMap for %s to be %s', post_vars['username'], eamap)
...@@ -1990,7 +1980,7 @@ def confirm_email_change(request, key): # pylint: disable=unused-argument ...@@ -1990,7 +1980,7 @@ def confirm_email_change(request, key): # pylint: disable=unused-argument
meta = u_prof.get_meta() meta = u_prof.get_meta()
if 'old_emails' not in meta: if 'old_emails' not in meta:
meta['old_emails'] = [] 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.set_meta(meta)
u_prof.save() u_prof.save()
# Send it to the old email... # Send it to the old email...
...@@ -2110,7 +2100,7 @@ def accept_name_change_by_id(uid): ...@@ -2110,7 +2100,7 @@ def accept_name_change_by_id(uid):
meta = u_prof.get_meta() meta = u_prof.get_meta()
if 'old_names' not in meta: if 'old_names' not in meta:
meta['old_names'] = [] 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.set_meta(meta)
u_prof.name = pnc.new_name u_prof.name = pnc.new_name
......
...@@ -20,8 +20,8 @@ class DashboardPage(PageObject): ...@@ -20,8 +20,8 @@ class DashboardPage(PageObject):
return self.q(css='section.my-courses').present return self.q(css='section.my-courses').present
@property @property
def courses_text(self): def current_courses_text(self):
text_items = self.q(css='section#my-courses span.my-courses-title-label').text text_items = self.q(css='section#my-courses').text
if len(text_items) > 0: if len(text_items) > 0:
return text_items[0] return text_items[0]
else: else:
......
...@@ -77,10 +77,10 @@ class LanguageTest(UniqueCourseTest): ...@@ -77,10 +77,10 @@ class LanguageTest(UniqueCourseTest):
self.dashboard_page = DashboardPage(self.browser) self.dashboard_page = DashboardPage(self.browser)
self.test_new_lang = 'eo' 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 # 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 # 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.username = "test"
self.password = "testpass" self.password = "testpass"
...@@ -92,10 +92,10 @@ class LanguageTest(UniqueCourseTest): ...@@ -92,10 +92,10 @@ class LanguageTest(UniqueCourseTest):
# Change language to Dummy Esperanto # Change language to Dummy Esperanto
self.dashboard_page.change_language(self.test_new_lang) 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 # 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): 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) auto_auth_page = AutoAuthPage(self.browser, username=self.username, password=self.password, email=self.email, course_id=self.course_id)
...@@ -113,10 +113,10 @@ class LanguageTest(UniqueCourseTest): ...@@ -113,10 +113,10 @@ class LanguageTest(UniqueCourseTest):
self.dashboard_page.visit() 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 # 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): class HighLevelTabTest(UniqueCourseTest):
......
...@@ -93,12 +93,6 @@ class StudentModule(models.Model): ...@@ -93,12 +93,6 @@ class StudentModule(models.Model):
return unicode(repr(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): class StudentModuleHistory(models.Model):
"""Keeps a complete history of state changes for a given XModule for a given """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 Student. Right now, we restrict this to problems so that the table doesn't
......
...@@ -308,28 +308,6 @@ ...@@ -308,28 +308,6 @@
margin-bottom: 30px; 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 { .empty-dashboard-message {
padding: 60px 0px; padding: 60px 0px;
text-align: center; text-align: center;
......
...@@ -291,10 +291,7 @@ ...@@ -291,10 +291,7 @@
<section class="my-courses" id="my-courses"> <section class="my-courses" id="my-courses">
<header> <header>
<h2 class="my-courses-title"> <h2>${_("Current Courses")}</h2>
<span class="my-courses-title-label">${_("Courses")}</span>
<span class="my-courses-title-description">${_("ordered by recent activity")}</span>
</h2>
</header> </header>
% if len(course_enrollment_pairs) > 0: % if len(course_enrollment_pairs) > 0:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment