Commit e4ad2a6d by Awais Committed by Awais Qureshi

After course-creation redirect towards course-detail page.

ECOM-7142
parent 15bd7d7f
......@@ -199,9 +199,15 @@ class CreateCourseViewTests(TestCase):
course_dict = self._post_data(data, self.course, self.course_run, self.seat)
course_dict['price'] = 0
course_dict['type'] = Seat.AUDIT
response = self.client.post(reverse('publisher:publisher_courses_new'), course_dict, files=data['image'])
response = self.client.post(
reverse('publisher:publisher_courses_new'), course_dict, files=data['image'], follow=True
)
course = Course.objects.get(number=data['number'])
self._assert_test_data(response, course, Seat.AUDIT, 0)
self.assertIn(
'You have successfully created a course. You can edit the course information',
response.content.decode('UTF-8')
)
def test_create_form_with_single_organization(self):
"""Verify that if there is only one organization then that organization will be shown as text. """
......@@ -304,15 +310,14 @@ class CreateCourseViewTests(TestCase):
def _assert_test_data(self, response, course, expected_type, expected_price):
course_run = course.publisher_course_runs.get()
run_detail_path = reverse('publisher:publisher_course_run_detail', kwargs={'pk': course_run.id})
course_detail_path = reverse('publisher:publisher_course_detail', kwargs={'pk': course.id})
self.assertRedirects(
response,
expected_url=run_detail_path,
expected_url=course_detail_path,
status_code=302,
target_status_code=200
)
self.assertEqual(course.organizations.first(), self.organization_extension.organization)
self.assertEqual(len(course.course_user_roles.all()), 3)
self.assertEqual(course.course_user_roles.filter(role=PublisherUserRole.CourseTeam).count(), 1)
......
......@@ -182,7 +182,7 @@ class CreateCourseView(mixins.LoginRequiredMixin, mixins.PublisherUserRequiredMi
run_form = CustomCourseRunForm
seat_form = CustomSeatForm
template_name = 'publisher/add_update_course_form.html'
success_url = 'publisher:publisher_course_run_detail'
success_url = 'publisher:publisher_course_detail'
def get_success_url(self, course_id): # pylint: disable=arguments-differ
return reverse(self.success_url, kwargs={'pk': course_id})
......@@ -266,7 +266,7 @@ class CreateCourseView(mixins.LoginRequiredMixin, mixins.PublisherUserRequiredMi
# sending email for notifying new course is created.
emails.send_email_for_course_creation(course, run_course)
return HttpResponseRedirect(self.get_success_url(run_course.id))
return HttpResponseRedirect(self.get_success_url(course.id))
except Exception as e: # pylint: disable=broad-except
# pylint: disable=no-member
error_message = _('An error occurred while saving your changes. {error}').format(error=str(e))
......
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