summaryrefslogtreecommitdiff
path: root/testapp/yaksh_app/management/commands/add_group.py
diff options
context:
space:
mode:
authorankitjavalkar2015-09-11 12:35:09 +0530
committerankitjavalkar2015-09-14 12:00:53 +0530
commit32cde26f9807a29eb1fae0833e353212d43d7802 (patch)
tree52423f2c68ee22d4375eef86a3950d169410fe55 /testapp/yaksh_app/management/commands/add_group.py
parentae10d36297797ffc53275eabe3acfa0cb4bf3b11 (diff)
downloadonline_test-32cde26f9807a29eb1fae0833e353212d43d7802.tar.gz
online_test-32cde26f9807a29eb1fae0833e353212d43d7802.tar.bz2
online_test-32cde26f9807a29eb1fae0833e353212d43d7802.zip
Change app name to 'yaksh'
Diffstat (limited to 'testapp/yaksh_app/management/commands/add_group.py')
-rw-r--r--testapp/yaksh_app/management/commands/add_group.py33
1 files changed, 0 insertions, 33 deletions
diff --git a/testapp/yaksh_app/management/commands/add_group.py b/testapp/yaksh_app/management/commands/add_group.py
deleted file mode 100644
index db0ebb6..0000000
--- a/testapp/yaksh_app/management/commands/add_group.py
+++ /dev/null
@@ -1,33 +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 = 'yaksh_app'
- 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)
- # 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()
-
- self.stdout.write('Moderator group added successfully')