No Description

admin_remove.py 797B

123456789101112131415161718192021222324252627
  1. from flask import (
  2. Blueprint, flash, g, redirect, render_template, request, url_for
  3. )
  4. from werkzeug.exceptions import abort
  5. from app.db import get_db
  6. from app.forms import StationForm
  7. bp = Blueprint('admin_remove', __name__)
  8. @bp.route('/admin_remove', methods=('GET', 'POST'))
  9. def admin_remove():
  10. form = StationForm()
  11. if form.validate_on_submit():
  12. valueToDelete = request.form['value']
  13. delete_id=request.form['what_to_delete']
  14. db = get_db()
  15. db.execute(
  16. 'DELETE FROM station WHERE'+delete_id+' = ?', (valueToDelete,)
  17. )
  18. db.commit()
  19. flash('Removed station for ' + delete_id +' with value '+ valueToDelete)
  20. return redirect(url_for('admin_remove'))
  21. return render_template('admin_remove.html', form=form)