Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gutyán Gábor
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
c6f318d9
authored
Feb 06, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: add logging to model
parent
93751cdf
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
0 deletions
+14
-0
circle/dashboard/models.py
+14
-0
No files found.
circle/dashboard/models.py
View file @
c6f318d9
from
logging
import
getLogger
from
django.conf
import
settings
from
django.contrib.auth.models
import
User
from
django.db.models
import
Model
,
ForeignKey
,
OneToOneField
,
CharField
...
...
@@ -6,6 +8,8 @@ from django.utils.translation import ugettext_lazy as _
from
vm.models
import
Instance
logger
=
getLogger
(
__name__
)
class
Favourite
(
Model
):
instance
=
ForeignKey
(
Instance
)
user
=
ForeignKey
(
User
)
...
...
@@ -23,15 +27,25 @@ class Profile(Model):
if
hasattr
(
settings
,
'SAML_ORG_ID_ATTRIBUTE'
):
logger
.
debug
(
"Register save_org_id to djangosaml2 pre_user_save"
)
from
djangosaml2.signals
import
pre_user_save
def
save_org_id
(
sender
,
attributes
,
user_modified
):
logger
.
debug
(
"save_org_id called by
%
s"
,
sender
.
username
)
atr
=
settings
.
SAML_ORG_ID_ATTRIBUTE
value
=
attributes
[
atr
]
profile
,
created
=
Profile
.
objects
.
get_or_create
(
user
=
sender
)
if
created
or
profile
.
org_id
!=
value
:
logger
.
info
(
"org_id of
%
s added to user
%
s's profile"
,
value
,
sender
.
username
)
profile
.
org_id
=
value
profile
.
save
()
else
:
logger
.
debug
(
"org_id of
%
s already added to user
%
s's profile"
,
value
,
sender
.
username
)
return
False
pre_user_save
.
connect
(
save_org_id
,
weak
=
False
)
else
:
logger
.
debug
(
"Do not register save_org_id to djangosaml2 pre_user_save"
)
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