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