diff options
author | ankitjavalkar | 2018-07-11 17:19:56 +0530 |
---|---|---|
committer | ankitjavalkar | 2018-07-13 13:00:36 +0530 |
commit | e7c18d17c8b5ed193e4e34bdfe2072951d996530 (patch) | |
tree | abe3e154790aab9213ede12336a06f544ddbc79b /yaksh/management/commands | |
parent | 69a07a92309105b289f4d08957729bda68727bf2 (diff) | |
download | online_test-e7c18d17c8b5ed193e4e34bdfe2072951d996530.tar.gz online_test-e7c18d17c8b5ed193e4e34bdfe2072951d996530.tar.bz2 online_test-e7c18d17c8b5ed193e4e34bdfe2072951d996530.zip |
Fix tests
Diffstat (limited to 'yaksh/management/commands')
-rw-r--r-- | yaksh/management/commands/create_moderator.py | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/yaksh/management/commands/create_moderator.py b/yaksh/management/commands/create_moderator.py index 86489d5..96276b5 100644 --- a/yaksh/management/commands/create_moderator.py +++ b/yaksh/management/commands/create_moderator.py @@ -7,7 +7,9 @@ # django imports from django.core.management.base import BaseCommand, CommandError from django.contrib.auth.models import User, Group, Permission -from django.contrib.contenttypes.models import ContentType + +# local imports +from yaksh.models import create_group class Command(BaseCommand): @@ -19,19 +21,9 @@ class Command(BaseCommand): def handle(self, *args, **options): app_label = 'yaksh' - - try: - group = Group.objects.get(name='moderator') - except Group.DoesNotExist: - group = Group(name='moderator') - group.save() - # 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() + group_name = 'moderator' + group = create_group(group_name, app_label) + if group and isinstance(group, Group): self.stdout.write('Moderator group added successfully') if options['usernames']: |