Fakultas Ilmu Komputer UI
Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ppl-fasilkom-ui
2021
Kelas D
PT Gizi Sehat - Dietela
Dietela Backend
Commits
cff7e4f3
Commit
cff7e4f3
authored
Apr 25, 2021
by
Kefas Satrio Bangkit Solideantyo
Browse files
[REFACTOR] change user group creation to get_or_create
parent
02d1f355
Pipeline
#72308
passed with stage
in 6 minutes and 12 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
authentication/managers.py
View file @
cff7e4f3
...
...
@@ -18,12 +18,8 @@ class CustomUserManager(BaseUserManager):
user
=
self
.
model
(
email
=
email
,
**
extra_fields
)
user
.
set_password
(
password
)
user
.
save
()
if
not
Group
.
objects
.
filter
(
name
=
'client'
).
exists
():
client_role
=
Group
.
objects
.
create
(
name
=
'client'
)
user
.
groups
.
add
(
client_role
)
else
:
client_role
=
Group
.
objects
.
get
(
name
=
'client'
)
user
.
groups
.
add
(
client_role
)
client_role
,
_created
=
Group
.
objects
.
get_or_create
(
name
=
'client'
)
user
.
groups
.
add
(
client_role
)
return
user
def
create_superuser
(
self
,
email
,
password
,
**
extra_fields
):
...
...
Write
Preview
Supports
Markdown
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