aboutsummaryrefslogtreecommitdiffstats
path: root/modules/django_application
diff options
context:
space:
mode:
authorMichael Scherer <misc@mageia.org>2011-02-25 18:25:49 +0000
committerMichael Scherer <misc@mageia.org>2011-02-25 18:25:49 +0000
commit2921ceb98adb19c97a9687637adfd697965e4570 (patch)
treed3b6a64d859bf257adf2beb854fbff3e8b212c52 /modules/django_application
parent75efc2825979ba6de2ba4f638b4ffef07ffc9038 (diff)
downloadpuppet-2921ceb98adb19c97a9687637adfd697965e4570.tar
puppet-2921ceb98adb19c97a9687637adfd697965e4570.tar.gz
puppet-2921ceb98adb19c97a9687637adfd697965e4570.tar.bz2
puppet-2921ceb98adb19c97a9687637adfd697965e4570.tar.xz
puppet-2921ceb98adb19c97a9687637adfd697965e4570.zip
- allow to give the application name ( as the codename is not enough )
Diffstat (limited to 'modules/django_application')
-rw-r--r--modules/django_application/files/django_add_permission_to_group.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/modules/django_application/files/django_add_permission_to_group.py b/modules/django_application/files/django_add_permission_to_group.py
index c5edc31c..4e5714f3 100644
--- a/modules/django_application/files/django_add_permission_to_group.py
+++ b/modules/django_application/files/django_add_permission_to_group.py
@@ -3,9 +3,18 @@ import sys
group_name = sys.argv[1]
permission = sys.argv[2]
-from django.contrib.auth.models import Group,Permission
+# as codename is not unique, we need to give the application name
+app = ''
+if len(sys.argv) > 3:
+ app = sys.argv[3]
+
+from django.contrib.auth.models import Group, Permission
g = Group.objects.get(name=group_name)
-p = Permission.objects.get(codename=permission)
+
+p = Permission.objects.filter(codename=permission)
+if app:
+ p = p.filter(content_type__app_label__exact=app)
+p = p[0]
g.permissions.add(p)
g.save()