Commit c6f318d9 by Őry Máté

dashboard: add logging to model

parent 93751cdf
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:"org_id of %s added to user %s's profile",
value, sender.username)
profile.org_id = value
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)
logger.debug("Do not register save_org_id to djangosaml2 pre_user_save")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment