Commit 3029daf8 by Clinton Blackburn

Updated Publisher course list view

- Added course number to the table
- Renamed template
- Removed extraneous docstrings
parent fc83773b
......@@ -12,10 +12,8 @@ from course_discovery.apps.publisher.utils import has_role_for_course
class CourseSerializer(serializers.Serializer): # pylint: disable=abstract-method
"""
Publisher courses list serializer.
"""
course_title = serializers.SerializerMethodField()
number = serializers.SerializerMethodField()
organization_name = serializers.SerializerMethodField()
project_coordinator_name = serializers.SerializerMethodField()
publisher_course_runs_count = serializers.SerializerMethodField()
......@@ -23,10 +21,10 @@ class CourseSerializer(serializers.Serializer): # pylint: disable=abstract-meth
internal_user_status = serializers.SerializerMethodField()
edit_url = serializers.SerializerMethodField()
def get_number(self, course):
return course.number
def get_course_title(self, course):
"""
Returns a dict containing course `title` and `url`.
"""
publisher_hide_features_for_pilot = self.context['publisher_hide_features_for_pilot']
return {
'title': course.title,
......@@ -36,31 +34,19 @@ class CourseSerializer(serializers.Serializer): # pylint: disable=abstract-meth
}
def get_organization_name(self, course):
"""
Returns course organization name.
"""
return course.organization_name
def get_project_coordinator_name(self, course):
"""
Returns course project coordinator name.
"""
project_coordinator = course.project_coordinator
return project_coordinator.full_name if project_coordinator else ''
def get_publisher_course_runs_count(self, course):
"""
Returns count of course runs for a course.
"""
try:
return course.publisher_course_runs.count()
except ObjectDoesNotExist:
return 0
def get_course_team_status(self, course):
"""
Returns a dict containing `status` and `date` for course team status.
"""
default_status = {
'status': '',
'date': ''
......@@ -79,9 +65,6 @@ class CourseSerializer(serializers.Serializer): # pylint: disable=abstract-meth
}
def get_internal_user_status(self, course):
"""
Returns a dict containing `status` and `date` for internal user status.
"""
default_status = {
'status': '',
'date': ''
......@@ -100,9 +83,6 @@ class CourseSerializer(serializers.Serializer): # pylint: disable=abstract-meth
}
def get_edit_url(self, course):
"""
Returns a dict containing `title` and `url` to edit a course.
"""
courses_edit_url = None
publisher_hide_features_for_pilot = self.context['publisher_hide_features_for_pilot']
if not publisher_hide_features_for_pilot and self.can_edit_course(course, self.context['user']):
......@@ -115,16 +95,6 @@ class CourseSerializer(serializers.Serializer): # pylint: disable=abstract-meth
@classmethod
def can_edit_course(cls, course, user):
"""
Check if user has permissions on course.
Arguments:
course: course instance to be serialized
user: currently logedin user
Returns:
bool: Whether the logedin user has permission or not.
"""
try:
return check_course_organization_permission(
user, course, OrganizationExtension.EDIT_COURSE
......
......@@ -26,6 +26,9 @@
{% trans "Course Name" %}
</th>
<th role="button">
{% trans "Course Number" %}
</th>
<th role="button">
{% trans "Organization" %}
</th>
<th role="button">
......
......@@ -801,8 +801,6 @@ class ToggleEmailNotification(mixins.LoginRequiredMixin, View):
class CourseListView(mixins.LoginRequiredMixin, ListView):
""" Course List View."""
template_name = 'publisher/courses.html'
paginate_by = COURSES_DEFAULT_PAGE_SIZE
def get_queryset(self):
......@@ -825,8 +823,8 @@ class CourseListView(mixins.LoginRequiredMixin, ListView):
).values_list('organization')
courses = courses.filter(organizations__in=organizations)
courses = self.do_ordering(courses)
courses = self.do_filtering(courses)
courses = self.sort_queryset(courses)
courses = self.filter_queryset(courses)
return courses
......@@ -840,9 +838,6 @@ class CourseListView(mixins.LoginRequiredMixin, ListView):
return context
def get_paginate_by(self, queryset):
"""
Get the number of items to paginate by.
"""
try:
page_size = int(self.request.GET.get('pageSize', COURSES_DEFAULT_PAGE_SIZE))
page_size = page_size if page_size in COURSES_ALLOWED_PAGE_SIZES else COURSES_DEFAULT_PAGE_SIZE
......@@ -851,10 +846,7 @@ class CourseListView(mixins.LoginRequiredMixin, ListView):
return page_size
def do_ordering(self, queryset):
"""
Perform ordering on queryset
"""
def sort_queryset(self, queryset):
# commented fields are multi-valued so ordering is not reliable becuase a single
# record can be returned multiple times. We are not doing ordering for these fields
ordering_fields = {
......@@ -886,10 +878,7 @@ class CourseListView(mixins.LoginRequiredMixin, ListView):
return queryset
def do_filtering(self, queryset):
"""
Perform filtering on queryset
"""
def filter_queryset(self, queryset):
filter_text = self.request.GET.get('searchText', '').strip()
if not filter_text:
......@@ -901,7 +890,8 @@ class CourseListView(mixins.LoginRequiredMixin, ListView):
keywords_filter = None
for keyword in keywords:
keyword_filter = Q(title__icontains=keyword) | Q(organizations__key__icontains=keyword)
keyword_filter = Q(title__icontains=keyword) | Q(organizations__key__icontains=keyword) | Q(
number__icontains=keyword)
keywords_filter = (keyword_filter & keywords_filter) if bool(keywords_filter) else keyword_filter
if keywords_filter:
......@@ -968,10 +958,7 @@ class CourseListView(mixins.LoginRequiredMixin, ListView):
return keywords, dates
def get(self, request):
"""
HTTP GET handler for publisher courses.
"""
def get(self, request, **kwargs): # pylint: disable=unused-argument
self.object_list = self.get_queryset()
context = self.get_context_data()
context['publisher_total_courses_count'] = self.object_list.count()
......
......@@ -7,14 +7,14 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-09-27 18:21+0000\n"
"POT-Creation-Date: 2017-09-28 00:07-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: \n"
#: apps/api/filters.py
#, python-brace-format
......@@ -501,7 +501,8 @@ msgstr ""
msgid "Partner Manager"
msgstr ""
#: apps/publisher/choices.py apps/publisher/templates/publisher/courses.html
#: apps/publisher/choices.py
#: apps/publisher/templates/publisher/course_list.html
msgid "Project Coordinator"
msgstr ""
......@@ -513,7 +514,8 @@ msgstr ""
msgid "Publisher"
msgstr ""
#: apps/publisher/choices.py apps/publisher/templates/publisher/courses.html
#: apps/publisher/choices.py
#: apps/publisher/templates/publisher/course_list.html
#: apps/publisher/templates/publisher/dashboard/_in_progress.html
msgid "Course Team"
msgstr ""
......@@ -615,6 +617,7 @@ msgstr ""
#: apps/publisher/forms.py
#: apps/publisher/templates/publisher/course_detail.html
#: apps/publisher/templates/publisher/course_list.html
#: apps/publisher/templates/publisher/course_revision_history.html
#: apps/publisher/templates/publisher/dashboard/_in_progress.html
#: apps/publisher/templates/publisher/dashboard/_published.html
......@@ -977,10 +980,10 @@ msgid "Institution email is preferred"
msgstr ""
#: apps/publisher/templates/publisher/_add_instructor_popup.html
#: apps/publisher/templates/publisher/course_list.html
#: apps/publisher/templates/publisher/course_run_detail/_drupal.html
#: apps/publisher/templates/publisher/course_run_detail/_instructor_profile.html
#: apps/publisher/templates/publisher/course_run_detail/_studio.html
#: apps/publisher/templates/publisher/courses.html
#: apps/publisher/templates/publisher/dashboard/_in_preview.html
#: apps/publisher/templates/publisher/dashboard/_in_progress.html
#: apps/publisher/templates/publisher/dashboard/_published.html
......@@ -1215,7 +1218,7 @@ msgid "Are you sure you want to revert all changes to this version ?"
msgstr ""
#: apps/publisher/templates/publisher/add_course_form.html
#: apps/publisher/templates/publisher/courses.html
#: apps/publisher/templates/publisher/course_list.html
msgid "Create New Course"
msgstr ""
......@@ -1438,7 +1441,7 @@ msgid "Dashboard"
msgstr ""
#: apps/publisher/templates/publisher/base.html
#: apps/publisher/templates/publisher/courses.html
#: apps/publisher/templates/publisher/course_list.html
msgid "Courses"
msgstr ""
......@@ -1954,6 +1957,19 @@ msgstr ""
msgid "Update Course"
msgstr ""
#: apps/publisher/templates/publisher/course_list.html
#: apps/publisher/templates/publisher/course_run_detail/_studio.html
#: apps/publisher/templates/publisher/dashboard/_in_preview.html
#: apps/publisher/templates/publisher/dashboard/_in_progress.html
#: apps/publisher/templates/publisher/dashboard/_published.html
#: apps/publisher/templates/publisher/dashboard/_studio_requests.html
msgid "Course Name"
msgstr ""
#: apps/publisher/templates/publisher/course_list.html
msgid "Runs"
msgstr ""
#: apps/publisher/templates/publisher/course_revision_history.html
msgid "Revision History"
msgstr ""
......@@ -2407,15 +2423,6 @@ msgid "Enrollment Type"
msgstr ""
#: apps/publisher/templates/publisher/course_run_detail/_studio.html
#: apps/publisher/templates/publisher/courses.html
#: apps/publisher/templates/publisher/dashboard/_in_preview.html
#: apps/publisher/templates/publisher/dashboard/_in_progress.html
#: apps/publisher/templates/publisher/dashboard/_published.html
#: apps/publisher/templates/publisher/dashboard/_studio_requests.html
msgid "Course Name"
msgstr ""
#: apps/publisher/templates/publisher/course_run_detail/_studio.html
msgid "Enrollment Start Date (time in UTC)"
msgstr ""
......@@ -2473,10 +2480,6 @@ msgstr ""
msgid "Publication failed."
msgstr ""
#: apps/publisher/templates/publisher/courses.html
msgid "Runs"
msgstr ""
#: apps/publisher/templates/publisher/dashboard.html
msgid "Course About Pages"
msgstr ""
......
......@@ -7,14 +7,14 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-09-27 18:21+0000\n"
"POT-Creation-Date: 2017-09-28 00:07-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: \n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: apps/api/filters.py
......@@ -620,7 +620,8 @@ msgstr ""
msgid "Partner Manager"
msgstr "Pärtnér Mänägér Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт α#"
#: apps/publisher/choices.py apps/publisher/templates/publisher/courses.html
#: apps/publisher/choices.py
#: apps/publisher/templates/publisher/course_list.html
msgid "Project Coordinator"
msgstr "Pröjéçt Çöördïnätör Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт αмєт,#"
......@@ -632,7 +633,8 @@ msgstr "Märkétïng Révïéwér Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт α
msgid "Publisher"
msgstr "Püßlïshér Ⱡ'σяєм ιρѕυм ∂σł#"
#: apps/publisher/choices.py apps/publisher/templates/publisher/courses.html
#: apps/publisher/choices.py
#: apps/publisher/templates/publisher/course_list.html
#: apps/publisher/templates/publisher/dashboard/_in_progress.html
msgid "Course Team"
msgstr "Çöürsé Téäm Ⱡ'σяєм ιρѕυм ∂σłσя #"
......@@ -746,6 +748,7 @@ msgstr "Çöürsé Tïtlé Ⱡ'σяєм ιρѕυм ∂σłσя ѕ#"
#: apps/publisher/forms.py
#: apps/publisher/templates/publisher/course_detail.html
#: apps/publisher/templates/publisher/course_list.html
#: apps/publisher/templates/publisher/course_revision_history.html
#: apps/publisher/templates/publisher/dashboard/_in_progress.html
#: apps/publisher/templates/publisher/dashboard/_published.html
......@@ -1138,10 +1141,10 @@ msgid "Institution email is preferred"
msgstr "Ìnstïtütïön émäïl ïs préférréd Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт αмєт, ¢σηѕє¢т#"
#: apps/publisher/templates/publisher/_add_instructor_popup.html
#: apps/publisher/templates/publisher/course_list.html
#: apps/publisher/templates/publisher/course_run_detail/_drupal.html
#: apps/publisher/templates/publisher/course_run_detail/_instructor_profile.html
#: apps/publisher/templates/publisher/course_run_detail/_studio.html
#: apps/publisher/templates/publisher/courses.html
#: apps/publisher/templates/publisher/dashboard/_in_preview.html
#: apps/publisher/templates/publisher/dashboard/_in_progress.html
#: apps/publisher/templates/publisher/dashboard/_published.html
......@@ -1394,7 +1397,7 @@ msgstr ""
"∂σłσя ѕιт αмєт, ¢σηѕє¢тєтυя α#"
#: apps/publisher/templates/publisher/add_course_form.html
#: apps/publisher/templates/publisher/courses.html
#: apps/publisher/templates/publisher/course_list.html
msgid "Create New Course"
msgstr "Çréäté Néw Çöürsé Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт αмє#"
......@@ -1678,7 +1681,7 @@ msgid "Dashboard"
msgstr "Däshßöärd Ⱡ'σяєм ιρѕυм ∂σł#"
#: apps/publisher/templates/publisher/base.html
#: apps/publisher/templates/publisher/courses.html
#: apps/publisher/templates/publisher/course_list.html
msgid "Courses"
msgstr "Çöürsés Ⱡ'σяєм ιρѕυм #"
......@@ -2336,6 +2339,19 @@ msgstr ""
msgid "Update Course"
msgstr "Ûpdäté Çöürsé Ⱡ'σяєм ιρѕυм ∂σłσя ѕι#"
#: apps/publisher/templates/publisher/course_list.html
#: apps/publisher/templates/publisher/course_run_detail/_studio.html
#: apps/publisher/templates/publisher/dashboard/_in_preview.html
#: apps/publisher/templates/publisher/dashboard/_in_progress.html
#: apps/publisher/templates/publisher/dashboard/_published.html
#: apps/publisher/templates/publisher/dashboard/_studio_requests.html
msgid "Course Name"
msgstr "Çöürsé Nämé Ⱡ'σяєм ιρѕυм ∂σłσя #"
#: apps/publisher/templates/publisher/course_list.html
msgid "Runs"
msgstr "Rüns Ⱡ'σяєм ι#"
#: apps/publisher/templates/publisher/course_revision_history.html
msgid "Revision History"
msgstr "Révïsïön Hïstörý Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт αм#"
......@@ -2845,15 +2861,6 @@ msgid "Enrollment Type"
msgstr "Énröllmént Týpé Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт α#"
#: apps/publisher/templates/publisher/course_run_detail/_studio.html
#: apps/publisher/templates/publisher/courses.html
#: apps/publisher/templates/publisher/dashboard/_in_preview.html
#: apps/publisher/templates/publisher/dashboard/_in_progress.html
#: apps/publisher/templates/publisher/dashboard/_published.html
#: apps/publisher/templates/publisher/dashboard/_studio_requests.html
msgid "Course Name"
msgstr "Çöürsé Nämé Ⱡ'σяєм ιρѕυм ∂σłσя #"
#: apps/publisher/templates/publisher/course_run_detail/_studio.html
msgid "Enrollment Start Date (time in UTC)"
msgstr ""
"Énröllmént Stärt Däté (tïmé ïn ÛTÇ) Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт αмєт, ¢σηѕє¢тєт#"
......@@ -2917,10 +2924,6 @@ msgstr ""
msgid "Publication failed."
msgstr "Püßlïçätïön fäïléd. Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт αмєт,#"
#: apps/publisher/templates/publisher/courses.html
msgid "Runs"
msgstr "Rüns Ⱡ'σяєм ι#"
#: apps/publisher/templates/publisher/dashboard.html
msgid "Course About Pages"
msgstr "Çöürsé Àßöüt Pägés Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт αмєт#"
......
$(document).ready(function() {
var data = $('.course-count-heading').data();
var $coursesTable = $('#dataTableCourse').DataTable({
......@@ -37,34 +36,38 @@ $(document).ready(function() {
},
{
"targets": 1,
"data": "number"
},
{
"targets": 2,
"data": "organization_name",
"sortable": false
},
{
"targets": 2,
"targets": 3,
"data": "project_coordinator_name",
"sortable": false
},
{
"targets": 3,
"targets": 4,
"data": "publisher_course_runs_count"
},
{
"targets": 4,
"targets": 5,
"data": "course_team_status",
"render": function ( data, type, full, meta ) {
return data.status + '<br>' + data.date;
}
},
{
"targets": 5,
"targets": 6,
"data": "internal_user_status",
"render": function ( data, type, full, meta ) {
return data.status + '<br>' + data.date;
}
},
{
"targets": 6,
"targets": 7,
"data": "edit_url",
"sortable": false,
"render": function ( data, type, full, meta ) {
......
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