def delete(id): idol = User.get_by_id(id) relationship = Relationship.delete().where( Relationship.fan == current_user.id, Relationship.idol == idol.id) relationship.execute() flash(f"Successfully unfollowed {idol.username}.", "primary") return redirect(url_for('users.show', username=idol.username))
def reject(id): fan = User.get_by_id(id) follower = Relationship.delete().where( Relationship.fan == id, Relationship.idol == current_user.id) if follower.execute(): flash(f"You reject {fan.username}'s following request.", 'primary') return redirect(url_for('users.show', username=current_user.username)) else: flash(f'Failed to approve request,try again later.', 'danger') return render_template('fanidols/show.html')