def admin_delete_post(permalink): post = db_accessor.get_post(permalink) result = db_accessor.delete_post(permalink) if result: return render_template('/admin/index.html', error=result) else: static_creator.delete_static_post(post) static_creator.update_static_indexes(db_accessor.get_posts()) return redirect(url_for('admin_index'))
def admin_save_post(): if request.method == 'POST': heroImage = request.files['heroimage'] # Check if the file is one of the allowed types/extensions if heroImage and allowed_file(heroImage.filename): # Make the filename safe, remove unsupported chars heroImage.filename = secure_filename(heroImage.filename) heroImage.fileending = heroImage.filename.rsplit('.', 1)[1].lower() result = db_accessor.add_post(request.form, heroImage) if result: return render_template('/admin/new.html', error=result) else: if heroImage and allowed_file(heroImage.filename): commons.saveHeroimage(request.form['permalink'], heroImage) static_creator.update_static_post(db_accessor.get_post(request.form['permalink'])) static_creator.update_static_indexes(db_accessor.get_posts()) return redirect(url_for('admin_index')) return render_template('/admin/new.html')