summaryrefslogtreecommitdiff
path: root/yaksh/management/commands/add_group.py
diff options
context:
space:
mode:
authorprathamesh2017-01-13 16:49:16 +0530
committerprathamesh2017-01-13 16:49:16 +0530
commitc70c38dd55e159a5e7aa6706bb23bb8e70ca10bd (patch)
treef85d78faa6d51046b79e26ee59efa15e3c16bd75 /yaksh/management/commands/add_group.py
parent5ee9b4647c7f1ba9803a95ad3871f6acfc92c1c0 (diff)
parent0e3e0cdbf322df9b5c8b7da0301cebe71eadcbe9 (diff)
downloadonline_test-c70c38dd55e159a5e7aa6706bb23bb8e70ca10bd.tar.gz
online_test-c70c38dd55e159a5e7aa6706bb23bb8e70ca10bd.tar.bz2
online_test-c70c38dd55e159a5e7aa6706bb23bb8e70ca10bd.zip
Merge branch 'master' of https://github.com/FOSSEE/online_test into UI-modifications-phase-2
Diffstat (limited to 'yaksh/management/commands/add_group.py')
-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')