Esempio n. 1
0
 def delete(self):
     if hasattr(self.instance, 'set_votes'):
             self.instance.set_votes(-1)
     else:
         VoteCounter.increase_counter(self.instance.key(), -1)
     vote_deleted.send(self)
     super(Vote, self).delete()
Esempio n. 2
0
 def delete(self):
     if hasattr(self.instance, 'set_votes'):
         self.instance.set_votes(-1)
     else:
         VoteCounter.increase_counter(self.instance.key(), -1)
     vote_deleted.send(self)
     super(Vote, self).delete()
Esempio n. 3
0
 def do_vote(cls, user, instance, count=1):
     """
     Añade un voto de un usuario a una instancia
     
         :param user: usuario que realiza la votacion
         :type user: :class:`geouser.models.User`
         :param instance: objeto al que se vota
         :type instance: :class:`object`
         :param count: valoracion del voto
         :type count: :class:`integer`
         
         :returns: True si se realizo el voto, False si ya se habia votado
     """
     from signals import vote_new, vote_deleted
     count = int(count)
     vote = cls.objects.get_user_vote(user, instance.key())
     if vote is not None:
         if count < 0:
             vote = Vote.from_entity(vote)
             vote_deleted.send(sender=vote)
             vote.delete()
             return True
         return False
     vote = Vote(parent=instance, user=user, instance=instance, count=1)
     vote.put()
     vote_new.send(sender=vote)
     return True
Esempio n. 4
0
 def do_vote(cls, user, instance, count=1):
     """
     Añade un voto de un usuario a una instancia
     
         :param user: usuario que realiza la votacion
         :type user: :class:`geouser.models.User`
         :param instance: objeto al que se vota
         :type instance: :class:`object`
         :param count: valoracion del voto
         :type count: :class:`integer`
         
         :returns: True si se realizo el voto, False si ya se habia votado
     """
     from signals import vote_new, vote_deleted
     count = int(count)
     vote = cls.objects.get_user_vote(user, instance.key())
     if vote is not None:
         if count < 0:
             vote = Vote.from_entity(vote)
             vote_deleted.send(sender=vote)
             vote.delete()
             return True
         return False
     vote = Vote(parent=instance, user=user, instance=instance, count=1)
     vote.put()
     vote_new.send(sender=vote)
     return True