Esempio n. 1
0
    def post(self, request, spot, username=None):
        if username is not None:
            return OutResponse.page_not_found()

        try:
            inUser = request.user
            inSpot = Spot.objects.get(id=spot)
        except ObjectDoesNotExist:
            return OutResponse.invalid_arguments()

        create = Favorites.create_favorite(inUser, inSpot)
        if not create:
            return OutResponse.entry_already_exists()

        return OutResponse.content_created(create)
Esempio n. 2
0
    def post(self, request,spot, username =None):
        if username is not None:
            return OutResponse.page_not_found()

        try:
            inUser = request.user
            inSpot = Spot.objects.get(id=spot)
        except ObjectDoesNotExist:
            return OutResponse.invalid_arguments()

        create = Favorites.create_favorite(inUser,inSpot)
        if not create:
            return OutResponse.entry_already_exists()

        return OutResponse.content_created(create)
Esempio n. 3
0
    def post(self, request, username):

        try:
            inUser = request.user
            otherUser = MyUser.objects.get(username=username)

            if inUser.username == username:
                return OutResponse.invalid_arguments()

        except ObjectDoesNotExist:
            return OutResponse.invalid_arguments()

        same_follow_relation = FollowerRelation.objects.filter(user_created=inUser, user_following=otherUser)
        if same_follow_relation.exists():
            return OutResponse.entry_already_exists()

        _status = FollowerRelation.do_follow(inUser,otherUser)

        return OutResponse.content_created(_status)
Esempio n. 4
0
    def post(self, request, username):

        try:
            inUser = request.user
            otherUser = MyUser.objects.get(username=username)

            if inUser.username == username:
                return OutResponse.invalid_arguments()

        except ObjectDoesNotExist:
            return OutResponse.invalid_arguments()

        same_follow_relation = FollowerRelation.objects.filter(
            user_created=inUser, user_following=otherUser)
        if same_follow_relation.exists():
            return OutResponse.entry_already_exists()

        _status = FollowerRelation.do_follow(inUser, otherUser)

        return OutResponse.content_created(_status)