summaryrefslogtreecommitdiff
path: root/yaksh
diff options
context:
space:
mode:
authorAkash Chavan2019-01-04 12:19:25 +0530
committerGitHub2019-01-04 12:19:25 +0530
commit75c5ed2569715610dd0d4864659501d101eb640d (patch)
tree688e32e86dc842dde925bdb0b9911562dbef2bf5 /yaksh
parentf2a03ec0fa32e0f23d1f8215209450c3251f691b (diff)
parentd16d3fa6be39394bd39ae5da960f8013ffbe45ca (diff)
downloadonline_test-75c5ed2569715610dd0d4864659501d101eb640d.tar.gz
online_test-75c5ed2569715610dd0d4864659501d101eb640d.tar.bz2
online_test-75c5ed2569715610dd0d4864659501d101eb640d.zip
Merge pull request #533 from CruiseDevice/update_create_moderator
Create_moderator command sets is_moderator to True
Diffstat (limited to 'yaksh')
-rw-r--r--yaksh/management/commands/create_moderator.py28
1 files changed, 18 insertions, 10 deletions
diff --git a/yaksh/management/commands/create_moderator.py b/yaksh/management/commands/create_moderator.py
index 96276b5..3ec012e 100644
--- a/yaksh/management/commands/create_moderator.py
+++ b/yaksh/management/commands/create_moderator.py
@@ -24,22 +24,30 @@ class Command(BaseCommand):
group_name = 'moderator'
group = create_group(group_name, app_label)
if group and isinstance(group, Group):
- self.stdout.write('Moderator group added successfully')
+ self.stdout.write(self.style.SUCCESS(
+ 'Moderator group added successfully'))
if options['usernames']:
for uname in options['usernames']:
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(
+ self.style.WARNING(
+ '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)
- )
+ user.profile.is_moderator = True
+ user.profile.save()
+ self.stdout.write(
+ self.style.SUCCESS(
+ 'Successfully added User "{0}"'
+ ' to Moderator group'.format(uname)
+ )
+ )