logger = logging.getLogger(__name__)
+class UserProfileManager(models.Manager):
+ """ Handle restoring data. """
+ def get_by_natural_key(self, user):
+ return self.get(user=user)
+
+
class UserProfile(models.Model):
user = models.OneToOneField(User)
school = models.ForeignKey(School, blank=True, null=True)
+ def natural_key(self):
+ return (self.user)
+
def get_points(self):
sum = 0
for cls in ALL_KARMA_EVENT_CLASSES:
GenericKarmaEvent.create_event(kwargs['email_address'].user, kwargs['email_address'].email, GenericKarmaEvent.EMAIL_CONFIRMED)
+class BaseKarmaEventManager(models.Manager):
+ """ Handle restoring data. """
+ def get_by_natural_key(self, points, user, timestamp):
+ return self.get(points=points, user=user, timestamp=timestamp)
+
+
class BaseKarmaEvent(models.Model):
points = models.IntegerField()
user = models.ForeignKey(User)
class Meta:
abstract = True
+ unique_together = ('points', 'user', 'timestamp')
+
+ def natural_key(self):
+ return (self.points, self.user, self.timestamp)
def get_message(self):
raise NotImplemented()