2010-10-13 02:57:59 +02:00
|
|
|
from django.db import models
|
2011-03-08 19:13:22 +01:00
|
|
|
from django.db.models.signals import post_save
|
2010-10-13 02:57:59 +02:00
|
|
|
from django.contrib.auth.models import User
|
2011-09-29 19:17:11 +02:00
|
|
|
from decimal import Decimal
|
2010-10-13 02:57:59 +02:00
|
|
|
|
|
|
|
class UserProfile(models.Model):
|
|
|
|
user = models.ForeignKey(User, unique=True)
|
2011-09-29 19:17:11 +02:00
|
|
|
balance = models.DecimalField(max_digits=9, decimal_places=2, default=Decimal(0))
|
2010-10-13 06:59:30 +02:00
|
|
|
|
|
|
|
def __unicode__(self):
|
2010-10-16 17:33:18 +02:00
|
|
|
return "%s (Kontostand: %s)" % (self.user ,self.balance)
|
2011-03-08 19:13:22 +01:00
|
|
|
|
|
|
|
def createUserProfile(sender, instance, created, **kwargs):
|
|
|
|
if created:
|
|
|
|
profile = UserProfile()
|
|
|
|
profile.user = instance
|
|
|
|
profile.save()
|
|
|
|
|
|
|
|
post_save.connect(createUserProfile, sender=User)
|
|
|
|
|