From c375666d884af8dfbfd006ae75b53b3040a92f5c Mon Sep 17 00:00:00 2001 From: Julia Hansbrough Date: Fri, 1 Nov 2013 20:23:43 +0000 Subject: [PATCH] Added new copy, small CR fixes * Changed text for "Are you sure you want to refund"... * Addressed a CR comment adding clarity to student view code * Converted UTC to pytz.utc --- common/djangoapps/student/views.py | 4 +--- lms/djangoapps/courseware/tests/test_access.py | 10 +++++----- lms/djangoapps/shoppingcart/tests/test_models.py | 10 +++++----- lms/templates/dashboard/_dashboard_course_listing.html | 8 ++++---- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/common/djangoapps/student/views.py b/common/djangoapps/student/views.py index af2d3e73ac..00a06495a4 100644 --- a/common/djangoapps/student/views.py +++ b/common/djangoapps/student/views.py @@ -470,9 +470,7 @@ def change_enrollment(request): ) elif action == "unenroll": - try: - CourseEnrollment.enrollment_mode_for_user(user, course_id) - except CourseEnrollment.DoesNotExist: + if not CourseEnrollment.is_enrolled(user, course_id): return HttpResponseBadRequest(_("You are not enrolled in this course")) CourseEnrollment.unenroll(user, course_id) org, course_num, run = course_id.split("/") diff --git a/lms/djangoapps/courseware/tests/test_access.py b/lms/djangoapps/courseware/tests/test_access.py index e537c60d21..d05a753f44 100644 --- a/lms/djangoapps/courseware/tests/test_access.py +++ b/lms/djangoapps/courseware/tests/test_access.py @@ -8,7 +8,7 @@ import courseware.access as access from courseware.tests.tests import TEST_DATA_MIXED_MODULESTORE from .factories import CourseEnrollmentAllowedFactory import datetime -from django.utils.timezone import UTC +import pytz from student.tests.factories import UserFactory from xmodule.modulestore.tests.factories import CourseFactory @@ -81,7 +81,7 @@ class AccessTestCase(TestCase): # TODO: override DISABLE_START_DATES and test the start date branch of the method u = Mock() d = Mock() - d.start = datetime.datetime.now(UTC()) - datetime.timedelta(days=1) # make sure the start time is in the past + d.start = datetime.datetime.now(pytz.utc) - datetime.timedelta(days=1) # make sure the start time is in the past # Always returns true because DISABLE_START_DATES is set in test.py self.assertTrue(access._has_access_descriptor(u, d, 'load')) @@ -89,8 +89,8 @@ class AccessTestCase(TestCase): def test__has_access_course_desc_can_enroll(self): u = Mock() - yesterday = datetime.datetime.now(UTC()) - datetime.timedelta(days=1) - tomorrow = datetime.datetime.now(UTC()) + datetime.timedelta(days=1) + yesterday = datetime.datetime.now(pytz.utc) - datetime.timedelta(days=1) + tomorrow = datetime.datetime.now(pytz.utc) + datetime.timedelta(days=1) c = Mock(enrollment_start=yesterday, enrollment_end=tomorrow, enrollment_domain='') # User can enroll if it is between the start and end dates @@ -118,7 +118,7 @@ class AccessTestCase(TestCase): # Non-staff cannot enroll outside the open enrollment period if not specifically allowed def test__has_access_refund(self): - today = datetime.datetime.now(UTC()) + today = datetime.datetime.now(pytz.utc) one_day_extra = datetime.timedelta(days=1) user = UserFactory.create() diff --git a/lms/djangoapps/shoppingcart/tests/test_models.py b/lms/djangoapps/shoppingcart/tests/test_models.py index 72d792d9d8..f158efe2b3 100644 --- a/lms/djangoapps/shoppingcart/tests/test_models.py +++ b/lms/djangoapps/shoppingcart/tests/test_models.py @@ -20,7 +20,7 @@ from student.tests.factories import UserFactory from student.models import CourseEnrollment from course_modes.models import CourseMode from shoppingcart.exceptions import PurchasedCallbackException -from django.utils.timezone import UTC +import pytz import datetime @@ -384,7 +384,7 @@ class CertificateItemTest(ModuleStoreTestCase): mode_slug="verified", mode_display_name="verified cert", min_price=self.cost, - expiration_date=(datetime.datetime.now(UTC()).date() + many_days)) + expiration_date=(datetime.datetime.now(pytz.utc).date() + many_days)) course_mode.save() CourseEnrollment.enroll(self.user, course_id, 'verified') @@ -407,7 +407,7 @@ class CertificateItemTest(ModuleStoreTestCase): mode_slug="verified", mode_display_name="verified cert", min_price=self.cost, - expiration_date=(datetime.datetime.now(UTC()).date() + many_days)) + expiration_date=(datetime.datetime.now(pytz.utc).date() + many_days)) course_mode.save() CourseEnrollment.enroll(self.user, course_id, 'verified') @@ -436,12 +436,12 @@ class CertificateItemTest(ModuleStoreTestCase): CertificateItem.add_to_order(cart, course_id, self.cost, 'verified') cart.purchase() - course_mode.expiration_date = (datetime.datetime.now(UTC()).date() - many_days) + course_mode.expiration_date = (datetime.datetime.now(pytz.utc).date() - many_days) course_mode.save() CourseEnrollment.unenroll(self.user, course_id) target_certs = CertificateItem.objects.filter(course_id=course_id, user_id=self.user, status='refunded', mode='verified') - self.assertEqual(len(target_certs),0) + self.assertEqual(len(target_certs), 0) def test_refund_cert_no_cert_exists(self): # If there is no paid certificate, the refund callback should return nothing diff --git a/lms/templates/dashboard/_dashboard_course_listing.html b/lms/templates/dashboard/_dashboard_course_listing.html index 6229a5472d..cb0efb33b7 100644 --- a/lms/templates/dashboard/_dashboard_course_listing.html +++ b/lms/templates/dashboard/_dashboard_course_listing.html @@ -142,11 +142,11 @@ % endif % if enrollment.mode != "verified": - ${_('Unregister')} + ${_('Unregister')} % elif show_refund_option: - ${_('Unregister')} + ${_('Unregister')} % else: - ${_('Unregister')} + ${_('Unregister')} % endif % if show_email_settings: @@ -163,7 +163,7 @@
-

${_('Are you sure you want to unregister from {course_number}? ').format(course_number='')}, ${_("modal open")}

+

${_(' {course_number}? ').format(course_number='')}, ${_("modal open")}

refund