Beispiel #1
0
def unfollow(id):
    idol = User.get_by_id(id)
    fan_status = FanIdol.get(FanIdol.fan==current_user.id,FanIdol.idol==id)
    if idol.private == True:
        if fan_status.approved == True:
            fan = FanIdol.delete().where(FanIdol.fan==current_user.id,FanIdol.idol==idol.id)
            fan.execute()
            flash(f"Successfully unfollowed {idol.username}.","primary")
            return redirect(url_for('index'))
        else:
            fan = FanIdol.delete().where(FanIdol.fan==current_user.id,FanIdol.idol==idol.id)
            fan.execute()
            flash(f"Successfully cancelled your follow request of {idol.username}.","primary")
            return redirect(url_for('users.show',username=current_user.username))
    elif idol.private == False:
        fan = FanIdol.delete().where(FanIdol.fan==current_user.id,FanIdol.idol==idol.id)
        fan.execute()
        flash(f"Successfully unfollowed {idol.username}.","primary")
        return redirect(url_for('index'))
    else:
        flash(f"Failed to unfollow {idol.username}. Try again later.","danger")
        return redirect(url_for('index'))
Beispiel #2
0
 def unfollow(self,idol):
     from models.fanidol import FanIdol
     return FanIdol.delete().where(FanIdol.fan==self.id,FanIdol.idol==idol.id).execute()
Beispiel #3
0
 def unfollow(self, idol):
     from models.fanidol import FanIdol
     FanIdol.delete().where(self.id == FanIdol.fan
                            and idol == FanIdol.idol).execute()
     return True