8000 Removed unpublish button from toolbar (#6438) · django-cms/django-cms@14110d0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 14110d0

Browse files
Aiky30czpython
authored andcommitted
Removed unpublish button from toolbar (#6438)
1 parent 37082d0 commit 14110d0

File tree

1 file changed

+1
-67
lines changed

1 file changed

+1
-67
lines changed

cms/cms_toolbars.py

Lines changed: 1 addition & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from django.utils.translation import override as force_language, ugettext_lazy as _
1010

1111
from cms.api import get_page_draft, can_change_page
12-
from cms.constants import TEMPLATE_INHERITANCE_MAGIC, PUBLISHER_STATE_PENDING
12+
from cms.constants import TEMPLATE_INHERITANCE_MAGIC
1313
from cms.models import Placeholder, Title, Page, PageType, StaticPlaceholder
1414
from cms.toolbar.items import TemplateItem, REFRESH_PAGE
1515
from cms.toolbar_base import CMSToolbar
@@ -20,7 +20,6 @@
2020
from cms.utils.page_permissions import (
2121
user_can_change_page,
2222
user_can_delete_page,
23-
user_can_publish_page,
2423
)
2524
from cms.utils.urlutils import add_url_parameters, admin_reverse
2625

@@ -236,7 +235,6 @@ def init_placeholders(self):
236235
self.statics = StaticPlaceholder.objects.filter(
237236
Q(draft__in=placeholder_ids) | Q(public__in=placeholder_ids)
238237
)
239-
self.dirty_statics = [sp for sp in self.statics if sp.dirty]
240238
else:
241239
if toolbar.structure_mode_active and not toolbar.uses_legacy_structure_mode:
242240
# User has explicitly requested structure mode
@@ -247,7 +245,6 @@ def init_placeholders(self):
247245

248246
self.placeholders = renderer.get_rendered_placeholders()
249247
self.statics = renderer.get_rendered_static_placeholders()
250-
self.dirty_statics = [sp for sp in self.statics if sp.dirty]
251248

252249
def add_structure_mode(self):
253250
if self.page and not self.page.application_urls:
@@ -281,32 +278,11 @@ def get_title(self):
281278
except Title.DoesNotExist:
282279
return None
283280

284-
def has_publish_permission(self):
285-
if self.page:
286-
publish_permission = page_permissions.user_can_publish_page(
287-
self.request.user,
288-
page=self.page,
289-
site=self.current_site
290-
)
291-
else:
292-
publish_permission = False
293-
294-
if publish_permission and self.statics:
295-
publish_permission = all(sp.has_publish_permission(self.request) for sp in self.dirty_statics)
296-
return publish_permission
297-
298-
def has_unpublish_permission(self):
299-
return self.has_publish_permission()
300-
301281
def has_page_change_permission(self):
302282
if not hasattr(self, 'page_change_permission'):
303283
self.page_change_permission = can_change_page(self.request)
304284
return self.page_change_permission
305285

306-
def page_is_pending(self, page, language):
307-
return (page.publisher_public_id and
308-
page.publisher_public.get_publisher_state(language) == PUBLISHER_STATE_PENDING)
309-
310286
def in_apphook(self):
311287
with force_language(self.toolbar.request_language):
312288
try:
@@ -357,32 +333,7 @@ def post_template_populate(self):
357333
self.add_draft_live()
358334
self.add_structure_mode()
359335

360-
def has_dirty_objects(self):
361-
language = self.current_lang
362-
363-
if self.page:
364-
if self.dirty_statics:
365-
# There's dirty static placeholders on this page.
366-
# Only show the page as dirty (publish button) if the page
367-
# translation has been configured.
368-
dirty = self.page.has_translation(language)
369-
else:
370-
dirty = (self.page.is_dirty(language) or self.page_is_pending(self.page, language))
371-
else:
372-
dirty = bool(self.dirty_statics)
373-
return dirty
374-
375336
# Buttons
376-
377-
def user_can_publish(self):
378-
if self.page and self.page.is_page_type:
379-
# By design, page-types are not publishable.
380-
return False
381-
382-
if not self.toolbar.edit_mode_active:
383-
return False
384-
return self.has_publish_permission() and self.has_dirty_objects()
385-
386337
def add_draft_live(self):
387338
if self.page:
388339
if self.toolbar.edit_mode_active and not self.title:
@@ -655,23 +606,6 @@ def add_page_menu(self):
655606
on_success=refresh,
656607
)
657608

658-
# publisher
659-
if self.title and not self.page.is_page_type:
660-
if self.title.published:
661-
publish_title = _('Unpublish page')
662-
publish_url = admin_reverse('cms_page_unpublish', args=(self.page.pk, self.current_lang))
663-
else:
664-
publish_title = _('Publish page')
665-
publish_url = admin_reverse('cms_page_publish_page', args=(self.page.pk, self.current_lang))
666-
667-
user_can_publish = user_can_publish_page(self.request.user, page=self.page)
668-
current_page_menu.add_ajax_item(
669-
publish_title,
670-
action=publish_url,
671-
disabled=not edit_mode or not user_can_publish,
672-
on_success=refresh,
673-
)
674-
675609
if self.current_lang and not self.page.is_page_type:
676610
# revert to live
677611
current_page_menu.add_break(PAGE_MENU_FOURTH_BREAK)

0 commit comments

Comments
 (0)
0