add support for natural keys to group collection permissions for use in fixtures (#6211)

pull/6471/head
Jim Jazwiecki 2020-07-07 12:40:12 -04:00 zatwierdzone przez Matt Westcott
rodzic 05223db8c3
commit 024717fe0f
3 zmienionych plików z 14 dodań i 0 usunięć

Wyświetl plik

@ -28,6 +28,7 @@ Changelog
* Add `register_snippet_action_menu_item` and `construct_snippet_action_menu` hooks to modify the actions available when creating / editing a snippet (Karl Hobley)
* Moved `generate_signature` and `verify_signature` functions into `wagtail.images.utils` (Noah H)
* Implement `bulk_to_python` on all structural StreamField block types (Matt Westcott)
* Add natural key support to `GroupCollectionPermission` (Jim Jazwiecki)
* Fix: Make page-level actions accessible to keyboard users in page listing tables (Jesse Menn)
* Fix: `WAGTAILFRONTENDCACHE_LANGUAGES` was being interpreted incorrectly. It now accepts a list of strings, as documented (Karl Hobley)
* Fix: Update oEmbed endpoints to use https where available (Matt Westcott)

Wyświetl plik

@ -53,6 +53,7 @@ Other features
* Add ``register_snippet_action_menu_item`` and ``construct_snippet_action_menu`` hooks to modify the actions available when creating / editing a snippet (Karl Hobley)
* Moved ``generate_signature`` and ``verify_signature`` functions into ``wagtail.images.utils`` (Noah H)
* Implement ``bulk_to_python`` on all structural StreamField block types (Matt Westcott)
* Add natural key support to ``GroupCollectionPermission`` (Jim Jazwiecki)
Bug fixes

Wyświetl plik

@ -3603,6 +3603,13 @@ class CollectionMember(models.Model):
abstract = True
class GroupCollectionPermissionManager(models.Manager):
def get_by_natural_key(self, group, collection, permission):
return self.get(group=group,
collection=collection,
permission=permission)
class GroupCollectionPermission(models.Model):
"""
A rule indicating that a group has permission for some action (e.g. "create document")
@ -3633,6 +3640,11 @@ class GroupCollectionPermission(models.Model):
self.collection.id, self.collection
)
def natural_key(self):
return (self.group, self.collection, self.permission)
objects = GroupCollectionPermissionManager()
class Meta:
unique_together = ('group', 'collection', 'permission')
verbose_name = _('group collection permission')