Skip to content

Set DRF permission_classes and filter_backends globally#309

Merged
brianhelba merged 2 commits intomasterfrom
drf-override
Mar 5, 2026
Merged

Set DRF permission_classes and filter_backends globally#309
brianhelba merged 2 commits intomasterfrom
drf-override

Conversation

@brianhelba
Copy link
Collaborator

@brianhelba brianhelba commented Feb 28, 2026

Move the de facto GuardianPermission and GuardianFilter defaults up to actual DRF defaults. This eliminates boilerplate and ensures that new ViewSets will automatically inherit the correct access control.

Note, DatasetViewSet and UserViewSet have exceptional overrides, to preserve their existing behavior.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Feb 28, 2026

Deploying geodatalytics with  Cloudflare Pages  Cloudflare Pages

Latest commit: c9b105c
Status: ✅  Deploy successful!
Preview URL: https://853b70bf.geodatalytics.pages.dev
Branch Preview URL: https://drf-override.geodatalytics.pages.dev

View logs

Base automatically changed from remove-redundant-lookup-field to master March 3, 2026 00:01
@brianhelba brianhelba marked this pull request as ready for review March 3, 2026 18:05
@brianhelba brianhelba requested a review from annehaley March 3, 2026 18:05
@brianhelba
Copy link
Collaborator Author

@annehaley Ready for review.

@brianhelba brianhelba mentioned this pull request Mar 3, 2026
Move the de facto `GuardianPermission` and `GuardianFilter` defaults up to
actual DRF defaults. This eliminates boilerplate and ensures that new
`ViewSets` will automatically inherit the correct access control.

Note, `DatasetViewSet` and `UserViewSet` have exceptional overrides,
to preserve their existing behavior.
@annehaley
Copy link
Collaborator

Strangely it looks like the test failures won't render properly for me on GH. I was able to run the tests locally (there was a lot of printout, so maybe it was too long for GH to handle). It appears to be an import error:

ImportError: Could not import 'uvdat.core.rest.access_control.GuardianPermission' for API setting 'DEFAULT_PERMISSION_CLASSES'. ImportError: cannot import name 'APIView' from partially initialized module 'rest_framework.views' (most likely due to a circular import) (/opt/django-project/.tox/test/lib/python3.12/site-packages/rest_framework/views.py).

@brianhelba
Copy link
Collaborator Author

I added one more commit to move access_control out of rest/. In addition to fixing the circular import error, I think this is a conceptual improvement, since rest/ holds the particular DRF views, whereas access_control is for permission utilities that are used to configure the views.

@brianhelba brianhelba merged commit 5f157bb into master Mar 5, 2026
4 checks passed
@brianhelba brianhelba deleted the drf-override branch March 5, 2026 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants