-
-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feature] Added multitenant capablities to django-filters #346 #347
[feature] Added multitenant capablities to django-filters #346 #347
Conversation
b1a2441
to
cbe401a
Compare
e5f3fdb
to
55d0afb
Compare
55d0afb
to
097c839
Compare
8aa1c43
to
d965671
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great progress @Aryamanz29! 👏
I did some testing and it's working well.
There's some room for improvement, since this is going to become a feature we will use in all our modules.
I believe we should add something like this to this library to avoid repeating the same over and over in all modules:
class BaseOrganizationFilter(FilterDjangoByOrgManaged):
organization_slug = filters.CharFilter(field_name='organization__slug')
class Meta:
fields = ['organization', 'organization_slug']
Usage example in Network Topology module:
class OrganizationFilter(BaseOrganizationFilter):
class Meta(BaseOrganizationFilter.Meta):
model = Node
See also my comments below.
Added the django filter class that can be used across various OpenWISP API views to filter options based on the organization managed by the user
989b0be
to
a0542ae
Compare
We should construct the opts dictionary after checking if the field is an instance of ForeignKey or ManyToManyField.
fd1d3ea
to
e173d71
Compare
Todo
Closes #346