Commit 3aa80654 by Julia Hansbrough

Midcourse reverification: fixing broken tests

Also, refactored code representing ReverifyInfo
parent 86588c49
......@@ -451,7 +451,6 @@ INSTALLED_APPS = (
# for managing course modes
'course_modes',
<<<<<<< HEAD
# Dark-launching languages
'dark_lang',
......
......@@ -84,6 +84,7 @@ log = logging.getLogger("edx.student")
AUDIT_LOG = logging.getLogger("audit")
Article = namedtuple('Article', 'title url author image deck publication publish_date')
ReverifyInfo = namedtuple('ReverifyInfo', 'course_id course_name course_number date status')
def csrf_token(context):
......@@ -209,7 +210,7 @@ def reverification_info(course_enrollment_pairs, user, statuses):
# Sort the data by the reverification_end_date
for status in statuses:
if reverifications[status]:
reverifications[status] = sorted(reverifications[status], key=lambda x: x[3])
reverifications[status] = sorted(reverifications[status], key=lambda x: x.date)
return reverifications
......@@ -217,7 +218,7 @@ def single_course_reverification_info(user, course, enrollment):
"""Returns midcourse reverification-related information for user with enrollment in course.
If a course has an open re-verification window, and that user has a verified enrollment in
the course, we return a tuple with relevant information. Returns None if there is no info..
the course, we return a tuple with relevant information. Returns None if there is no info..
Args:
user (User): the user we want to get information for
......@@ -225,7 +226,7 @@ def single_course_reverification_info(user, course, enrollment):
enrollment (CourseEnrollment): the object representing the type of enrollment user has in course
Returns:
5-tuple: (course_id, course_display_name, course_number, reverification_end_date, reverification_status)
5-namedtuple: (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.datetime.now(UTC))
......@@ -233,7 +234,7 @@ def single_course_reverification_info(user, course, enrollment):
# If there's no window OR the user is not verified, we don't get reverification info
if (not window) or (enrollment.mode != "verified"):
return None
return (
return ReverifyInfo(
course.id, course.display_name, course.number,
window.end_date.strftime('%B %d, %Y %X %p'),
SoftwareSecurePhotoVerification.user_status(user, window)[0],
......
......@@ -677,7 +677,7 @@ def fetch_reverify_banner_info(request, course_id):
reverifications = defaultdict(list)
user = request.user
if not user.id:
return {'reverifications': None, }
return reverifications
enrollment = CourseEnrollment.get_or_create_enrollment(request.user, course_id)
course = course_from_id(course_id)
info = single_course_reverification_info(user, course, enrollment)
......
......@@ -395,12 +395,12 @@ class MidCourseReverifyView(View):
return render_to_response("verify_student/midcourse_photo_reverification.html", context)
def midcourse_reverify_dash(_request):
def midcourse_reverify_dash(request):
"""
Shows the "course reverification dashboard", which displays the reverification status (must reverify,
pending, approved, failed, etc) of all courses in which a student has a verified enrollment.
"""
user = _request.user
user = request.user
course_enrollment_pairs = []
for enrollment in CourseEnrollment.enrollments_for_user(user):
try:
......
......@@ -8,10 +8,10 @@
<div class="msg msg-reverify has-actions">
<div class="msg-content">
<h2 class="title">${_("You need to re-verify to continue")}</h2>
% for course_id, course_name, course_number, date, status in reverifications["must_reverify"]:
% for item in reverifications["must_reverify"]:
<div class="copy">
<p class='activation-message'>
${_('To continue in the verified track in <strong>{course_name}</strong>, you need to re-verify your identity by {date}.').format(course_name=course_name, date=date)}
${_('To continue in the verified track in <strong>{course_name}</strong>, you need to re-verify your identity by {date}.').format(course_name=item.course_name, date=item.date)}
</p>
</div>
</div>
......@@ -32,10 +32,10 @@
<div class="msg msg-reverify is-dismissable">
<div class="msg-content">
<h2 class="title">${_("Your re-verification failed")}</h2>
% for course_id, course_name, course_number, date, status in reverifications["denied"]:
% for item in reverifications["denied"]:
<div class="copy">
<p class='activation-message'>
${_('Your re-verification for <strong>{course_name}</strong> failed and you are no longer eligible for a Verified Certificate. If you think this is in error, please contact us at support@edx.org.')}
${_('Your re-verification for <strong>{course_name}</strong> failed and you are no longer eligible for a Verified Certificate. If you think this is in error, please contact us at support@edx.org.').format(course_name=item.course_name)}
</p>
</div>
</div>
......
......@@ -10,26 +10,26 @@
<ul class="reverify-status-list">
% if reverifications["must_reverify"]:
% for course_id, course_name, course_number, date, status in reverifications["must_reverify"]:
<li class="status-item is-open">${_('<i class="icon-circle"></i><span class="label">Re-verify now:</span> <span class="course-name"><a href="">{course_name}</span></a>').format(course_name=course_name)}</li>
% for item in reverifications["must_reverify"]:
<li class="status-item is-open">${_('<i class="icon-circle"></i><span class="label">Re-verify now:</span> <span class="course-name"><a href="">{course_name}</span></a>').format(course_name=item.course_name)}</li>
% endfor
%endif
% if reverifications["pending"]:
% for course_id, course_name, course_number, date, status in reverifications["pending"]:
<li class="status-item is-pending">${_('<i class="icon-circle"></i><span class="label">Pending:</span> <span class="course-name"><a href="">{course_name}</span></a>').format(course_name=course_name)}</li>
% for item in reverifications["pending"]:
<li class="status-item is-pending">${_('<i class="icon-circle"></i><span class="label">Pending:</span> <span class="course-name"><a href="">{course_name}</span></a>').format(course_name=item.course_name)}</li>
% endfor
%endif
% if reverifications["denied"]:
% for course_id, course_name, course_number, date, status in reverifications["denied"]:
<li class="status-item is-denied">${_('<i class="icon-remove-sign"></i><span class="label">Denied:</span> <span class="course-name"><a href="">{course_name}</span></a>').format(course_name=course_name)}</li>
% for item in reverifications["denied"]:
<li class="status-item is-denied">${_('<i class="icon-remove-sign"></i><span class="label">Denied:</span> <span class="course-name"><a href="">{course_name}</span></a>').format(course_name=item.course_name)}</li>
% endfor
%endif
% if reverifications["approved"]:
% for course_id, course_name, course_number, date, status in reverifications["approved"]:
<li class="status-item is-approved">${_('<i class="icon-ok"></i><span class="label">Approved:</span> <span class="course-name"><a href="">{course_name}</span></a>').format(course_name=course_name)}</li>
% for item in reverifications["approved"]:
<li class="status-item is-approved">${_('<i class="icon-ok"></i><span class="label">Approved:</span> <span class="course-name"><a href="">{course_name}</span></a>').format(course_name=item.course_name)}</li>
% endfor
%endif
</ul>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment