summaryrefslogtreecommitdiff
path: root/yaksh/management
diff options
context:
space:
mode:
authorankitjavalkar2017-01-02 15:44:31 +0530
committerankitjavalkar2017-01-02 15:44:31 +0530
commit510a8d60168405111aae2fe291ba77e3d5456869 (patch)
tree24118bf8d0a446f8b2b768b6e9adf7e4da2989d2 /yaksh/management
parent011ca73b4c1042ceb208974e57c11474ecea65f2 (diff)
downloadonline_test-510a8d60168405111aae2fe291ba77e3d5456869.tar.gz
online_test-510a8d60168405111aae2fe291ba77e3d5456869.tar.bz2
online_test-510a8d60168405111aae2fe291ba77e3d5456869.zip
Bug Fix: Add permissions for all models related to yaksh
- Earlier only permissions related to Answer models were being added to the group, fixed so that all model permissions are added
Diffstat (limited to 'yaksh/management')
-rw-r--r--yaksh/management/commands/add_group.py11
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')