kopia lustrzana https://github.com/wagtail/wagtail
Allow groups to manage sections of the collection hierarchy
rodzic
5a7ae4280d
commit
2c1e37eb03
|
@ -308,3 +308,14 @@ def collection_member_permission_formset_factory(
|
|||
extra=0,
|
||||
can_delete=True
|
||||
)
|
||||
|
||||
|
||||
GroupCollectionManagementPermissionFormSet = collection_member_permission_formset_factory(
|
||||
Collection,
|
||||
[
|
||||
('add_collection', _("Add"), _("Add collections")),
|
||||
('change_collection', _("Edit"), _("Edit collections")),
|
||||
('delete_collection', _("Delete"), _("Delete collections")),
|
||||
],
|
||||
'wagtailadmin/permissions/includes/collection_management_permissions_form.html'
|
||||
)
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
{% extends "wagtailadmin/permissions/includes/collection_member_permissions_formset.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block title %}{% trans "Collection management permissions" %}{% endblock %}
|
||||
{% block add_button_label %}{% trans "Add a collection permission" %}{% endblock %}
|
|
@ -11,6 +11,8 @@ import wagtail.admin.rich_text.editors.draftail.features as draftail_features
|
|||
from wagtail import __version__
|
||||
from wagtail.admin.admin_url_finder import ModelAdminURLFinder, register_admin_url_finder
|
||||
from wagtail.admin.auth import user_has_any_page_permission
|
||||
from wagtail.admin.forms.collections import GroupCollectionManagementPermissionFormSet
|
||||
from wagtail.admin.localization import get_available_admin_languages, get_available_admin_time_zones
|
||||
from wagtail.admin.menu import MenuItem, SubmenuMenuItem, reports_menu, settings_menu
|
||||
from wagtail.admin.navigation import get_explorable_root_page
|
||||
from wagtail.admin.rich_text import (
|
||||
|
@ -112,6 +114,11 @@ def register_pages_search_area():
|
|||
return PageSearchArea()
|
||||
|
||||
|
||||
@hooks.register('register_group_permission_panel')
|
||||
def register_collection_permissions_panel():
|
||||
return GroupCollectionManagementPermissionFormSet
|
||||
|
||||
|
||||
class CollectionsMenuItem(MenuItem):
|
||||
def is_shown(self, request):
|
||||
return collection_permission_policy.user_has_any_permission(
|
||||
|
|
|
@ -1128,6 +1128,9 @@ class TestGroupCreateView(TestCase, WagtailTestUtils):
|
|||
'page_permissions-TOTAL_FORMS': ['0'],
|
||||
'page_permissions-MAX_NUM_FORMS': ['1000'],
|
||||
'page_permissions-INITIAL_FORMS': ['0'],
|
||||
'collection_permissions-TOTAL_FORMS': ['0'],
|
||||
'collection_permissions-MAX_NUM_FORMS': ['1000'],
|
||||
'collection_permissions-INITIAL_FORMS': ['0'],
|
||||
'document_permissions-TOTAL_FORMS': ['0'],
|
||||
'document_permissions-MAX_NUM_FORMS': ['1000'],
|
||||
'document_permissions-INITIAL_FORMS': ['0'],
|
||||
|
@ -1308,6 +1311,9 @@ class TestGroupEditView(TestCase, WagtailTestUtils):
|
|||
'image_permissions-TOTAL_FORMS': ['0'],
|
||||
'image_permissions-MAX_NUM_FORMS': ['1000'],
|
||||
'image_permissions-INITIAL_FORMS': ['0'],
|
||||
'collection_permissions-TOTAL_FORMS': ['0'],
|
||||
'collection_permissions-MAX_NUM_FORMS': ['1000'],
|
||||
'collection_permissions-INITIAL_FORMS': ['0'],
|
||||
}
|
||||
for k, v in post_defaults.items():
|
||||
post_data[k] = post_data.get(k, v)
|
||||
|
@ -1468,8 +1474,8 @@ class TestGroupEditView(TestCase, WagtailTestUtils):
|
|||
|
||||
# "Eviler Plans" should be prefixed with ↳ (↳) and exactly 4 non-breaking spaces
|
||||
# after the <option> tag.
|
||||
# There are 3 instances because it appears twice in the form template javascript.
|
||||
self.assertContains(response, '> ↳ Eviler Plans', count=3)
|
||||
# There are 4 instances because we have one document permission + 3 in the form template javascript.
|
||||
self.assertContains(response, '> ↳ Eviler Plans', count=4)
|
||||
|
||||
def test_group_edit_loads_with_page_permissions_shown(self):
|
||||
# The test group has one page permission to begin with
|
||||
|
|
Ładowanie…
Reference in New Issue