Repository: django-cms/django-cms

Issue:
Implements a different live/draft switcher for placeholders outside of the CMS.
Placeholders outside of the CMS currently cause the live/draft switcher to be displayed, which toggles the editing mode. However, for non-CMS models, draft versions are not implemented. This can be confusing to users.

This PR adds another switcher template that uses the language "Editing Off" in place of "Draft" and "Editing Live" in place of "Live." The PageToolbar.add_draft_live() method has been modified to take the parameter "is_page" which determines the template used.

Tests have not been implemented as there are currently no tests for cms_toolbar.py.

Some thoughts: Should there be a separate method for adding the new toggle, as opposed to piggybacking off of add_draft_live? Should there be one template for the switcher that we hand text to? Can anyone offer guidance on implementing tests?



Discussion:
tests can be found in cms/tests/toolbar.py

for use with apphooks maybe have a look at cms/tests/apphooks.py as well

Shouldn't the language be reversed? Draft->Live edit and Live->Edit off


Resolving patch:
diff --git a/cms/cms_toolbar.py b/cms/cms_toolbar.py
--- a/cms/cms_toolbar.py
+++ b/cms/cms_toolbar.py
@@ -274,8 +274,8 @@ def populate(self):
     def post_template_populate(self):
         self.init_placeholders_from_request()
 
-        self.add_publish_button()
         self.add_draft_live()
+        self.add_publish_button()
 
     # Buttons
 


Test patch:
diff --git a/cms/tests/views.py b/cms/tests/views.py
--- a/cms/tests/views.py
+++ b/cms/tests/views.py
@@ -149,13 +149,13 @@ def test_edit_permission(self):
         page = create_page("page", "nav_playground.html", "en", published=True)
         # Anon user
         response = self.client.get("/en/?%s" % get_cms_setting('CMS_TOOLBAR_URL__EDIT_ON'))
-        self.assertNotContains(response, "cms_toolbar-item_switch", 200)
+        self.assertNotContains(response, "cms_toolbar-item_switch_save-edit", 200)
 
         # Superuser
         user = self.get_superuser()
         with self.login_user_context(user):
             response = self.client.get("/en/?%s" % get_cms_setting('CMS_TOOLBAR_URL__EDIT_ON'))
-        self.assertContains(response, "cms_toolbar-item_switch", 4, 200)
+        self.assertContains(response, "cms_toolbar-item_switch_save-edit", 1, 200)
 
         # Admin but with no permission
         user = self.get_staff_user_with_no_permissions()
@@ -163,12 +163,12 @@ def test_edit_permission(self):
 
         with self.login_user_context(user):
             response = self.client.get("/en/?%s" % get_cms_setting('CMS_TOOLBAR_URL__EDIT_ON'))
-        self.assertNotContains(response, "cms_toolbar-item_switch", 200)
+        self.assertNotContains(response, "cms_toolbar-item_switch_save-edit", 200)
 
         PagePermission.objects.create(can_change=True, user=user, page=page)
         with self.login_user_context(user):
             response = self.client.get("/en/?%s" % get_cms_setting('CMS_TOOLBAR_URL__EDIT_ON'))
-        self.assertContains(response, "cms_toolbar-item_switch", 4, 200)
+        self.assertContains(response, "cms_toolbar-item_switch_save-edit", 1, 200)
 
 
 @override_settings(ROOT_URLCONF='cms.test_utils.project.urls')