Esempio n. 1
0
def edit_description(photo_id):
    photo = Photo.query.get_or_404(photo_id)
    if current_user != photo.author:
        abort(403)

    form = DescriptionForm()
    if form.validate_on_submit():
        photo.description = form.description.data
        db.session.commit()
        flash('Description updated.', 'success')
    flash_error(form)
    return redirect(url_for('.show_photo', photo_id=photo_id))
Esempio n. 2
0
def show_photo(photo_id):
    photo = Photo.query.get_or_404(photo_id)
    page = request.args.get("page", 1, type=int)
    per_page = current_app.config['ALBUM_WALL_COMMENT_PER_PAGE']
    pagination = Comment.query.with_parent(photo).order_by(Comment.timestamp.desc()).paginate(page, per_page)
    comments = pagination.items

    comment_form = CommentForm()
    description_form = DescriptionForm()
    tag_form = TagForm()

    return render_template('main/photo.html', photo=photo, pagination=pagination, comments=comments,
                           comment_form=comment_form, description_form=description_form, tag_form=tag_form)