diff options
author | Michael Scherer <misc@mageia.org> | 2011-02-25 18:25:49 +0000 |
---|---|---|
committer | Michael Scherer <misc@mageia.org> | 2011-02-25 18:25:49 +0000 |
commit | 2921ceb98adb19c97a9687637adfd697965e4570 (patch) | |
tree | d3b6a64d859bf257adf2beb854fbff3e8b212c52 /modules/django_application/files | |
parent | 75efc2825979ba6de2ba4f638b4ffef07ffc9038 (diff) | |
download | puppet-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/files')
-rw-r--r-- | modules/django_application/files/django_add_permission_to_group.py | 13 |
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() |