Commit 7ecebff2 by tasawernawaz Committed by Bill DeRusha

feature switches added for history and workflow widgets ECOM-7143

parent 0ab5d420
# -*- coding: utf-8 -*-
# Generated by Django 1.9.12 on 2017-02-13 09:14
from __future__ import unicode_literals
from django.db import migrations
def create_switch(apps, schema_editor):
"""Create the publisher_history_widget_feature switch if it does not already exist."""
Switch = apps.get_model('waffle', 'Switch')
Switch.objects.get_or_create(name='publisher_history_widget_feature', defaults={'active': False})
def delete_switch(apps, schema_editor):
"""Delete the publisher_history_widget_feature switch."""
Switch = apps.get_model('waffle', 'Switch')
Switch.objects.filter(name='publisher_history_widget_feature').delete()
class Migration(migrations.Migration):
dependencies = [
('publisher', '0032_create_switch_for_comments'),
('waffle', '0001_initial'),
]
operations = [
migrations.RunPython(create_switch, delete_switch),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.9.12 on 2017-02-13 09:18
from __future__ import unicode_literals
from django.db import migrations
def create_switch(apps, schema_editor):
"""Create the publisher_approval_widget_feature switch if it does not already exist."""
Switch = apps.get_model('waffle', 'Switch')
Switch.objects.get_or_create(name='publisher_approval_widget_feature', defaults={'active': False})
def delete_switch(apps, schema_editor):
"""Delete the publisher_approval_widget_feature switch."""
Switch = apps.get_model('waffle', 'Switch')
Switch.objects.filter(name='publisher_approval_widget_feature').delete()
class Migration(migrations.Migration):
dependencies = [
('publisher', '0033_auto_20170213_0914'),
('waffle', '0001_initial'),
]
operations = [
migrations.RunPython(create_switch, delete_switch),
]
...@@ -984,7 +984,6 @@ class CourseRunDetailTests(TestCase): ...@@ -984,7 +984,6 @@ class CourseRunDetailTests(TestCase):
toggle_switch('publisher_hide_features_for_pilot', True) toggle_switch('publisher_hide_features_for_pilot', True)
response = self.client.get(self.page_url) response = self.client.get(self.page_url)
self.assertContains(response, '<div id="approval-widget" class="hidden">')
self.assertContains(response, '<div class="non-studio-fields hidden">') self.assertContains(response, '<div class="non-studio-fields hidden">')
def test_page_disable_waffle_switch_pilot(self): def test_page_disable_waffle_switch_pilot(self):
...@@ -992,7 +991,6 @@ class CourseRunDetailTests(TestCase): ...@@ -992,7 +991,6 @@ class CourseRunDetailTests(TestCase):
toggle_switch('publisher_hide_features_for_pilot', False) toggle_switch('publisher_hide_features_for_pilot', False)
response = self.client.get(self.page_url) response = self.client.get(self.page_url)
self.assertContains(response, '<div id="approval-widget" class="">')
self.assertContains(response, '<div class="non-studio-fields ">') self.assertContains(response, '<div class="non-studio-fields ">')
def test_comments_with_enable_switch(self): def test_comments_with_enable_switch(self):
...@@ -1012,6 +1010,24 @@ class CourseRunDetailTests(TestCase): ...@@ -1012,6 +1010,24 @@ class CourseRunDetailTests(TestCase):
response = self.client.get(self.page_url) response = self.client.get(self.page_url)
self.assertContains(response, '<div id="comments-widget" class="comment-container hidden">') self.assertContains(response, '<div id="comments-widget" class="comment-container hidden">')
def test_approval_widget_with_enable_switch(self):
""" Verify that user will see the history widget when
'publisher_approval_widget_feature' is enabled.
"""
self.user.groups.add(Group.objects.get(name=INTERNAL_USER_GROUP_NAME))
toggle_switch('publisher_approval_widget_feature', True)
response = self.client.get(self.page_url)
self.assertContains(response, '<div id="approval-widget" class="approval-widget ">')
def test_approval_widget_with_disable_switch(self):
""" Verify that user will not see the history widget when
'publisher_approval_widget_feature' is disabled.
"""
self.user.groups.add(Group.objects.get(name=INTERNAL_USER_GROUP_NAME))
toggle_switch('publisher_approval_widget_feature', False)
response = self.client.get(self.page_url)
self.assertContains(response, '<div id="approval-widget" class="approval-widget hidden">')
class ChangeStateViewTests(TestCase): class ChangeStateViewTests(TestCase):
""" Tests for the `ChangeStateView`. """ """ Tests for the `ChangeStateView`. """
...@@ -1587,6 +1603,42 @@ class CourseDetailViewTests(TestCase): ...@@ -1587,6 +1603,42 @@ class CourseDetailViewTests(TestCase):
response = self.client.get(self.detail_page_url) response = self.client.get(self.detail_page_url)
self.assertContains(response, '<div id="comments-widget" class="comment-container hidden">') self.assertContains(response, '<div id="comments-widget" class="comment-container hidden">')
def test_history_with_enable_switch(self):
""" Verify that user will see the history widget when
'publisher_history_widget_feature' is enabled.
"""
self.user.groups.add(Group.objects.get(name=INTERNAL_USER_GROUP_NAME))
toggle_switch('publisher_history_widget_feature', True)
response = self.client.get(self.detail_page_url)
self.assertContains(response, '<div class="history-widget ">')
def test_history_with_disable_switch(self):
""" Verify that user will not see the history widget when
'publisher_history_widget_feature' is disabled.
"""
self.user.groups.add(Group.objects.get(name=INTERNAL_USER_GROUP_NAME))
toggle_switch('publisher_history_widget_feature', False)
response = self.client.get(self.detail_page_url)
self.assertContains(response, '<div class="history-widget hidden">')
def test_approval_widget_with_enable_switch(self):
""" Verify that user will see the history widget when
'publisher_approval_widget_feature' is enabled.
"""
self.user.groups.add(Group.objects.get(name=INTERNAL_USER_GROUP_NAME))
toggle_switch('publisher_approval_widget_feature', True)
response = self.client.get(self.detail_page_url)
self.assertContains(response, '<div class="approval-widget ">')
def test_approval_widget_with_disable_switch(self):
""" Verify that user will not see the history widget when
'publisher_approval_widget_feature' is disabled.
"""
self.user.groups.add(Group.objects.get(name=INTERNAL_USER_GROUP_NAME))
toggle_switch('publisher_approval_widget_feature', False)
response = self.client.get(self.detail_page_url)
self.assertContains(response, '<div class="approval-widget hidden">')
def test_course_approval_widget(self): def test_course_approval_widget(self):
""" """
Verify that user can see approval widget on course detail page. Verify that user can see approval widget on course detail page.
......
...@@ -170,6 +170,7 @@ class CourseRunDetailView(mixins.LoginRequiredMixin, mixins.PublisherPermissionM ...@@ -170,6 +170,7 @@ class CourseRunDetailView(mixins.LoginRequiredMixin, mixins.PublisherPermissionM
context['can_view_all_tabs'] = mixins.check_roles_access(self.request.user) context['can_view_all_tabs'] = mixins.check_roles_access(self.request.user)
context['publisher_hide_features_for_pilot'] = waffle.switch_is_active('publisher_hide_features_for_pilot') context['publisher_hide_features_for_pilot'] = waffle.switch_is_active('publisher_hide_features_for_pilot')
context['publisher_comment_widget_feature'] = waffle.switch_is_active('publisher_comment_widget_feature') context['publisher_comment_widget_feature'] = waffle.switch_is_active('publisher_comment_widget_feature')
context['publisher_approval_widget_feature'] = waffle.switch_is_active('publisher_approval_widget_feature')
return context return context
...@@ -379,7 +380,8 @@ class CourseDetailView(mixins.LoginRequiredMixin, mixins.PublisherPermissionMixi ...@@ -379,7 +380,8 @@ class CourseDetailView(mixins.LoginRequiredMixin, mixins.PublisherPermissionMixi
context['post_back_url'] = reverse('publisher:publisher_course_detail', kwargs={'pk': self.object.id}) context['post_back_url'] = reverse('publisher:publisher_course_detail', kwargs={'pk': self.object.id})
context['publisher_hide_features_for_pilot'] = waffle.switch_is_active('publisher_hide_features_for_pilot') context['publisher_hide_features_for_pilot'] = waffle.switch_is_active('publisher_hide_features_for_pilot')
context['publisher_comment_widget_feature'] = waffle.switch_is_active('publisher_comment_widget_feature') context['publisher_comment_widget_feature'] = waffle.switch_is_active('publisher_comment_widget_feature')
context['publisher_history_widget_feature'] = waffle.switch_is_active('publisher_history_widget_feature')
context['publisher_approval_widget_feature'] = waffle.switch_is_active('publisher_approval_widget_feature')
context['role_widgets'] = self.get_role_widgets_data() context['role_widgets'] = self.get_role_widgets_data()
return context return context
......
...@@ -39,7 +39,10 @@ ...@@ -39,7 +39,10 @@
</div> </div>
{% endfor %} {% endfor %}
</div> </div>
<div class="history-widget {% if not publisher_history_widget_feature %}hidden{% endif %}">
{% include 'publisher/_history_widget.html' %} {% include 'publisher/_history_widget.html' %}
</div>
<div class="approval-widget {% if not publisher_approval_widget_feature %}hidden{% endif %}">
{% include 'publisher/course_detail/_approval_widget.html' %} {% include 'publisher/course_detail/_approval_widget.html' %}
</div>
</div> </div>
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
</main> </main>
<aside id="right-panel" class="layout-col layout-col-a layout-col-a-custom"> <aside id="right-panel" class="layout-col layout-col-a layout-col-a-custom">
<div id="approval-widget" class="{% if publisher_hide_features_for_pilot %}hidden{% endif %}"> <div id="approval-widget" class="approval-widget {% if not publisher_approval_widget_feature %}hidden{% endif %}">
{% include 'publisher/course_run_detail/_approval_widget.html' %} {% include 'publisher/course_run_detail/_approval_widget.html' %}
</div> </div>
<div id="comments-widget" class="comment-container {% if not publisher_comment_widget_feature %}hidden{% endif %}"> <div id="comments-widget" class="comment-container {% if not publisher_comment_widget_feature %}hidden{% endif %}">
......
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