-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add ObjectTag view permission and filter
- Loading branch information
Showing
4 changed files
with
50 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
""" | ||
API Filters for content | ||
""" | ||
|
||
from rest_framework.filters import BaseFilterBackend | ||
|
||
from ... import rules as oel_tagging | ||
|
||
|
||
class ObjectTagTaxonomyFilterBackend(BaseFilterBackend): | ||
""" | ||
Filter for ObjectTagViewSet to only show taxonomies that the user can view. | ||
""" | ||
|
||
def filter_queryset(self, request, queryset, _): | ||
if oel_tagging.is_taxonomy_admin(request.user): | ||
return queryset | ||
|
||
return queryset.filter(taxonomy__enabled=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters