Skip to content

Commit

Permalink
[admin] Change empty org label openwisp#171
Browse files Browse the repository at this point in the history
  • Loading branch information
purhan committed Dec 28, 2020
1 parent 4569b60 commit 84e7cd1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions openwisp_users/multitenancy.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ def _edit_form(self, request, form):
else show everything
"""
fields = form.base_fields
if 'organization' in fields:
fields['organization'].empty_label = 'Shared systemwide (no organization)'
if not request.user.is_superuser:
orgs_pk = request.user.organizations_managed
# organizations relation;
Expand Down
9 changes: 9 additions & 0 deletions openwisp_users/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1381,6 +1381,15 @@ def test_admin_add_user_with_invalid_email(self):
self.client.post(reverse(f'admin:{self.app_label}_user_add'), params)
mocked.assert_called_once()

def test_organization_default_label(self):
admin = self._create_admin()
self.client.force_login(admin)
url = reverse(f'admin:testapp_book_add')
r = self.client.get(url)
self.assertContains(
r, '<option value="" selected>Shared systemwide (no organization)</option>'
)

@classmethod
def tearDownClass(cls):
super().tearDownClass()
Expand Down

0 comments on commit 84e7cd1

Please sign in to comment.