Commit 8823e0d2 by Awais Qureshi Committed by GitHub

Merge pull request #283 from edx/awais786/ECOM-5387-course-runs-improve

ECOM-5387
parents acfa0465 7ea2aa43
......@@ -67,7 +67,7 @@ class ProgramAdmin(admin.ModelAdmin):
list_display = ('id', 'uuid', 'title', 'category', 'type', 'partner', 'status',)
list_filter = ('partner', 'type',)
ordering = ('uuid', 'title', 'status')
readonly_fields = ('uuid', 'course_runs', 'excluded_course_runs',)
readonly_fields = ('uuid', 'custom_course_runs_display', 'excluded_course_runs',)
search_fields = ('uuid', 'title', 'marketing_slug')
......@@ -79,11 +79,16 @@ class ProgramAdmin(admin.ModelAdmin):
'banner_image_url', 'card_image_url', 'overview', 'video',
)
fields += (
'courses', 'course_runs', 'excluded_course_runs', 'authoring_organizations',
'courses', 'custom_course_runs_display', 'excluded_course_runs', 'authoring_organizations',
'credit_backing_organizations'
)
fields += filter_horizontal
def custom_course_runs_display(self, obj):
return ", ".join([str(run) for run in obj.course_runs])
custom_course_runs_display.short_description = "Included course runs"
def response_add(self, request, obj, post_url_continue=None):
return HttpResponseRedirect(reverse('admin_metadata:update_course_runs', kwargs={'pk': obj.pk}))
......
......@@ -34,6 +34,8 @@ class AdminTests(TestCase):
""" Verify that course selection page loads successfully. """
response = self.client.get(reverse('admin_metadata:update_course_runs', args=(self.program.id,)))
self.assertEqual(response.status_code, 200)
self.assertContains(response, reverse('admin:course_metadata_program_change', args=(self.program.id,)))
self.assertContains(response, reverse('admin:course_metadata_program_changelist'))
def test_custom_course_selection_page_with_invalid_id(self):
""" Verify that course selection page will return 404 for invalid program id. """
......
......@@ -24,7 +24,9 @@ class CourseRunSelectionAdmin(UpdateView):
def get_context_data(self, **kwargs):
if self.request.user.is_authenticated() and self.request.user.is_staff:
return super(CourseRunSelectionAdmin, self).get_context_data(**kwargs)
context = super(CourseRunSelectionAdmin, self).get_context_data(**kwargs)
context['program_id'] = self.object.id
return context
raise Http404
def form_valid(self, form):
......
......@@ -23,6 +23,9 @@
<a href="{% url 'admin:course_metadata_program_changelist' %}">
<input type="button" name="Cancel" value="{% trans 'Cancel' %}">
</a>
<a href="{% url 'admin:course_metadata_program_change' program_id %}">
<input type="button" name="Back" value="{% trans 'Back to Program' %}">
</a>
<input type="submit" value="{% trans 'Save Course Run' %}" class="default" name="_save" />
</div>
{% endblock %}
......
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