diff options
author | adityacp | 2017-01-04 11:42:32 +0530 |
---|---|---|
committer | adityacp | 2017-01-04 11:42:32 +0530 |
commit | 58481cdcba38e8e602b8e2d3e5172f9e653f93a9 (patch) | |
tree | 21312113c078b6b22f24d5bab052a52bd185a3c9 /yaksh/management/commands | |
parent | b271e3b33f673c70114893bf461d2a6116dd7cf7 (diff) | |
parent | ef6a61b1938ec399efb6d66b914f245afa3ed5ff (diff) | |
download | online_test-58481cdcba38e8e602b8e2d3e5172f9e653f93a9.tar.gz online_test-58481cdcba38e8e602b8e2d3e5172f9e653f93a9.tar.bz2 online_test-58481cdcba38e8e602b8e2d3e5172f9e653f93a9.zip |
Merge https://github.com/fossee/online_test into fix_management_commands
Diffstat (limited to 'yaksh/management/commands')
-rw-r--r-- | yaksh/management/commands/add_group.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/yaksh/management/commands/add_group.py b/yaksh/management/commands/add_group.py index 03ef103..624ff3c 100644 --- a/yaksh/management/commands/add_group.py +++ b/yaksh/management/commands/add_group.py @@ -15,7 +15,7 @@ class Command(BaseCommand): help = 'Adds the moderator group' def handle(self, *args, **options): - app = 'yaksh' + app_label = 'yaksh' group = Group(name='moderator') try: group.save() @@ -23,11 +23,10 @@ class Command(BaseCommand): raise CommandError("The group already exits") else: # Get the models for the given app - content_types = ContentType.objects.filter(app_label=app) + content_types = ContentType.objects.filter(app_label=app_label) # Get list of permissions for the models - permission_list = Permission.objects.filter(content_type=content_types) - for permission in permission_list: - group.permissions.add(permission) - group.save() + permission_list = Permission.objects.filter(content_type__in=content_types) + group.permissions.add(*permission_list) + group.save() self.stdout.write('Moderator group added successfully') |