Skip to content

Commit

Permalink
adding model and signal to user post_save - closes colab#104
Browse files Browse the repository at this point in the history
  • Loading branch information
LuanP committed Dec 17, 2013
1 parent f21f3dd commit 7740189
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/proxy/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

from django.conf import settings
from django.db import models
from django.db.models.signals import post_save
from django.dispatch import receiver

from accounts.models import User
from hitcounter.models import HitCounterModelMixin
Expand Down Expand Up @@ -148,3 +150,27 @@ class TicketCollabCount(models.Model):
class Meta:
managed = False
db_table = 'ticket_collab_count_view'


class SessionAttribute(models.Model):
sid = models.TextField(primary_key=True)
authenticated = models.IntegerField()
name = models.TextField()
value = models.TextField(blank=True)

class Meta:
managed = False
db_table = 'session_attribute'


@receiver(post_save, sender=User)
def change_session_attribute_email(sender, instance, **kwargs):
try:
session_attr = SessionAttribute.objects.get(
sid=instance.username, name='email'
)
except SessionAttribute.DoesNotExist:
pass
else:
session_attr.value = instance.email
session_attr.save()

0 comments on commit 7740189

Please sign in to comment.