9
9
from django .utils .translation import override as force_language , ugettext_lazy as _
10
10
11
11
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
13
13
from cms .models import Placeholder , Title , Page , PageType , StaticPlaceholder
14
14
from cms .toolbar .items import TemplateItem , REFRESH_PAGE
15
15
from cms .toolbar_base import CMSToolbar
20
20
from cms .utils .page_permissions import (
21
21
user_can_change_page ,
22
22
user_can_delete_page ,
23
- user_can_publish_page ,
24
23
)
25
24
from cms .utils .urlutils import add_url_parameters , admin_reverse
26
25
@@ -236,7 +235,6 @@ def init_placeholders(self):
236
235
self .statics = StaticPlaceholder .objects .filter (
237
236
Q (draft__in = placeholder_ids ) | Q (public__in = placeholder_ids )
238
237
)
239
- self .dirty_statics = [sp for sp in self .statics if sp .dirty ]
240
238
else :
241
239
if toolbar .structure_mode_active and not toolbar .uses_legacy_structure_mode :
242
240
# User has explicitly requested structure mode
@@ -247,7 +245,6 @@ def init_placeholders(self):
247
245
248
246
self .placeholders = renderer .get_rendered_placeholders ()
249
247
self .statics = renderer .get_rendered_static_placeholders ()
250
- self .dirty_statics = [sp for sp in self .statics if sp .dirty ]
251
248
252
249
def add_structure_mode (self ):
253
250
if self .page and not self .page .application_urls :
@@ -281,32 +278,11 @@ def get_title(self):
281
278
except Title .DoesNotExist :
282
279
return None
283
280
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
-
301
281
def has_page_change_permission (self ):
302
282
if not hasattr (self , 'page_change_permission' ):
303
283
self .page_change_permission = can_change_page (self .request )
304
284
return self .page_change_permission
305
285
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
-
310
286
def in_apphook (self ):
311
287
with force_language (self .toolbar .request_language ):
312
288
try :
@@ -357,32 +333,7 @@ def post_template_populate(self):
357
333
self .add_draft_live ()
358
334
self .add_structure_mode ()
359
335
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
-
375
336
# 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
-
386
337
def add_draft_live (self ):
387
338
if self .page :
388
339
if self .toolbar .edit_mode_active and not self .title :
@@ -655,23 +606,6 @@ def add_page_menu(self):
655
606
on_success = refresh ,
656
607
)
657
608
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
-
675
609
if self .current_lang and not self .page .is_page_type :
676
610
# revert to live
677
611
current_page_menu .add_break (PAGE_MENU_FOURTH_BREAK )
0 commit comments