Limit collections in image/document chooser based on permissions
See original GitHub issueSummary
When a user is assigned to a group with permissions to add/edit images and/or documents to a collection named “Collection One”, the chooser still has a select with options for all collections.
Quick and dirty solution:
wagtail/images/views/chooser.py
def chooser(request):
...
collections = None
groups = request.user.groups.all()
if groups:
collection_permissions = GroupCollectionPermission.objects.filter(group__in=groups)
if collection_permissions:
collections = [cp.collection for cp in collection_permissions.all()]
if not collections:
collections = Collection.objects.all()
if len(collections) < 2:
collections = None
...
Technical details
- Python version: 3.6.4.
- Django version: 2.0.4.
- Wagtail version: 2.0.1.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:28 (7 by maintainers)
Top Results From Across the Web
Permissions — Wagtail Documentation 4.1.1 documentation
The 'choose' permission for images and documents determines which collections are visible within the chooser interface used to select images and document links ......
Read more >Change permissions at the organization or collection-level
You can grant these permissions by adding a user or group to the Project Collection Administrators group. Or, you can grant select collection- ......
Read more >Access and edit collection configuration - OCLC Support
Open CONTENTdm Administration and select the collections tab. ... You can set collection-level permissions based on user names or IP ...
Read more >Controlling access to AWS resources using policies
AWS is composed of collections of resources. ... It sets the maximum permissions that an identity-based policy can grant to an IAM entity....
Read more >Collection Permissions: An Overview | Help Center | Wix.com
The collection permissions model contains a number of presets that ... Based on the preset you select, each role is assigned permissions that...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hoo boy, it took me a looong time to circle back to this one. But I’m finally working on this. No clue yet how long it’ll take, but as of today it’s my primary focus.
@coredumperror That plan sounds good to me! I’d just change one detail:
should be: “every existing Group that has the ‘can access Wagtail admin’ (
wagtailadmin.access_admin
) permission”. (Functionally this is no different, since groups with no access to the Wagtail admin obviously won’t be able to access the chooser UI at all - but if there happen to be a large number of non-Wagtail-related groups on the system, we wouldn’t want to create redundant permission records for them all.)I think we’d still need to mention the new permission in the ‘upgrade considerations’ section of the release notes, for the benefit of developers who are creating groups programmatically or through fixtures and will need to update their code accordingly.