From a92797d65437f16c5f1eb88adc8a290a20213a2f Mon Sep 17 00:00:00 2001 From: Michael Scherer Date: Fri, 25 Feb 2011 18:25:53 +0000 Subject: - add better error messages --- modules/django_application/files/django_add_permission_to_group.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'modules') 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() -- cgit v1.2.1