openwisp/openwisp-users

[feature] Create a reusable organization filter using select2 and autocomplete

Closed this issue · 3 comments

The list of organization accessible to a superadmin user can be potentially very large, this can slow down page loading in all list pages which have a filter by organization.

For this reason we should look for a solution which loads the options asynchronously.

It looks like this is what we need: https://pypi.org/project/django-admin-autocomplete-filter/.

We already have an organization filter which complies with our multi-tenancy requirements in openwisp_users.multitenancy.MultitenantOrgFilter, it would be really great if we manage to just update this filter to ship this new feature, that way we won't have to touch other modules at all because those are already using this class.

@nemesisdesign May i start working on this?

@nemesisdesign May i start working on this?

I am not sure whether this is the right issue to start practicing on, I suggest starting with something different, easier. Come to https://gitter.im/openwisp/development so we can coordinate.

The new autocomplete filter feature added in openwisp/openwisp-utils#303 can work for this task too!

The current filter doesn't show up if there's only one organization, that seems good, so we should maintain this behavior if possible, we should check whether the user has access to at least 2 orgs and show the filter only in that case.

We have to create a reusable base class because not all models have an organization field, they may get the org from a related model, so a base class will allow other modules to create the right filter for them.
We can have a concrete organization filter class for all those models who do have the organization field, so that the different openwisp modules can import it from here instead of redefining it each time.