Files
caminus/local/models.py
Trever Fischer e0957c2dab Move MinecraftProfile from the profiles app into the minecraft app, and stop using the auth profiles feature.
Might go back to auth profiles if a suitable use can be found.
2012-03-04 23:18:00 -05:00

23 lines
735 B
Python

from django.db import models
from minecraft.models import MinecraftProfile
from django.db.models.signals import post_save
class CurrencyAccount(models.Model):
profile = models.OneToOneField(MinecraftProfile)
username = models.CharField(max_length=255, unique=True, null=True)
balance = models.FloatField(default=3000)
status = models.IntegerField()
def __unicode__(self):
return self.username
def save(self, *args, **kwargs):
if not self.username:
self.username = self.profile.mc_username
def create_account(sender, instance, created, **kwargs):
if created:
CurrencyAccount.objects.create(profile=instance)
post_save.connect(create_account, sender=MinecraftProfile)