Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
rp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
15
Issues
15
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
La Quadrature du Net
rpteam
rp
Commits
220f4be0
Verified
Commit
220f4be0
authored
Nov 29, 2017
by
Thibaut Broggi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make command "init_groups" assign "padawan" group to all users
parent
aaf50250
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
1 deletion
+5
-1
apps/core/management/commands/init_groups.py
apps/core/management/commands/init_groups.py
+5
-1
No files found.
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