Commit 8730da0e by Waheed Ahmed

Don't show history widget for single object.

ECOM-7501
parent 2e556a19
...@@ -1584,14 +1584,6 @@ class CourseDetailViewTests(TestCase): ...@@ -1584,14 +1584,6 @@ class CourseDetailViewTests(TestCase):
self.assertContains(response, 'STUDIO URL -') self.assertContains(response, 'STUDIO URL -')
self.assertContains(response, 'Not yet created') self.assertContains(response, 'Not yet created')
self.assertContains(response, reverse('publisher:publisher_course_run_detail', kwargs={'pk': course_run.id})) self.assertContains(response, reverse('publisher:publisher_course_run_detail', kwargs={'pk': course_run.id}))
self.assertContains(response, 'REVISION HISTORY')
revision_url = reverse(
'publisher:publisher_course_revision', args=[self.course.id, self.course.history.first().history_id]
)
self.assertContains(
response, '<option value="{revision_url}">Latest version</option>'.format(revision_url=revision_url)
)
def test_detail_page_data(self): def test_detail_page_data(self):
""" """
...@@ -1657,6 +1649,9 @@ class CourseDetailViewTests(TestCase): ...@@ -1657,6 +1649,9 @@ class CourseDetailViewTests(TestCase):
""" Verify that user will see the history widget when """ Verify that user will see the history widget when
'publisher_history_widget_feature' is enabled. 'publisher_history_widget_feature' is enabled.
""" """
# Update course to create multiple history objects.
self.course.title = 'Updated Test Title'
self.course.save()
self.user.groups.add(Group.objects.get(name=INTERNAL_USER_GROUP_NAME)) self.user.groups.add(Group.objects.get(name=INTERNAL_USER_GROUP_NAME))
toggle_switch('publisher_history_widget_feature', True) toggle_switch('publisher_history_widget_feature', True)
response = self.client.get(self.detail_page_url) response = self.client.get(self.detail_page_url)
...@@ -1666,6 +1661,9 @@ class CourseDetailViewTests(TestCase): ...@@ -1666,6 +1661,9 @@ class CourseDetailViewTests(TestCase):
""" Verify that user will not see the history widget when """ Verify that user will not see the history widget when
'publisher_history_widget_feature' is disabled. 'publisher_history_widget_feature' is disabled.
""" """
# Update course to create multiple history objects.
self.course.title = 'Updated Test Title'
self.course.save()
self.user.groups.add(Group.objects.get(name=INTERNAL_USER_GROUP_NAME)) self.user.groups.add(Group.objects.get(name=INTERNAL_USER_GROUP_NAME))
toggle_switch('publisher_history_widget_feature', False) toggle_switch('publisher_history_widget_feature', False)
response = self.client.get(self.detail_page_url) response = self.client.get(self.detail_page_url)
...@@ -1823,6 +1821,33 @@ class CourseDetailViewTests(TestCase): ...@@ -1823,6 +1821,33 @@ class CourseDetailViewTests(TestCase):
self.assertContains(response, '<strong>MARKETING</strong>') self.assertContains(response, '<strong>MARKETING</strong>')
self.assertNotContains(response, '<strong>PUBLISHER</strong>') self.assertNotContains(response, '<strong>PUBLISHER</strong>')
def test_detail_page_with_history_widget(self):
"""
Test that user can see history widget on detail page if history exists.
"""
self.user.groups.add(self.organization_extension.group)
assign_perm(OrganizationExtension.VIEW_COURSE, self.organization_extension.group, self.organization_extension)
response = self.client.get(self.detail_page_url)
# Verify that user cannot see history widget if there is only one history object.
self.assertEqual(self.course.history.count(), 1)
self.assertNotContains(response, 'REVISION HISTORY')
# Update course to create multiple history objects.
self.course.title = 'Updated Test Title'
self.course.save()
response = self.client.get(self.detail_page_url)
self.assertContains(response, 'REVISION HISTORY')
revision_url = reverse(
'publisher:publisher_course_revision', args=[self.course.id, self.course.history.first().history_id]
)
self.assertContains(
response, '<option value="{revision_url}">Latest version</option>'.format(revision_url=revision_url)
)
class CourseEditViewTests(TestCase): class CourseEditViewTests(TestCase):
""" Tests for the course edit view. """ """ Tests for the course edit view. """
......
...@@ -630,3 +630,7 @@ ...@@ -630,3 +630,7 @@
padding-bottom: 20px; padding-bottom: 20px;
font-size: 14px; font-size: 14px;
} }
#id_select_revisions {
max-width: 50%;
}
{% load i18n %} {% load i18n %}
<div class="margin-top20"> <div class="margin-top20">
<h5 class="hd-5 emphasized course-runs-heading">{% trans "REVISION HISTORY" %}</h5> <h5 class="hd-5 emphasized course-runs-heading">{% trans "REVISION HISTORY" %}</h5>
<br> <br>
{% with object.history.all as history_list %}
<select id="id_select_revisions"> <select id="id_select_revisions">
{% for history in history_list %} {% for history in history_list %}
{% if forloop.first %} {% if forloop.first %}
...@@ -17,6 +16,4 @@ ...@@ -17,6 +16,4 @@
{% endfor %} {% endfor %}
</select> </select>
<a id="id_open_revision" class="btn btn-brand btn-small btn-courserun-add" href="{% url 'publisher:publisher_course_revision' course.id history_list.first.history_id %}" target="_blank">{% trans "Open Selected Version" %}</a> <a id="id_open_revision" class="btn btn-brand btn-small btn-courserun-add" href="{% url 'publisher:publisher_course_revision' course.id history_list.first.history_id %}" target="_blank">{% trans "Open Selected Version" %}</a>
{% endwith %}
</div> </div>
...@@ -40,9 +40,14 @@ ...@@ -40,9 +40,14 @@
</div> </div>
{% endfor %} {% endfor %}
</div> </div>
<div class="history-widget {% if not publisher_history_widget_feature %}hidden{% endif %}">
{% include 'publisher/_history_widget.html' %} {% with object.history.all as history_list %}
</div> {% if history_list.count > 1 %}
<div class="history-widget {% if not publisher_history_widget_feature %}hidden{% endif %}">
{% include 'publisher/_history_widget.html' %}
</div>
{% endif %}
{% endwith %}
<div class="approval-widget {% if not publisher_approval_widget_feature %}hidden{% endif %}"> <div class="approval-widget {% if not publisher_approval_widget_feature %}hidden{% endif %}">
{% include 'publisher/_approval_widget.html' %} {% include 'publisher/_approval_widget.html' %}
</div> </div>
......
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