コード例 #1
0
 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)
コード例 #2
0
ファイル: models.py プロジェクト: 1000YARDSTARE/resrc
    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)
コード例 #3
0
    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)
コード例 #4
0
ファイル: models.py プロジェクト: Nodraak/resrc
 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)
コード例 #5
0
    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)
コード例 #6
0
ファイル: models.py プロジェクト: 1000YARDSTARE/resrc
 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)
コード例 #7
0
 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)
コード例 #8
0
ファイル: models.py プロジェクト: AJseesit/resrc
    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)
コード例 #9
0
    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)
コード例 #10
0
ファイル: models.py プロジェクト: 1000YARDSTARE/resrc
    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)