Commit 46932ee0 by Ben McMorran

Replace data-test-course and data-test-unsucceeded with data-course-key

parent 0d1669c6
......@@ -5,6 +5,7 @@
import copy
import mock
import shutil
import lxml
from datetime import timedelta
from fs.osfs import OSFS
......@@ -1585,31 +1586,31 @@ class RerunCourseTest(ContentStoreTestCase):
destination_course_key = CourseKey.from_string(json_resp['destination_course_key'])
return destination_course_key
def create_course_listing_html(self, course_key):
"""Creates html fragment that is created for the given course_key in the course listing section"""
return 'data-test-course="{}/{}/{}"'.format(course_key.org, course_key.course, course_key.run)
def get_course_listing_elements(self, html, course_key):
"""Returns the elements in the course listing section of html that have the given course_key"""
return html.cssselect('.course-item[data-course-key="{}"]'.format(unicode(course_key)))
def create_unsucceeded_course_action_html(self, course_key):
"""Creates html fragment that is created for the given course_key in the unsucceeded course action section"""
return 'data-test-unsucceeded="{}/{}/{}"'.format(course_key.org, course_key.course, course_key.run)
def get_unsucceeded_course_action_elements(self, html, course_key):
"""Returns the elements in the unsucceeded course action section that have the given course_key"""
return html.cssselect('.courses-processing li[data-course-key="{}"]'.format(unicode(course_key)))
def assertInCourseListing(self, course_key):
"""
Asserts that the given course key is in the accessible course listing section of the html
and NOT in the unsucceeded course action section of the html.
"""
course_listing_html = self.client.get_html('/course/')
self.assertIn(self.create_course_listing_html(course_key), course_listing_html.content)
self.assertNotIn(self.create_unsucceeded_course_action_html(course_key), course_listing_html.content)
course_listing = lxml.html.fromstring(self.client.get_html('/course/').content)
self.assertEqual(len(self.get_course_listing_elements(course_listing, course_key)), 1)
self.assertEqual(len(self.get_unsucceeded_course_action_elements(course_listing, course_key)), 0)
def assertInUnsucceededCourseActions(self, course_key):
"""
Asserts that the given course key is in the unsucceeded course action section of the html
and NOT in the accessible course listing section of the html.
"""
course_listing_html = self.client.get_html('/course/')
self.assertNotIn(self.create_course_listing_html(course_key), course_listing_html.content)
self.assertIn(self.create_unsucceeded_course_action_html(course_key), course_listing_html.content)
course_listing = lxml.html.fromstring(self.client.get_html('/course/').content)
self.assertEqual(len(self.get_course_listing_elements(course_listing, course_key)), 0)
self.assertEqual(len(self.get_unsucceeded_course_action_elements(course_listing, course_key)), 1)
def test_rerun_course_success(self):
......
......@@ -353,33 +353,36 @@ def course_listing(request):
def format_course_for_view(course):
"""
return tuple of the data which the view requires for each course
Return a dict of the data which the view requires for each course
"""
return (
course.display_name,
reverse_course_url('course_handler', course.id),
get_lms_link_for_item(course.location),
_get_rerun_link_for_item(course.id),
course.display_org_with_default,
course.display_number_with_default,
course.location.run
)
return {
'display_name': course.display_name,
'course_key': unicode(course.location.course_key),
'url': reverse_course_url('course_handler', course.id),
'lms_link': get_lms_link_for_item(course.location),
'rerun_link': _get_rerun_link_for_item(course.id),
'org': course.display_org_with_default,
'number': course.display_number_with_default,
'run': course.location.run
}
def format_unsucceeded_course_for_view(uca):
"""
return tuple of the data which the view requires for each unsucceeded course
Return a dict of the data which the view requires for each unsucceeded course
"""
return (
uca.display_name,
uca.course_key.org,
uca.course_key.course,
uca.course_key.run,
True if uca.state == CourseRerunUIStateManager.State.FAILED else False,
True if uca.state == CourseRerunUIStateManager.State.IN_PROGRESS else False,
reverse_course_url('course_notifications_handler', uca.course_key, kwargs={
'action_state_id': uca.id,
}) if uca.state == CourseRerunUIStateManager.State.FAILED else ''
)
return {
'display_name': uca.display_name,
'course_key': unicode(uca.course_key),
'org': uca.course_key.org,
'number': uca.course_key.course,
'run': uca.course_key.run,
'is_failed': True if uca.state == CourseRerunUIStateManager.State.FAILED else False,
'is_in_progress': True if uca.state == CourseRerunUIStateManager.State.IN_PROGRESS else False,
'dismiss_link':
reverse_course_url('course_notifications_handler', uca.course_key, kwargs={
'action_state_id': uca.id,
}) if uca.state == CourseRerunUIStateManager.State.FAILED else ''
}
# remove any courses in courses that are also in the unsucceeded_course_actions list
unsucceeded_action_course_keys = [uca.course_key for uca in unsucceeded_course_actions]
......
......@@ -137,24 +137,24 @@ require(["domReady!", "jquery", "jquery.form", "js/index"], function(doc, $) {
<h3 class="title">Courses Being Processed</h3>
<ul class="list-courses">
%for display_name, org, num, run, state_failed, state_in_progress, dismiss_link in sorted(unsucceeded_course_actions, key=lambda s: s[0].lower() if s[0] is not None else ''):
%for course_info in sorted(unsucceeded_course_actions, key=lambda s: s['display_name'].lower() if s['display_name'] is not None else ''):
<!-- STATE: re-run is processing -->
%if state_in_progress:
<li class="wrapper-course has-status" data-test-unsucceeded="${org}/${num}/${run}">
%if course_info['is_in_progress']:
<li class="wrapper-course has-status" data-course-key="${course_info['course_key']}">
<div class="course-item course-rerun is-processing">
<div class="course-details" href="#">
<h3 class="course-title">${display_name}</h3>
<h3 class="course-title">${course_info['display_name']}</h3>
<div class="course-metadata">
<span class="course-org metadata-item">
<span class="label">${_("Organization:")}</span> <span class="value">${org}</span>
<span class="label">${_("Organization:")}</span> <span class="value">${course_info['org']}</span>
</span>
<span class="course-num metadata-item">
<span class="label">${_("Course Number:")}</span>
<span class="value">${num}</span>
<span class="value">${course_info['number']}</span>
</span>
<span class="course-run metadata-item">
<span class="label">${_("Course Run:")}</span> <span class="value">${run}</span>
<span class="label">${_("Course Run:")}</span> <span class="value">${course_info['run']}</span>
</span>
</div>
</div>
......@@ -177,22 +177,22 @@ require(["domReady!", "jquery", "jquery.form", "js/index"], function(doc, $) {
<!-- - - - -->
<!-- STATE: re-run has error -->
%if state_failed:
<li class="wrapper-course has-status" data-test-unsucceeded="${org}/${num}/${run}">
%if course_info['is_failed']:
<li class="wrapper-course has-status" data-course-key="${course_info['course_key']}">
<div class="course-item course-rerun has-error">
<div class="course-details" href="#">
<h3 class="course-title">${display_name}</h3>
<h3 class="course-title">${course_info['display_name']}</h3>
<div class="course-metadata">
<span class="course-org metadata-item">
<span class="label">${_("Organization:")}</span> <span class="value">${org}</span>
<span class="label">${_("Organization:")}</span> <span class="value">${course_info['org']}</span>
</span>
<span class="course-num metadata-item">
<span class="label">${_("Course Number:")}</span>
<span class="value">${num}</span>
<span class="value">${course_info['number']}</span>
</span>
<span class="course-run metadata-item">
<span class="label">${_("Course Run:")}</span> <span class="value">${run}</span>
<span class="label">${_("Course Run:")}</span> <span class="value">${course_info['run']}</span>
</span>
</div>
</div>
......@@ -211,7 +211,7 @@ require(["domReady!", "jquery", "jquery.form", "js/index"], function(doc, $) {
<ul class="status-actions">
<li class="action action-dismiss">
<a href="#" class="button dismiss-button" data-dismiss-link="${dismiss_link}">
<a href="#" class="button dismiss-button" data-dismiss-link="${course_info['dismiss_link']}">
<i class="icon icon-remove-sign"></i>
<span class="button-copy">${_("Dismiss")}</span>
</a>
......@@ -228,21 +228,21 @@ require(["domReady!", "jquery", "jquery.form", "js/index"], function(doc, $) {
%if len(courses) > 0:
<div class="courses">
<ul class="list-courses">
%for course, url, lms_link, rerun_link, org, num, run in sorted(courses, key=lambda s: s[0].lower() if s[0] is not None else ''):
<li class="course-item" data-test-course="${org}/${num}/${run}">
<a class="course-link" href="${url}">
<h3 class="course-title">${course}</h3>
%for course_info in sorted(courses, key=lambda s: s['display_name'].lower() if s['display_name'] is not None else ''):
<li class="course-item" data-course-key="${course_info['course_key']}">
<a class="course-link" href="${course_info['url']}">
<h3 class="course-title">${course_info['display_name']}</h3>
<div class="course-metadata">
<span class="course-org metadata-item">
<span class="label">${_("Organization:")}</span> <span class="value">${org}</span>
<span class="label">${_("Organization:")}</span> <span class="value">${course_info['org']}</span>
</span>
<span class="course-num metadata-item">
<span class="label">${_("Course Number:")}</span>
<span class="value">${num}</span>
<span class="value">${course_info['number']}</span>
</span>
<span class="course-run metadata-item">
<span class="label">${_("Course Run:")}</span> <span class="value">${run}</span>
<span class="label">${_("Course Run:")}</span> <span class="value">${course_info['run']}</span>
</span>
</div>
</a>
......@@ -250,11 +250,11 @@ require(["domReady!", "jquery", "jquery.form", "js/index"], function(doc, $) {
<ul class="item-actions course-actions">
% if allow_course_reruns and rerun_creator_status and course_creator_status=='granted':
<li class="action action-rerun">
<a href="${rerun_link}" class="button rerun-button">${_("Re-run Course")}</a>
<a href="${course_info['rerun_link']}" class="button rerun-button">${_("Re-run Course")}</a>
</li>
% endif
<li class="action action-view">
<a href="${lms_link}" rel="external" class="button view-button">${_("View Live")}</a>
<a href="${course_info['lms_link']}" rel="external" class="button view-button">${_("View Live")}</a>
</li>
</ul>
</li>
......
......@@ -10,6 +10,7 @@ bleach==1.4
html5lib==0.999
boto==2.13.3
celery==3.0.19
cssselect==0.9.1
dealer==0.2.3
distribute>=0.6.28, <0.7
django-babel-underscore==0.1.0
......
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