summaryrefslogtreecommitdiffstats
path: root/hyperkitty/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'hyperkitty/models.py')
-rw-r--r--hyperkitty/models.py87
1 files changed, 44 insertions, 43 deletions
diff --git a/hyperkitty/models.py b/hyperkitty/models.py
index 00c5128..0ed8f46 100644
--- a/hyperkitty/models.py
+++ b/hyperkitty/models.py
@@ -29,61 +29,62 @@ from hyperkitty.lib import ThreadSafeStorePool
class Rating(models.Model):
- # @TODO: instead of list_address, user list model from kittystore?
- list_address = models.CharField(max_length=50)
+ # @TODO: instead of list_address, user list model from kittystore?
+ list_address = models.CharField(max_length=50)
- # @TODO: instead of messsageid, use message model from kittystore?
- messageid = models.CharField(max_length=100)
+ # @TODO: instead of messsageid, use message model from kittystore?
+ messageid = models.CharField(max_length=100)
- user = models.ForeignKey(User)
+ user = models.ForeignKey(User)
- vote = models.SmallIntegerField()
+ vote = models.SmallIntegerField()
- def __unicode__(self):
- """Unicode representation"""
- if self.vote == 1:
- return u'id = %s : %s voted up %s' % (self.id, unicode(self.user), self.messageid)
- else:
- return u'id = %s : %s voted down %s' % (self.id, unicode(self.user), self.messageid)
+ def __unicode__(self):
+ """Unicode representation"""
+ if self.vote == 1:
+ return u'id = %s : %s voted up %s' % (self.id, unicode(self.user), self.messageid)
+ else:
+ return u'id = %s : %s voted down %s' % (self.id, unicode(self.user), self.messageid)
class UserProfile(models.Model):
- # User Object
- user = models.OneToOneField(User)
+ # User Object
+ user = models.OneToOneField(User)
- karma = models.IntegerField(default=1)
+ karma = models.IntegerField(default=1)
- def _get_votes(self):
- "Returns all the votes by a user"
- # Extract all the votes by this user
- try:
- votes = Rating.objects.filter(user=self.user)
- except Rating.DoesNotExist:
- votes = {}
+ def _get_votes(self):
+ "Returns all the votes by a user"
+ # Extract all the votes by this user
+ try:
+ votes = Rating.objects.filter(user=self.user)
+ except Rating.DoesNotExist:
+ votes = {}
- for vote in votes:
- list_name = vote.list_address.split('@')[0]
- STORE = ThreadSafeStorePool().get()
- message = STORE.get_message_by_id_from_list(vote.list_address, vote.messageid)
- vote.message = message
+ STORE = ThreadSafeStorePool().get()
+ for vote in votes:
+ list_name = vote.list_address.split('@')[0]
+ message = STORE.get_message_by_id_from_list(vote.list_address, vote.messageid)
+ vote.message = message
- return votes
+ return votes
- votes = property(_get_votes)
+ votes = property(_get_votes)
+
+ def __unicode__(self):
+ """Unicode representation"""
+ return u'%s' % (unicode(self.user))
- def __unicode__(self):
- """Unicode representation"""
- return u'%s' % (unicode(self.user))
class Tag(models.Model):
- # @TODO: instead of list_address, user list model from kittystore?
- list_address = models.CharField(max_length=50)
-
- # @TODO: instead of threadid, use thread model from kittystore?
- threadid = models.CharField(max_length=100)
-
- tag = models.CharField(max_length=255)
-
- def __unicode__(self):
- """Unicode representation"""
- return u'threadid = %s , tag = %s ' % (unicode(self.list_address), unicode(self.threadid))
+ # @TODO: instead of list_address, user list model from kittystore?
+ list_address = models.CharField(max_length=50)
+
+ # @TODO: instead of threadid, use thread model from kittystore?
+ threadid = models.CharField(max_length=100)
+
+ tag = models.CharField(max_length=255)
+
+ def __unicode__(self):
+ """Unicode representation"""
+ return u'threadid = %s , tag = %s ' % (unicode(self.list_address), unicode(self.threadid))