Commit 069f4c7f authored by Michal Čihař's avatar Michal Čihař

Add management command to setup groups

parent 1ac7101d
from django.core.management.base import BaseCommand, CommandError
from trans.models import SubProject
from optparse import make_option
from django.contrib.auth.models import Group, Permission
class Command(BaseCommand):
help = 'setups default groups'
option_list = BaseCommand.option_list + (
make_option('--move',
action='store_true',
dest='move',
default=False,
help='Move all users to Users group'),
)
def handle(self, *args, **options):
group, created = Group.objects.get_or_create(name = 'Users')
if created:
group.permissions.add(
Permission.objects.get(codename = 'upload_translation'),
Permission.objects.get(codename = 'overwrite_translation'),
Permission.objects.get(codename = 'save_translation'),
Permission.objects.get(codename = 'accept_suggestion'),
Permission.objects.get(codename = 'ignore_check'),
)
if options['move']:
for u in User.objects.all():
u.groups.add(group)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment