[admin] allow administrator role access organization admin #143#152
[admin] allow administrator role access organization admin #143#152nemesifier merged 2 commits intomasterfrom
Conversation
There was a problem hiding this comment.
Good progress! Sorry for my late response.
For some reason while testing, the permissions were not added to the administrator group correctly in my env.
So I wanted to run the migration backward to run it again and found this:
raise IrreversibleError("Operation %s in %s is not reversible" % (operation, self))
django.db.migrations.exceptions.IrreversibleError: Operation <RunPython <function allow_admins_change_organization at 0x7fa9626b6dd0>> in openwisp_users.0010_allow_admins_change_organization is not reversible
PS: also rebase on the latest master please
| f'admin:{self.app_label}_organization_change', args=[default_org.pk] | ||
| ) | ||
| ), | ||
| follow=True, |
There was a problem hiding this comment.
rather than following the redirect, assert the status code to ensure it's a redirect and remove the following lines which are not relevant anymore
|
Sure. Will do that today |
@nemesisdesign It says that because I didn't make the migration reversible. I didn't see a reason to make this reversible since its absence will cause other core functionalities which were added to malfunction. Should i make it reversible? |
In this case we can simply set the backward migration to noop, no operation, look it up on the django docs please. |
679b46c to
400dbd2
Compare
|
@nemesisdesign This is ready for review |
nemesifier
left a comment
There was a problem hiding this comment.
Good progress, see my hints below and we're ready to move on
| ).pk, | ||
| ] | ||
| admins.permissions.add(*permissions) | ||
| except ObjectDoesNotExist: |
There was a problem hiding this comment.
it looks like this is here but it's not being imported at the top, don't you have flake8 configured in your editor to highlight these issues? I wonder why this doesn't pop up in the global flake8 check.
There was a problem hiding this comment.
@nemesisdesign Please i don't understand what you are asking for. it looks like your sentence is missing some words
There was a problem hiding this comment.
no missing word, please read carefully: ObjectDoesNotExist is used here but it's not imported.
Please activate flake8 checks in your editor.
There was a problem hiding this comment.
I created a patch for this issue: #157
I will merge that and then you only need to rebase.
| content_type__app_label=app_label, codename='change_organizationowner' | ||
| ).pk, | ||
| ] | ||
| admins.permissions.add(*permissions) |
There was a problem hiding this comment.
please simplify, we added get_model to avoid those lines, remember?
Group = get_model(apps, 'Group')
try:
admins = Group.objects.get(name='Administrator')
permissions = [
Permission.objects.get(
content_type__app_label='openwisp_users', codename='change_organization'
).pk,
Permission.objects.get(
content_type__app_label='openwisp_users', codename='change_organizationowner'
).pk,
]
admins.permissions.add(*permissions)| - Only super users have the permission to add and delete organizations. | ||
| - Only super users and organization owners have the permission to change the OrganizationOwner inline. | ||
| - Only Super users have the permission to delete OrganizationOwner inline. | ||
|
|
There was a problem hiding this comment.
here's an improved version:
Here's a summary of the default permissions:
- All users who belong to the Administrators group and are organization
managers (``OrganizationUser.is_admin=True``), have the permission to edit
the organizations details which they administrate.
- Only super users have the permission to add and delete organizations.
- Only super users and organization owners have the permission to change
the ``OrganizationOwner`` inline or delete the relation.
400dbd2 to
939836e
Compare
Closed issue by updating organization admin and also added a couple number of tests for these changes. Closes #143
939836e to
a234fec
Compare
…wisp#152 Made organization field visible when importing a CA or Cert. Fixes openwisp#152
[bug] Organization field is missing when importing a CA or cert. openwisp#152
Related to openwisp#152
Closed issue by updating organization admin and also added
a couple number of tests for these changes.
Fixes #143