diff options
author | Madhusudan.C.S | 2009-10-30 15:09:12 +0530 |
---|---|---|
committer | Madhusudan.C.S | 2009-10-30 15:09:12 +0530 |
commit | f89410559c20dd88d78ccd6b9d24e7941da9d5ff (patch) | |
tree | 3ad4fb64efc7523d1f3065e0dd03693871d6ce55 /project/kiwipycon/user/models.py | |
parent | 75f0773685ef0724d8ccc1eb1aab16bba55cd7a7 (diff) | |
download | scipycon-f89410559c20dd88d78ccd6b9d24e7941da9d5ff.tar.gz scipycon-f89410559c20dd88d78ccd6b9d24e7941da9d5ff.tar.bz2 scipycon-f89410559c20dd88d78ccd6b9d24e7941da9d5ff.zip |
Added all the files from kiwipycon and the changes made for SciPy.in.
Diffstat (limited to 'project/kiwipycon/user/models.py')
-rw-r--r-- | project/kiwipycon/user/models.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/project/kiwipycon/user/models.py b/project/kiwipycon/user/models.py new file mode 100644 index 0000000..85cf762 --- /dev/null +++ b/project/kiwipycon/user/models.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +from __future__ import absolute_import + +#django +from django.db import models +from django.conf import settings +from django.db.models.signals import post_save +from django.contrib.auth.models import User + +class UserProfile(models.Model): + """ + Extend atributes for django User + """ + user = models.ForeignKey(User, unique=True) + url = models.URLField(blank=True, verify_exists=False) + photo = models.CharField(max_length=64, blank=True) + about = models.TextField(blank=True) + + def __unicode__(self): + return 'UserProfile for user: <%s %s> %s' % (self.user.first_name, + self.user.last_name, self.user.email) + + def fullname(self): + return '%s %s' % (self.user.first_name, self.user.last_name) + +def add_profile(sender, instance, signal, *args, **kwargs): + """Create user profile on create of new user""" + if not instance.is_superuser: + try: + profile, new = UserProfile.objects.get_or_create(user=instance) + if new: + profile.save() + except: + pass + +post_save.connect(add_profile, sender=User, weak=False) |