def delete(idol_id):

    follow = FollowerFollowing.get_or_none((FollowerFollowing.idol_id == idol_id) and (
        FollowerFollowing.fan_id == current_user.id))

    flash(f"You have unfollowed {follow.idol.name}")
    return redirect(url_for('users_show', username=follow.idol.name))
def delete(idol_id):

    follow = FollowerFollowing.get_or_none((FollowerFollowing.idols_id == idols_id) and (
        FollowerFollowing.fan_id == current_user.id))

    if follow.delete_instance():
        flash(f'You have unfollowed{follow.idol.username}')
        return redirect(url_for('users.show_feed', username=follow.idol.username))
Example #3
0
 def is_following(self, user):
     from models.follower_following import FollowerFollowing
     check_following = FollowerFollowing.get_or_none(
         (FollowerFollowing.fan_id == current_user.id)
         & (FollowerFollowing.idol_id == user.id))
     if check_following == None:
         return False
     else:
         return True
Example #4
0
def delete(id):
    unfollow = FollowerFollowing.get_or_none(
        idol_id=id, fan_id=current_user.id)

    if unfollow.delete_instance():
        flash("Bye bye ")
        return redirect(request.referrer)

    else:
        flash("you will be a follower forever")
        return render_template("users/index.html")
def delete(idol_id):
    idol = User.get_or_none(User.id == idol_id)
    unfollow = FollowerFollowing.get_or_none(fan_id=current_user.id,
                                             idol_id=idol.id)
    if unfollow.delete_instance():
        flash(f"Unfollowed {idol.username}")
        return redirect(url_for('home'))

    else:
        flash("Unfollow unsuccessful, guess you're forced to be a good person")
        return redirect(url_for('users.profile', id=idol.id))
    def is_approved(self, user):
        from models.follower_following import FollowerFollowing
        # user = FollowerFollowing.get_or_none(
        #     FollowerFollowing.idol_id == user.id)
        # fan = FollowerFollowing.get_or_none(
        #     FollowerFollowing.fan_id == self.id)
        x = FollowerFollowing.get_or_none(
            (FollowerFollowing.fan_id == self.id) & (FollowerFollowing.idol_id == user.id))
        #     return True
        # return False

        return True if (x.approved == True) else False
Example #7
0
def delete(idol_id):
    idol = FollowerFollowing.get_or_none(
        (FollowerFollowing.idol_id == idol_id)
        & (FollowerFollowing.fan_id == current_user.id))
    idol_info = User.get_by_id(idol_id)

    if idol.delete_instance():
        flash(f"You Just Unfollow {idol_info.name}")
    else:
        flash("Ops, Something Went Wrong.. ")

    return redirect(url_for('users.feed'))
def approve(fan_id):

    # ------GET THE INSTANCE AND SET APPROVED TO TRUE ---------------
    approved_follow = FollowerFollowing.get_or_none(
        (FollowerFollowing.idol_id == current_user.id) & (FollowerFollowing.fan_id == fan_id))

    if not approved_follow:
        flash(f"No relationship found", "error")
        return redirect(url_for('follows.review', user_id=current_user.id))

    if approved_follow.approved == False:
        approved_follow.approved = True
    else:
        approved_follow.approved = False

    if not approved_follow.save():
        flash(f"Could not approve follower", "error")
        return redirect(url_for('follows.review', user_id=current_user.id))

    else:
        flash(f"Sucessfully approved follower", "sucess")
        return redirect(url_for('follows.review', user_id=current_user.id))
 def is_following(self, user):
     from models.follower_following import FollowerFollowing
     return True if FollowerFollowing.get_or_none((FollowerFollowing.idol_id == user.id) & (FollowerFollowing.fan_id == self.id)) else False