Ejemplo n.º 1
0
class Vote(models.Model):
    user = models.ForeignKey(User)

    content_type = models.ForeignKey(ContentType)
    object_id = models.PositiveIntegerField()
    payload = generic.GenericForeignKey('content_type', 'object_id')
    # vote AKA direction.
    direction = models.IntegerField(choices=possible_votes.items(), default=1)
    time_stamp = models.DateTimeField(editable=False, default=datetime.now)
    # optional **kwargs
    is_archived = models.BooleanField(default=False)
    keep_private = models.BooleanField(default=False)
    api_interface = models.IntegerField(null=True,
                                        blank=True)  #key naar oauth consumer

    objects = VoteManager()
    parliament = ParliamentVoteManager()

    def __unicode__(self):
        return u"%s on %s  by %s" % (self.direction, self.payload,
                                     self.user.username)

    class Meta:
        db_table = 'votes'