Ejemplo n.º 1
0
    def toggle_following_repo(self, follow_repo_id, user_id):

        f = self.sa.query(UserFollowing)\
            .filter(UserFollowing.follows_repo_id == follow_repo_id)\
            .filter(UserFollowing.user_id == user_id).scalar()

        if f is not None:
            try:
                self.sa.delete(f)
                action_logger(UserTemp(user_id),
                              'stopped_following_repo',
                              RepoTemp(follow_repo_id))
                return
            except Exception:
                log.error(traceback.format_exc())
                raise

        try:
            f = UserFollowing()
            f.user_id = user_id
            f.follows_repo_id = follow_repo_id
            self.sa.add(f)

            action_logger(UserTemp(user_id),
                          'started_following_repo',
                          RepoTemp(follow_repo_id))
        except Exception:
            log.error(traceback.format_exc())
            raise
Ejemplo n.º 2
0
    def toggle_following_repo(self, follow_repo_id, user_id):

        f = UserFollowing.query() \
            .filter(UserFollowing.follows_repository_id == follow_repo_id) \
            .filter(UserFollowing.user_id == user_id).scalar()

        if f is not None:
            try:
                Session().delete(f)
                action_logger(UserTemp(user_id), 'stopped_following_repo',
                              RepoTemp(follow_repo_id))
                return
            except Exception:
                log.error(traceback.format_exc())
                raise

        try:
            f = UserFollowing()
            f.user_id = user_id
            f.follows_repository_id = follow_repo_id
            Session().add(f)

            action_logger(UserTemp(user_id), 'started_following_repo',
                          RepoTemp(follow_repo_id))
        except Exception:
            log.error(traceback.format_exc())
            raise
Ejemplo n.º 3
0
    def toggle_following_user(self, follow_user_id, user_id):
        f = self.sa.query(UserFollowing)\
            .filter(UserFollowing.follows_user_id == follow_user_id)\
            .filter(UserFollowing.user_id == user_id).scalar()

        if f is not None:
            try:
                self.sa.delete(f)
                return
            except Exception:
                log.error(traceback.format_exc())
                raise

        try:
            f = UserFollowing()
            f.user_id = user_id
            f.follows_user_id = follow_user_id
            self.sa.add(f)
        except Exception:
            log.error(traceback.format_exc())
            raise
Ejemplo n.º 4
0
    def toggle_following_user(self, follow_user_id, user_id):
        f = UserFollowing.query() \
            .filter(UserFollowing.follows_user_id == follow_user_id) \
            .filter(UserFollowing.user_id == user_id).scalar()

        if f is not None:
            try:
                Session().delete(f)
                return
            except Exception:
                log.error(traceback.format_exc())
                raise

        try:
            f = UserFollowing()
            f.user_id = user_id
            f.follows_user_id = follow_user_id
            Session().add(f)
        except Exception:
            log.error(traceback.format_exc())
            raise