def save(self, *args, **kwargs): cache.delete('link_%s' % self.pk) self.do_unique_slug() if not self.id: from resrc.utils.karma import karma_rate karma_rate(self.author_id, 1) cache.set('link_%s' % self.pk, self, 60 * 5) super(Link, self).save(*args, **kwargs)
def unvote(self, user): from resrc.vote.models import Vote Vote.objects.get(user=user, link=self).delete() if user.pk is not self.author.pk: # remove karma from link author if not voter from resrc.utils.karma import karma_rate karma_rate(self.author.pk, -1)
def save(self, *args, **kwargs): cache.delete('link_%s' % self.pk) self.do_unique_slug() if not self.id: from resrc.utils.karma import karma_rate karma_rate(self.author_id, 1) cache.set('link_%s' % self.pk, self, 60*5) super(Link, self).save(*args, **kwargs)
def vote(self, user): from resrc.vote.models import Vote vote = Vote.objects.create(user=user, link=None, alist=self) vote.save() if user.pk is not self.owner.pk: # add karma to list owner if not voter from resrc.utils.karma import karma_rate karma_rate(self.owner.pk, 1)
def save(self, *args, **kwargs): cache.delete('link_%s' % self.pk) self.do_unique_slug() if not self.id: from resrc.utils.karma import karma_rate karma_rate(self.author_id, 1) cache.set('link_%s' % self.pk, self, 60*5) from resrc.utils import construct_body if self.content in ['', None, 'REGEN']: construct_body.construct_body(self) super(Link, self).save(*args, **kwargs)
def save(self, *args, **kwargs): cache.delete('link_%s' % self.pk) self.do_unique_slug() if not self.id: from resrc.utils.karma import karma_rate karma_rate(self.author_id, 1) cache.set('link_%s' % self.pk, self, 60 * 5) from resrc.utils import construct_body if self.content in ['', None, 'REGEN']: construct_body.construct_body(self) super(Link, self).save(*args, **kwargs)
def vote(self, user): from resrc.vote.models import Vote vote = Vote.objects.create( user=user, link=None, alist=self ) vote.save() if user.pk is not self.owner.pk: # add karma to list owner if not voter from resrc.utils.karma import karma_rate karma_rate(self.owner.pk, 1)
def vote(self, user, list_pk=None): from resrc.vote.models import Vote # we keep track of list because if link is voted from a list, we also vote for the list if list_pk is not None: from resrc.list.models import List alist = get_object_or_404(List, pk=list_pk) else: alist = None vote = Vote.objects.create(user=user, link=self, alist=alist) vote.save() if user.pk is not self.author.pk: # add karma to link author if not voter from resrc.utils.karma import karma_rate karma_rate(self.author.pk, 1)
def vote(self, user, list_pk=None): from resrc.vote.models import Vote # we keep track of list because if link is voted from a list, we also vote for the list if list_pk is not None: from resrc.list.models import List alist = get_object_or_404(List, pk=list_pk) else: alist = None vote = Vote.objects.create( user=user, link=self, alist=alist ) vote.save() if user.pk is not self.author.pk: # add karma to link author if not voter from resrc.utils.karma import karma_rate karma_rate(self.author.pk, 1)