コード例 #1
0
    def add_follower(self, follower, followee):
        """ Create 'follower' follows 'followee' relationship """
        relation = Follow.objects.create(follower=follower, followee=followee)

        follower_created.send(sender=self, follower=follower)
        following_created.send(sender=self, follow=followee)

        bust_cache('followers', followee.pk)
        bust_cache('following', follower.pk)

        return relation
コード例 #2
0
    def add_follower(self, follower, followee):
        """ Create 'follower' follows 'followee' relationship """
        relation = Follow.objects.create(follower=follower, followee=followee)

        follower_created.send(sender=self, follower=follower)
        following_created.send(sender=self, follow=followee)

        bust_cache('followers', followee.pk)
        bust_cache('following', follower.pk)

        return relation
コード例 #3
0
ファイル: models.py プロジェクト: ziweizhou/django-friendship
 def add_follower(self, follower, followee):
     """ Create 'follower' follows 'followee' relationship """
     if follower == followee:
         raise ValidationError("Users cannot follow themselves")
         
     relation,created = Follow.objects.get_or_create(follower=follower, followee=followee)
     if created:
         follower_created.send(sender=self, follower=follower,followee=followee)
         following_created.send(sender=self, follower=follower,followee=followee)
         bust_cache('followers', followee.pk)
         bust_cache('following', follower.pk)
     
     return relation
コード例 #4
0
ファイル: models.py プロジェクト: kanimozhimurugan/Nxt4
    def add_follower(self, follower, followee):
        """ Create 'follower' follows 'followee' relationship """
        if follower == followee:
            raise ValidationError("Users cannot follow themselves")

        relation, created = Follow.objects.get_or_create(follower=follower, followee=followee)

        if created is False:
            raise AlreadyExistsError("User '%s' already follows '%s'" % (follower, followee))

        follower_created.send(sender=self, follower=follower)
        following_created.send(sender=self, follow=followee)

        bust_cache('followers', followee.pk)
        bust_cache('following', follower.pk)

        return relation
コード例 #5
0
ファイル: models.py プロジェクト: nebesite/django-friendship
    def add_follower(self, follower, followee):
        """ Create 'follower' follows 'followee' relationship """
        if follower == followee:
            raise ValidationError("Users cannot follow themselves")

        relation, created = Follow.objects.get_or_create(follower=follower, followee=followee)

        if created is False:
            raise AlreadyExistsError("User '%s' already follows '%s'" % (follower, followee))

        follower_created.send(sender=self, follower=follower)
        following_created.send(sender=self, follow=followee)

        bust_cache("followers", followee.pk)
        bust_cache("following", follower.pk)

        return relation