Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nk20
Manage
Activity
Members
Labels
Plan
Issues
31
Issue boards
Milestones
Wiki
Code
Merge requests
6
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BDE
nk20
Commits
3c52c1d0
Commit
3c52c1d0
authored
5 years ago
by
ynerant
Browse files
Options
Downloads
Patches
Plain Diff
Users have now automatically an attached profile to a user (fix an old bug)
parent
d316c313
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!28
Logs
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
apps/member/apps.py
+13
-0
13 additions, 0 deletions
apps/member/apps.py
apps/member/signals.py
+13
-0
13 additions, 0 deletions
apps/member/signals.py
with
26 additions
and
0 deletions
apps/member/apps.py
+
13
−
0
View file @
3c52c1d0
...
...
@@ -2,9 +2,22 @@
# SPDX-License-Identifier: GPL-3.0-or-later
from
django.apps
import
AppConfig
from
django.conf
import
settings
from
django.db.models.signals
import
pre_save
from
django.utils.translation
import
gettext_lazy
as
_
from
.signals
import
save_user_note
class
MemberConfig
(
AppConfig
):
name
=
'
member
'
verbose_name
=
_
(
'
member
'
)
def
ready
(
self
):
"""
Define app internal signals to interact with other apps
"""
pre_save
.
connect
(
save_user_note
,
sender
=
settings
.
AUTH_USER_MODEL
,
)
This diff is collapsed.
Click to expand it.
apps/member/signals.py
+
13
−
0
View file @
3c52c1d0
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
# SPDX-License-Identifier: GPL-3.0-or-later
def
save_user_note
(
instance
,
created
,
raw
,
**
_kwargs
):
"""
Hook to create and save a profile when an user is updated if it is not registered with the signup form
"""
if
raw
:
# When provisionning data, do not try to autocreate
return
if
created
:
from
.models
import
Profile
Profile
.
objects
.
get_or_create
(
user
=
instance
)
instance
.
profile
.
save
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment