10000 Remove Publish button from the toolbar by Aiky30 · Pull Request #6414 · django-cms/django-cms · GitHub
[go: up one dir, main page]

Skip to content

Remove Publish button from the toolbar #6414

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 14, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Remove the page publish methods and button from the toolbar
  • Loading branch information
Andrew Aikman authored and vxsx committed Jun 14, 2018
commit bb07025076ee52294dc7be2e6bae1fa066e0b627
44 changes: 1 addition & 43 deletions cms/cms_toolbars.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from cms.api import get_page_draft, can_change_page
from cms.constants import TEMPLATE_INHERITANCE_MAGIC, PUBLISHER_STATE_PENDING
from cms.models import Placeholder, Title, Page, PageType, StaticPlaceholder
from cms.toolbar.items import ButtonList, TemplateItem, REFRESH_PAGE
from cms.toolbar.items import TemplateItem, REFRESH_PAGE
from cms.toolbar_base import CMSToolbar
from cms.toolbar_pool import toolbar_pool
from cms.utils import get_language_from_request, page_permissions
Expand Down Expand Up @@ -355,7 +355,6 @@ def populate(self):
def post_template_populate(self):
self.init_placeholders()
self.add_draft_live()
self.add_publish_button()
self.add_structure_mode()

def has_dirty_objects(self):
Expand All @@ -375,11 +374,6 @@ def has_dirty_objects(self):

# Buttons

def add_publish_button(self, classes=('cms-btn-action', 'cms-btn-publish',)):
if self.user_can_publish():
button = self.get_publish_button(classes=classes)
self.toolbar.add_item(button)

def user_can_publish(self):
if self.page and self.page.is_page_type:
# By design, page-types are not publishable.
Expand All @@ -389,42 +383,6 @@ def user_can_publish(self):
return False
return self.has_publish_permission() and self.has_dirty_objects()

def get_publish_button(self, classes=None):
dirty = self.has_dirty_objects()
classes = list(classes or [])

if dirty and 'cms-btn-publish-active' not in classes:
classes.append('cms-btn-publish-active')

if self.dirty_statics or (self.page and self.page.is_published(self.current_lang)):
title = _('Publish page changes')
else:
title = _('Publish page now')
classes.append('cms-publish-page')

item = ButtonList(side=self.toolbar.RIGHT)
item.add_button(
title,
url=self.get_publish_url(),
disabled=not dirty,
extra_classes=classes,
)
return item

def get_publish_url(self):
pk = self.page.pk if self.page else 0
params = {}

if self.dirty_statics:
params['statics'] = ','.join(str(sp.pk) for sp in self.dirty_statics)

if self.in_apphook():
params['redirect'] = self.toolbar.request_path

with force_language(self.current_lang):
url = admin_reverse('cms_page_publish_page', args=(pk, self.current_lang))
return add_url_parameters(url, params)

def add_draft_live(self):
if self.page:
if self.toolbar.edit_mode_active and not self.title:
Expand Down
0