summaryrefslogtreecommitdiff
path: root/yaksh/management/commands/add_group.py
diff options
context:
space:
mode:
authorMahesh Gudi2018-03-21 13:48:56 +0000
committerGitHub2018-03-21 13:48:56 +0000
commit9a5918700857ee7b912221e1df850bb0288262c2 (patch)
tree367ef8a4e85b0b6643836ab83786f9e7e8c00d95 /yaksh/management/commands/add_group.py
parente244cd285669d3de80a764d75eecbb46b6d3fd63 (diff)
parent4b356aa2f6097cd0f46292218f31ded18b631e53 (diff)
downloadonline_test-9a5918700857ee7b912221e1df850bb0288262c2.tar.gz
online_test-9a5918700857ee7b912221e1df850bb0288262c2.tar.bz2
online_test-9a5918700857ee7b912221e1df850bb0288262c2.zip
Merge branch 'master' into fix_quiz_completion
Diffstat (limited to 'yaksh/management/commands/add_group.py')
-rw-r--r--yaksh/management/commands/add_group.py32
1 files changed, 0 insertions, 32 deletions
diff --git a/yaksh/management/commands/add_group.py b/yaksh/management/commands/add_group.py
deleted file mode 100644
index 624ff3c..0000000
--- a/yaksh/management/commands/add_group.py
+++ /dev/null
@@ -1,32 +0,0 @@
-'''
- This command adds moderator group with permissions to add, change and delete
- the objects in the exam app.
- We can modify this command to add more groups by providing arguments.
- Arguments like group-name, app-name can be passed.
-'''
-
-# django imports
-from django.core.management.base import BaseCommand, CommandError
-from django.contrib.auth.models import Group, Permission
-from django.contrib.contenttypes.models import ContentType
-from django.db.utils import IntegrityError
-
-class Command(BaseCommand):
- help = 'Adds the moderator group'
-
- def handle(self, *args, **options):
- app_label = 'yaksh'
- group = Group(name='moderator')
- try:
- group.save()
- except IntegrityError:
- raise CommandError("The group already exits")
- else:
- # Get the models for the given app
- content_types = ContentType.objects.filter(app_label=app_label)
- # Get list of permissions for the models
- permission_list = Permission.objects.filter(content_type__in=content_types)
- group.permissions.add(*permission_list)
- group.save()
-
- self.stdout.write('Moderator group added successfully')