-
-
Notifications
You must be signed in to change notification settings - Fork 74
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
[groups] Added default "operator" and "user manager" groups. #40
Conversation
b227ae3
to
53f822b
Compare
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.
Tested and works! A minor correction is needed for older django versions, see my comments below.
I created the issues in the other modules to add the permissions to the operator group, we could have some of those issues put as GCI tasks! :-)
operator = group.objects.filter(name='operator') | ||
if operator.count() == 0: | ||
operator = group.objects.create(name='operator') | ||
operator.permissions.set([]) |
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.
this line is not needed now, right?
user_manager.permissions.set([ | ||
Permission.objects.get(codename='add_user').pk, | ||
Permission.objects.get(codename='change_user').pk, | ||
Permission.objects.get(codename='view_user').pk, |
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.
this permission is available only from django 2.1 onwards (finally!). In order to support older versions of django the simples thing you can do in this case is to build the list of permissions (except the view one) before the set
call, then append the view_user
permission within a try, except DoesNotExist:
block.
PS: also rebase on the current master when you can |
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.
Implements and closes openwisp#31
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.
Great work @R9295! 👍
Removed the logics which were duplicated in the others modules and redefined it here to enable reusability and ease debugging. Fixes #40
[admin] Removed logic duplicates #40
Implements and closes #31