-
-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # Generated by Django 3.0.8 on 2020-07-14 15:28 | ||
|
|
||
| from django.db import migrations | ||
|
|
||
| from . import allow_admins_change_organization | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('openwisp_users', '0009_create_organization_owners'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.RunPython( | ||
| allow_admins_change_organization, reverse_code=migrations.RunPython.noop | ||
| ) | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -134,3 +134,22 @@ def create_organization_owners(apps, schema_editor): | |
| OrganizationOwner.objects.create( | ||
| organization_user=org_user, organization=org | ||
| ) | ||
|
|
||
|
|
||
| def allow_admins_change_organization(apps, schema_editor): | ||
| Group = get_model(apps, 'Group') | ||
| try: | ||
| admins = Group.objects.get(name='Administrator') | ||
| permissions = [ | ||
| Permission.objects.get( | ||
| content_type__app_label=Group._meta.app_label, | ||
| codename='change_organization', | ||
| ).pk, | ||
| Permission.objects.get( | ||
| content_type__app_label=Group._meta.app_label, | ||
| codename='change_organizationowner', | ||
| ).pk, | ||
| ] | ||
| admins.permissions.add(*permissions) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please simplify, we added 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) |
||
| except ObjectDoesNotExist: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no missing word, please read carefully:
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I created a patch for this issue: #157 |
||
| pass | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Generated by Django 3.0.8 on 2020-07-23 17:55 | ||
|
|
||
| from django.db import migrations | ||
| from openwisp_users.migrations import allow_admins_change_organization | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('testapp', '0003_multitenancy'), | ||
| ] | ||
|
|
||
| operations = [migrations.RunPython(allow_admins_change_organization)] |
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: