Disable some actions in Page Explorer

67 views
Skip to first unread message

Rafael Pinto

unread,
Jul 4, 2018, 10:23:19 AM7/4/18
to Wagtail support
Hi there!
Is possible to hide or disable some actions in Page Explorer for certain Page type?
For example, when the page type is "Página Externa" I want not show Move, Copy and Revisions actions.





Sævar Öfjörð Magnússon

unread,
Jul 4, 2018, 6:42:51 PM7/4/18
to Wagtail support
Hi!

If you are ok with just setting permission per page object then you can do that via the wagtail permissions under the group settings in the admin: http://docs.wagtail.io/en/v2.1/topics/permissions.html

The only way I've found to do this per page type, is to monkey patch the PagePermissionTester class. 
That way you would be overriding each action that you would want to control. 
However, I can not recommend doing this unless you really have to, it's messy and error prone.

Having said that, here is a simple example removing the "Move" option from all ContentPage pages:

from wagtail.wagtailcore.models import UserPagePermissionsProxy, PagePermissionTester

def can_move(self):
   
# my model is called ContentPage, so I look for the name "content page"
   if self.page.content_type.name == "content page":
       return False
   return self.original_can_move()

PagePermissionTester.original_can_move = PagePermissionTester.can_move
PagePermissionTester.can_move = can_move



- Sævar

Rafael Pinto

unread,
Jul 5, 2018, 9:13:03 AM7/5/18
to wag...@googlegroups.com
OK! That's works for me! Tks

--
You received this message because you are subscribed to the Google Groups "Wagtail support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wagtail+u...@googlegroups.com.
To post to this group, send email to wag...@googlegroups.com.
Visit this group at https://groups.google.com/group/wagtail.
To view this discussion on the web, visit https://groups.google.com/d/msgid/wagtail/c603cd08-e1c4-41cb-9a47-e3de457e6de7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Rafael Pinto
Reply all
Reply to author
Forward
0 new messages