Commit 3c385e69 by tasawernawaz Committed by Tasawer Nawaz

Fixed course listing page for pilot demo ECOM-6796

parent cf869746
......@@ -1527,7 +1527,26 @@ class CourseListViewTests(TestCase):
self.assertContains(response, 'Add Course')
if course_count > 0:
self.assertContains(response, self.course.title)
self.assertContains(response, 'Edit')
def test_page_with_enable_waffle_switch(self):
"""
Verify that edit button will not be shown if 'publisher_hide_features_for_pilot' activated.
"""
self.user.groups.add(Group.objects.get(name=INTERNAL_USER_GROUP_NAME))
factories.CourseUserRoleFactory(course=self.course, user=self.user)
toggle_switch('publisher_hide_features_for_pilot', True)
response = self.client.get(self.courses_url)
self.assertNotIn(response.content.decode('UTF-8'), 'Edit')
def test_page_with_disable_waffle_switch(self):
"""
Verify that edit button will be shown if 'publisher_hide_features_for_pilot' dectivated.
"""
self.user.groups.add(Group.objects.get(name=INTERNAL_USER_GROUP_NAME))
factories.CourseUserRoleFactory(course=self.course, user=self.user)
toggle_switch('publisher_hide_features_for_pilot', False)
response = self.client.get(self.courses_url)
self.assertContains(response, 'Edit')
class CourseDetailViewTests(TestCase):
......
......@@ -492,3 +492,8 @@ class CourseListView(mixins.LoginRequiredMixin, ListView):
courses = Course.objects.filter(organizations__in=organizations)
return courses
def get_context_data(self, **kwargs):
context = super(CourseListView, self).get_context_data(**kwargs)
context['publisher_hide_features_for_pilot'] = waffle.switch_is_active('publisher_hide_features_for_pilot')
return context
......@@ -33,7 +33,13 @@
{% for course in object_list %}
<tr>
<td>
<a href="{% url 'publisher:publisher_course_detail' course.id %}">{{ course.title }}</a>
{% if publisher_hide_features_for_pilot %}
{{ course.title }}
{% else %}
<a href="{% url 'publisher:publisher_course_detail' course.id %}">
{{ course.title }}
</a>
{% endif %}
</td>
<td>
{% if course.organizations.first %}{{ course.organizations.first.name }}{% endif %}
......@@ -44,11 +50,13 @@
<td>
{{ course.publisher_course_runs.count }}
</td>
<td>
{% if not publisher_hide_features_for_pilot %}
<td>
<a href="{% url 'publisher:publisher_courses_edit' course.id %}" class="btn btn-brand btn-small btn-course-edit">
{% trans "Edit" %}
{% trans "Edit" %}
</a>
</td>
</td>
{% endif %}
</tr>
{% endfor %}
</tbody>
......
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