-
-
Notifications
You must be signed in to change notification settings - Fork 87
[admin] allow administrator role access organization admin #143 #152
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] allow administrator role access organization admin #143 #152
Conversation
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.
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
openwisp_users/tests/test_admin.py
Outdated
| f'admin:{self.app_label}_organization_change', args=[default_org.pk] | ||
| ) | ||
| ), | ||
| follow=True, |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
nemesifier
left a comment
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.
👍
…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