summaryrefslogtreecommitdiff
path: root/yaksh/management/commands/create_moderator.py
diff options
context:
space:
mode:
authoradityacp2018-05-24 12:07:39 +0530
committeradityacp2018-06-07 14:50:47 +0530
commit97b657edc2a323f832c81f0e34ce5761bd21f7e9 (patch)
tree09f4367f813fab99ffa8cd540d246cfc8c8fa00a /yaksh/management/commands/create_moderator.py
parent78ce1804d3a82327aa0da1510bb5c03d6bbff3ba (diff)
downloadonline_test-97b657edc2a323f832c81f0e34ce5761bd21f7e9.tar.gz
online_test-97b657edc2a323f832c81f0e34ce5761bd21f7e9.tar.bz2
online_test-97b657edc2a323f832c81f0e34ce5761bd21f7e9.zip
Pep8 changes
Diffstat (limited to 'yaksh/management/commands/create_moderator.py')
-rw-r--r--yaksh/management/commands/create_moderator.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/yaksh/management/commands/create_moderator.py b/yaksh/management/commands/create_moderator.py
index 3bbe462..86489d5 100644
--- a/yaksh/management/commands/create_moderator.py
+++ b/yaksh/management/commands/create_moderator.py
@@ -1,5 +1,6 @@
'''
- This command creates a moderator group and adds users to the moderator group with permissions to add, change and delete
+ This command creates a moderator group and adds users to the moderator group
+ with permissions to add, change and delete
the objects in the exam app.
'''
@@ -7,10 +8,7 @@
from django.core.management.base import BaseCommand, CommandError
from django.contrib.auth.models import User, Group, Permission
from django.contrib.contenttypes.models import ContentType
-from django.db.utils import IntegrityError
-# Yaksh imports
-from yaksh.models import Profile
class Command(BaseCommand):
help = 'Adds users to the moderator group'
@@ -30,7 +28,8 @@ class Command(BaseCommand):
# 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)
+ permission_list = Permission.objects.filter(
+ content_type__in=content_types)
group.permissions.add(*permission_list)
group.save()
self.stdout.write('Moderator group added successfully')
@@ -40,9 +39,15 @@ class Command(BaseCommand):
try:
user = User.objects.get(username=uname)
except User.DoesNotExist:
- raise CommandError('User "{0}" does not exist'.format(uname))
+ raise CommandError('User "{0}" does not exist'.format(
+ uname)
+ )
if user in group.user_set.all():
- self.stdout.write('User "{0}" is already a Moderator'.format(uname))
+ self.stdout.write('User "{0}" is '
+ 'already a Moderator'.format(uname)
+ )
else:
group.user_set.add(user)
- self.stdout.write('Successfully added User "{0}" to Moderator group'.format(uname))
+ self.stdout.write('Successfully added User "{0}"'
+ ' to Moderator group'.format(uname)
+ )