diff options
author | Aamir Khan <syst3m.w0rm@gmail.com> | 2012-07-24 17:00:25 -0400 |
---|---|---|
committer | Aamir Khan <syst3m.w0rm@gmail.com> | 2012-07-24 17:00:25 -0400 |
commit | 9f18a590819a01017c15169d82763680a72848fb (patch) | |
tree | 9c781cd677eeae9b1e50e986647e1929e99bdac7 /models.py | |
parent | ae77d9901e2a466622818f95d784fb85b5296727 (diff) | |
download | hyperkitty-9f18a590819a01017c15169d82763680a72848fb.tar.gz hyperkitty-9f18a590819a01017c15169d82763680a72848fb.tar.xz hyperkitty-9f18a590819a01017c15169d82763680a72848fb.zip |
Packaging hyperkitty
Diffstat (limited to 'models.py')
-rw-r--r-- | models.py | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/models.py b/models.py deleted file mode 100644 index 588363d..0000000 --- a/models.py +++ /dev/null @@ -1,77 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 1998-2012 by the Free Software Foundation, Inc. -# -# This file is part of HyperKitty. -# -# HyperKitty is free software: you can redistribute it and/or modify it under -# the terms of the GNU General Public License as published by the Free -# Software Foundation, either version 3 of the License, or (at your option) -# any later version. -# -# HyperKitty is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -# more details. -# -# You should have received a copy of the GNU General Public License along with -# HyperKitty. If not, see <http://www.gnu.org/licenses/>. -# -# Author: Aamir Khan <syst3m.w0rm@gmail.com> -# - -from django.db import models -from django.contrib.auth.models import User -from django.conf import settings - -from kittystore.kittysastore import KittySAStore - -from gsoc.utils import log - -STORE = KittySAStore(settings.KITTYSTORE_URL) - - -class Rating(models.Model): - # @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) - - user = models.ForeignKey(User) - - 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) - - -class UserProfile(models.Model): - # User Object - user = models.OneToOneField(User) - - 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 = {} - - for vote in votes: - list_name = vote.list_address.split('@')[0] - message = STORE.get_email(list_name, vote.messageid) - vote.message = message - - return votes - - votes = property(_get_votes) - - def __unicode__(self): - """Unicode representation""" - return u'%s' % (unicode(self.user)) |