def unfriend_bro(bro_id): bro_model = Bro.query.get(bro_id) if not bro_model: flash("Bro doesn't exist", 'error') return redirect(redirect_url('bro.list_bros')) current_user.unfriend(bro_model) db.session.commit() flash("Bro has been successfully unfriended", "info") return redirect(redirect_url('bro.list_bros'))
def unfriend(id): form = Form() if form.validate(): profile = Profile.query.get_or_404(id) try: current_user.unfriend(profile) except ValueError: abort(BAD_REQUEST_STATUS_CODE) db.session.commit() return redirect(url_for('bro.view_profile', id=id)) abort(BAD_REQUEST_STATUS_CODE)
def unfriend(username): user = Users.query.filter_by(username=username).first() if user is None: flash(f'User {username} could not be found.') return redirect(url_for('main.index')) if user == current_user: flash('You cannot unfriend yourself!') return redirect(url_for('main.index')) current_user.unfriend(user) db.session.commit() flash(f'You are no longer friends with {username}.') return redirect(url_for('main.profile', username=username))
def unfriend(username): user = User.query.filter_by(username=username).first() if user is None: flash('User {} not found.'.format(username)) return redirect(url_for('index')) if user == current_user: flash('You cannot unfriend yourself!') return redirect(url_for('user', username=username)) current_user.unfriend(user) db.session.commit() flash('You are not friends with {}.'.format(username)) return redirect(url_for('user', username=username))
def unfriend(user_id): user = User.query.filter_by(id=user_id).first() if user is None: flash('User {} not found.'.format(user_id)) return redirect(url_for('auth.index')) current_user.unfriend(user) db.session.commit() flash('You have unfriended {}'.format(user.username)) #next_page functionality sourced from: #https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-v-user-logins next_page = request.args.get('next') if not next_page or url_parse(next_page).netloc != '': next_page = url_for('auth.index') return redirect(next_page)
def unfriend(username): form = EmptyForm() if form.validate_on_submit(): user = User.query.filter_by(username=username).first() if user is None: flash('User {} not found.'.format(username)) return redirect(url_for('index')) if user == current_user: flash('You cannot unfollow yourself!') return redirect(url_for('user', username=username)) current_user.unfriend(user) db.session.commit() flash('You are not following {}.'.format(username)) return redirect(url_for('user', username=username)) else: return redirect(url_for('index'))
def unFriend(username): user = User.query.filter_by(username = username).first() deleteFriend = current_user.unfriend(user) declineFriend = user.unfriend(current_user) db.session.commit() flash('Friend removed!') return redirect(url_for('userProfile', username=username,user = user))
def unfriend(nickname): user = User.query.filter_by(username=nickname).first() u = current_user.unfriend(user) db.session.add(u) db.session.commit() flash('You have unfriended ' + nickname + '!', 'success') return redirect(url_for('users.friends', title='Friends', users=users))
def delete_friend(friend_id): friend = User.query.get(int(friend_id)) res = db.session.query(User, Friends).join( Friends, db.and_(Friends.user_id == current_user.id, Friends.friend_id == friend_id)).first() if res is None: return jsonify(response_message="Non siete ancora amici") message_property = current_user.last_message_property(friend) if not message_property: return jsonify( response_message= 'non puoi cancellare un legame di amicizia se non sei hai inviato per ultimo un ' 'messaggio sul canale di comunicazione') else: friend = User.query.get(int(friend_id)) current_user.delete_channel(friend) current_user.unfriend(friend) return jsonify(response_message="amicizia interrotta")
def unfriend(username): user = User.query.filter_by(username=username).first() if user is None: flash('Usuário %s não encontrado.' % username) return redirect(url_for('main.index')) if user == current_user: flash('Você não pode desfazer amizade consigo mesmo!') return redirect(url_for('users.account', username=username)) u = current_user.unfriend(user) if u is None: flash('Você e ' + username + ' não são amigos para desfazer uma amizade!') return redirect(url_for('users.account', username=username)) db.session.add(u) db.session.commit() flash('Você e ' + username + ' não são mais amigos!', 'success') return redirect(url_for('users.account', username=username))