FixMyBerlin / FixMyBerlin/fixmy.platform
Add per-borough permissions for Django admin
- Dominant language
- Python
- Stars
- 10
- Forks
- 3
- PR merge metrics
- No merged PRs in 30d
Description
**What's the problem you want solved?**
Users with access to the administration site have access rights to data based on the data kind (i.e. project, report). It is not possible to give them access rights based on the region where an object is situatied (e.g. Friedrichshain-Kreuzberg).
**Is there a solution you'd like to recommend?**
Add custom permissions for each borough in Berlin and use them to manage access to data in the Django admin.
**Tasks**
- [ ] Make either the `Bezirk` or `Verantworlich` property a field with fixed values in order to be able to use this for assigning permissions
- [ ] Add a custom permission for each Bezirk / Verantworlicher to the `Project` model. See [1]
- [ ] Overwrite the methods`Project.has_view_permission`, `Project.has_change_permission`, `Project.has_add_permission` and `Project.has_delete_permission` classes to check whether the current user has the relevant permission for the Project class as a whole and for the specific borough of this project. See [2]
- [ ] Add a user group for each permission class
- [ ] Add tests for each combination of permissions
[1]: https://docs.djangoproject.com/en/3.0/topics/auth/customizing/#custom-permissions
[2]: https://docs.djangoproject.com/en/3.0/ref/contrib/admin/#django.contrib.admin.ModelAdmin.has_view_permission
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.