Browse Source

añadir la funcionalidad para que puedan remover una estación, no completo

Tatiana Castro 6 years ago
parent
commit
09beb21fbf
2 changed files with 55 additions and 0 deletions
  1. 27
    0
      app/admin_remove.py
  2. 28
    0
      app/templates/admin_remove.html

+ 27
- 0
app/admin_remove.py View File

@@ -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)

+ 28
- 0
app/templates/admin_remove.html View File

@@ -0,0 +1,28 @@
1
+{% extends 'base.html' %}
2
+
3
+{% block header %}
4
+    <h1>{% block title %}UPR Queue: Remove Station{% endblock %}</h1>
5
+{% endblock %}
6
+
7
+{% block content %}
8
+    <form action="" method="post">
9
+  		<input type="radio" onclick="javascript:addInformation();" name="check" id="what_to_delete" value="s_id"> Identificación de Station<br>
10
+  		<input type="radio" onclick="javascript:addInformation();" name="check" id="what_to_delete" value="nombre_empleado">  Nombre del Empleado<br>
11
+  		<input type="radio" onclick="javascript:addInformation();" name="check" id="what_to_delete" value="oficina"> Oficina<br>
12
+  		<input type="radio" onclick="javascript:addInformation();" name="check" id="what_to_delete" value="last_turn"> Ultimo turno<br>
13
+
14
+    <div id="showUp" style="visibility:hidden">
15
+        Escribe el valor por el quiere remover: <input type='text' id='value' name='value'><br>
16
+    </div>
17
+      {{ form.submit }}
18
+    </form>
19
+
20
+    <script>
21
+    function addInformation() {
22
+    if (document.getElementById('what_to_delete').checked) {
23
+        document.getElementById('showUp').style.visibility = 'visible';
24
+    else document.getElementById('showUp').style.visibility = 'hidden';
25
+     }
26
+    </script>
27
+
28
+{% endblock %}