-
-
Notifications
You must be signed in to change notification settings - Fork 75
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
[admin] Make organization selection automatic when only 1 org #170
Comments
Update: this could do the trick: https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.formfield_for_choice_field if len(request.user.organizations_managed) <= 1:
kwargs['initial'] = request.user.organizations_maanged[0] I have not tested this. |
I think that way would require code in all ModelAdmin where the model uses organization field. I'm testing with the field, something like adding a default value to the field https://github.com/openwisp/openwisp-users/blob/master/openwisp_users/mixins.py#L84 Let me think about your suggestion, I didn't knew about organizations_managed but its a good point. |
Not exactly. All the modules which support multitenancy inherit this mixin: So it should be enough to implement it once for every multi-tenant admin. |
Great, I will try it. |
Well done. |
Implemented in #333. |
When the user logged in has access to only one organization, the organization select should automatically set that org as the default value, the user should not need to select it.
The text was updated successfully, but these errors were encountered: