def delete_image(work_image_id): """删除作品图片""" work_image = WorkImage.query.get_or_404(work_image_id) permission = WorkImageAdminPermission(work_image_id) if not permission.check(): return permission.deny() db.session.delete(work_image) db.session.commit() return redirect(url_for('.view', work_id=work_image.work_id))
def edit_image(work_image_id): """编辑作品图片""" work_image = WorkImage.query.get_or_404(work_image_id) permission = WorkImageAdminPermission(work_image_id) if not permission.check(): return permission.deny() form = WorkImageForm(image=work_image.filename) if form.validate_on_submit(): is_original = True if form.is_original.data == 'yes' else False work_image.is_original = is_original work_image.filename = form.image.data db.session.add(work_image) db.session.commit() return redirect(url_for('.image', work_image_id=work_image_id)) return render_template('work/edit_image/edit_image.html', work_image=work_image, form=form)