-
-
Notifications
You must be signed in to change notification settings - Fork 281
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upon registration assign default group permissions if none set
also by default make all users have is_staff permissions so they can add Products, Builds, Versions, etc. via the ADMIN menu! If you don't want this to be possible (e.g. products and builds are synced automatically from a product database) you have to define another default group and revoke some of its permissions!
- Loading branch information
Showing
4 changed files
with
35 additions
and
4 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
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
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
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,20 @@ | ||
# -*- coding: utf-8 -*- | ||
from django.contrib.auth.models import Group, Permission | ||
|
||
|
||
def assign_default_group_permissions(): | ||
""" | ||
Adds the default permissions for Administrator and Tester | ||
groups! | ||
""" | ||
admin = Group.objects.get(name='Administrator') | ||
if admin.permissions.count() == 0: | ||
all_perms = Permission.objects.all() | ||
admin.permissions.add(*all_perms) | ||
|
||
tester = Group.objects.get(name='Tester') | ||
if tester.permissions.count() == 0: | ||
# apply all permissions for test case & product management | ||
for app_name in ['django_comments', 'management', 'testcases', 'testplans', 'testruns']: | ||
app_perms = Permission.objects.filter(content_type__app_label__contains=app_name) | ||
tester.permissions.add(*app_perms) |