-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cu 862j1wq35 default user group (#171)
* initial commit for a default user group * fixed issue with multiple permissions * pulled group creation out of if statement * added new script for a group to be created --------- Authored-by: Adam Sutton <[email protected]>
- Loading branch information
1 parent
a74c704
commit 266ba52
Showing
2 changed files
with
18 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from django.contrib.auth.models import Group, Permission | ||
from itertools import chain | ||
|
||
print("Checking for Default User Group") | ||
group, created = Group.objects.get_or_create(name='user_group') | ||
if created: | ||
print("No Default User Group Found - Creating with Permissions") | ||
dataset = list(Permission.objects.filter(codename__contains='dataset').exclude(codename__contains='delete')) | ||
concept = list(Permission.objects.filter(codename__contains='concept')) | ||
project = list(Permission.objects.filter(codename__contains="projectannotateentities").exclude(codename__contains="delete")) | ||
permissions = chain(dataset, concept, project) | ||
for p in permissions: | ||
group.permissions.add(p) | ||
print("User_group created with minimum correct permissions") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters