3 from django.utils.translation import ugettext as _
\r
5 class Activity(models.Model):
\r
7 We keep some history data for user activities
\r
9 user = models.ForeignKey(User)
\r
10 activity_type = models.SmallIntegerField(choices=TYPE_ACTIVITY)
\r
11 active_at = models.DateTimeField(default=datetime.datetime.now)
\r
12 content_type = models.ForeignKey(ContentType)
\r
13 object_id = models.PositiveIntegerField()
\r
14 content_object = generic.GenericForeignKey('content_type', 'object_id')
\r
15 is_auditted = models.BooleanField(default=False)
\r
17 def __unicode__(self):
\r
18 return u'[%s] was active at %s' % (self.user.username, self.active_at)
\r
22 db_table = u'activity'
\r
24 class EmailFeedSetting(models.Model):
\r
26 'w':datetime.timedelta(7),
\r
27 'd':datetime.timedelta(1),
\r
28 'n':datetime.timedelta(-1),
\r
31 ('q_all',_('Entire forum')),
\r
32 ('q_ask',_('Questions that I asked')),
\r
33 ('q_ans',_('Questions that I answered')),
\r
34 ('q_sel',_('Individually selected questions')),
\r
36 UPDATE_FREQUENCY = (
\r
39 ('n',_('No email')),
\r
41 subscriber = models.ForeignKey(User)
\r
42 feed_type = models.CharField(max_length=16,choices=FEED_TYPES)
\r
43 frequency = models.CharField(max_length=8,choices=UPDATE_FREQUENCY,default='n')
\r
44 added_at = models.DateTimeField(auto_now_add=True)
\r
45 reported_at = models.DateTimeField(null=True)
\r
47 def save(self,*args,**kwargs):
\r
48 type = self.feed_type
\r
49 subscriber = self.subscriber
\r
50 similar = self.__class__.objects.filter(feed_type=type,subscriber=subscriber).exclude(pk=self.id)
\r
51 if len(similar) > 0:
\r
52 raise IntegrityError('email feed setting already exists')
\r
53 super(EmailFeedSetting,self).save(*args,**kwargs)
\r
58 class AnonymousEmail(models.Model):
\r
59 #validation key, if used
\r
60 key = models.CharField(max_length=32)
\r
61 email = models.EmailField(null=False,unique=True)
\r
62 isvalid = models.BooleanField(default=False)
\r
68 class AuthKeyUserAssociation(models.Model):
\r
69 key = models.CharField(max_length=256,null=False,unique=True)
\r
70 provider = models.CharField(max_length=64)
\r
71 user = models.ForeignKey(User)
\r
72 added_at = models.DateTimeField(default=datetime.datetime.now)
\r