Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
La Quadrature du Net
rpteam
Revue de Press
Commits
220f4be0
Verified
Commit
220f4be0
authored
Nov 29, 2017
by
Thibaut Broggi
Browse files
Make command "init_groups" assign "padawan" group to all users
parent
aaf50250
Changes
1
Hide whitespace changes
Inline
Side-by-side
apps/core/management/commands/init_groups.py
View file @
220f4be0
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"
]
permissions
=
{
...
...
@@ -20,3 +20,7 @@ class Command(BaseCommand):
new_group
,
created
=
Group
.
objects
.
get_or_create
(
name
=
g
)
for
p
in
permissions
[
g
]:
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"
))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment