Example #1
0
def edit_description(photo_id):
    photo = Photo.query.get_or_404(photo_id)
    if current_user != photo.author and not current_user.can('MODERATE'):
        abort(403)
    form = DescriptionForm()
    if form.validate_on_submit():
        photo.description = form.description.data
        db.session.commit()
        flash('已更新图片描述', 'success')
    flash_errors(form)  #flash表单的错误
    return redirect(url_for('.show_photo', photo_id=photo_id))
Example #2
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')

    return redirect(url_for('main.show_photo', photo_id=photo_id))
Example #3
0
def edit_description(photo_id):
    photo = Photo.query.get_or_404(photo_id)
    if current_user != photo.author and not current_user.can("MODERATE"):
        abort(403)

    form = DescriptionForm()
    if form.validate_on_submit():
        photo.description = form.description.data
        db.session.commit()
        flash("Description updated.", "success")

    flash_errors(form)
    return redirect(url_for("main.show_photo", photo_id=photo.id))
Example #4
0
def edit_description(photo_id):
	"""
	编辑图片描述
	:param photo_id: 图片id
	"""
	logger.info('url = ' + str(request.url))
	photo = Photo.query.get_or_404(photo_id)
	if current_user != photo.author and not current_user.can("MODERATE"):
		abort(403)

	form = DescriptionForm()
	if form.validate_on_submit():
		photo.description = form.description.data
		logger.info('修改了图片id={}的描述={}'.format(photo_id, photo.description))
		db.session.commit()
		flash("描述更新成功!", "success")

	flash_errors(form)
	return redirect(url_for(".show_photo", photo_id=photo_id))