diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/django_application/files/django_add_permission_to_group.py | 5 |
1 files changed, 4 insertions, 1 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 5c3c915f..4fa77e8d 100644 --- a/modules/django_application/files/django_add_permission_to_group.py +++ b/modules/django_application/files/django_add_permission_to_group.py @@ -15,10 +15,13 @@ permissions = Permission.objects.filter(codename=permission) if app: permissions = permissions.filter(content_type__app_label__exact=app) -if len(permissions) != 1: +if len(permissions) > 1: print "Error, result not unique, please give the application among :" print ' '.join([p.content_type.app_label for p in permissions]) sys.exit(1) +elif len(permissions) < 1: + print "Error, wrong codename" + sys.exit(1) group.permissions.add(permissions[0]) group.save() |