Verified Commit 220f4be0 authored by Thibaut Broggi's avatar Thibaut Broggi
Browse files

Make command "init_groups" assign "padawan" group to all users

parent aaf50250
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
from django.contrib.auth.models import Group, Permission from django.contrib.auth.models import User, Group, Permission
groups = ["jedi", "padawan"] groups = ["jedi", "padawan"]
permissions = { permissions = {
...@@ -20,3 +20,7 @@ class Command(BaseCommand): ...@@ -20,3 +20,7 @@ class Command(BaseCommand):
new_group, created = Group.objects.get_or_create(name=g) new_group, created = Group.objects.get_or_create(name=g)
for p in permissions[g]: for p in permissions[g]:
new_group.permissions.add(Permission.objects.get(codename=p)) new_group.permissions.add(Permission.objects.get(codename=p))
users = User.objects.all()
for user in users:
user.groups.add(Group.objects.get(name="padawan"))
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