def unfollow(username): form = EmptyForm() if form.validate_on_submit(): user = User.query.filter_by(username=username).first() if user is None: flash(u'Nie znaleziono użytkownika: {} '.format(username)) return redirect(url_for('index')) if user == current_user: flash(u'Nie możesz przestać śledzić samego siebie.') return redirect(url_for('user', username=username)) current_user.unfollow(user) db.session.commit() flash(u'Nie obserwujesz użytkownika {}.'.format(username)) return redirect(url_for('user', username=username)) else: return redirect(url_for('index'))
def user(username): user = User.query.filter_by(username=username).first_or_404() page = request.args.get('page', 1, type=int) posts = user.posts.order_by(Post.timestamp.desc()).paginate( page, app.config['POST_PER_PAGE'], False) next_url = url_for('user', username=user.username, page=posts.next_num) \ if posts.has_next else None prev_url = url_for('user', username=user.username, page=posts.prev_num) \ if posts.has_prev else None form = EmptyForm() return render_template('user.html', user=user, posts=posts.items, next_url=next_url, prev_url=prev_url, form=form)
def app_button(): form = EmptyForm() if form.validate_on_submit(): return redirect(url_for('index'))
def devops(): form = EmptyForm() return render_template('devops.html', title="CI/CD", form=form)
def edit_button(username): form = EmptyForm() if form.validate_on_submit(): user = User.query.filter_by(username=username).first() if user == current_user: return redirect(url_for('edit_profile'))