Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nk20
Manage
Activity
Members
Labels
Plan
Issues
32
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
6c2cdf06
Commit
6c2cdf06
authored
5 years ago
by
ynerant
Browse files
Options
Downloads
Patches
Plain Diff
Remove warning when no user is detected while a modification is made
parent
daef8065
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!56
Corrections
Pipeline
#7918
passed with stages
in 4 minutes and 3 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
apps/logs/signals.py
+17
-3
17 additions, 3 deletions
apps/logs/signals.py
with
17 additions
and
3 deletions
apps/logs/signals.py
+
17
−
3
View file @
6c2cdf06
...
@@ -67,9 +67,10 @@ def save_object(sender, instance, **kwargs):
...
@@ -67,9 +67,10 @@ def save_object(sender, instance, **kwargs):
ip
=
"
127.0.0.1
"
ip
=
"
127.0.0.1
"
username
=
Alias
.
normalize
(
getpass
.
getuser
())
username
=
Alias
.
normalize
(
getpass
.
getuser
())
note
=
NoteUser
.
objects
.
filter
(
alias__normalized_name
=
username
)
note
=
NoteUser
.
objects
.
filter
(
alias__normalized_name
=
username
)
if
not
note
.
exists
():
# if not note.exists():
print
(
"
WARNING: A model attempted to be saved in the DB, but the actor is unknown:
"
+
username
)
# print("WARNING: A model attempted to be saved in the DB, but the actor is unknown: " + username)
else
:
# else:
if
note
.
exists
():
user
=
note
.
get
().
user
user
=
note
.
get
().
user
# noinspection PyProtectedMember
# noinspection PyProtectedMember
...
@@ -113,6 +114,19 @@ def delete_object(sender, instance, **kwargs):
...
@@ -113,6 +114,19 @@ def delete_object(sender, instance, **kwargs):
# Si un utilisateur est connecté, on récupère l'utilisateur courant ainsi que son adresse IP
# Si un utilisateur est connecté, on récupère l'utilisateur courant ainsi que son adresse IP
user
,
ip
=
get_current_authenticated_user
(),
get_current_ip
()
user
,
ip
=
get_current_authenticated_user
(),
get_current_ip
()
if
user
is
None
:
# Si la modification n'a pas été faite via le client Web, on suppose que c'est du à `manage.py`
# On récupère alors l'utilisateur·trice connecté·e à la VM, et on récupère la note associée
# IMPORTANT : l'utilisateur dans la VM doit être un des alias note du respo info
ip
=
"
127.0.0.1
"
username
=
Alias
.
normalize
(
getpass
.
getuser
())
note
=
NoteUser
.
objects
.
filter
(
alias__normalized_name
=
username
)
# if not note.exists():
# print("WARNING: A model attempted to be saved in the DB, but the actor is unknown: " + username)
# else:
if
note
.
exists
():
user
=
note
.
get
().
user
# On crée notre propre sérialiseur JSON pour pouvoir sauvegarder les modèles
# On crée notre propre sérialiseur JSON pour pouvoir sauvegarder les modèles
class
CustomSerializer
(
ModelSerializer
):
class
CustomSerializer
(
ModelSerializer
):
class
Meta
:
class
Meta
:
...
...
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