-
Numberplates
-
-
-
-
- | ID |
- Numberplate |
-
-
-
- {% for plate in plates %}
-
- | {{ plate.id }} |
- {{ plate.plate }} |
-
- {% endfor %}
-
-
-
+
+
+
+
Numberplates
+
+
+
+
+ | ID |
+ Numberplate |
+
+
+
+ {% for plate in plates %}
+
+ | {{ plate.id }} |
+ {{ plate.plate }} |
+
+ Edit
+
+ |
+
+ {% endfor %}
+
+
+
diff --git a/application/dashboard/templates/edit.html b/application/dashboard/templates/edit.html
new file mode 100644
index 0000000..0354946
--- /dev/null
+++ b/application/dashboard/templates/edit.html
@@ -0,0 +1,110 @@
+{%extends 'base.html' %}
+{% block content %}
+
+
+
+
Numberplate
+
+
+
+
+
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/application/dashboard/views.py b/application/dashboard/views.py
index 6ee69f5..fb0c594 100644
--- a/application/dashboard/views.py
+++ b/application/dashboard/views.py
@@ -5,6 +5,8 @@ from flask import (
jsonify,
flash,
send_from_directory,
+ redirect,
+ url_for
)
from application.dashboard.models import AllowedPlate, LoggedItem
from application import db
@@ -15,7 +17,7 @@ dash_blueprint = Blueprint("dash", __name__, template_folder="templates")
@dash_blueprint.route("/dashboard")
-@login_required
+#@login_required
def dashboard():
Plates = AllowedPlate.query.all()
logs = (
@@ -25,7 +27,7 @@ def dashboard():
@dash_blueprint.route("/add", methods=["GET", "POST"])
-@login_required
+#@login_required
def add():
Plates = AllowedPlate.query.all()
form = npForm()
@@ -73,3 +75,36 @@ def live_image():
as_attachment=False,
conditional=True,
)
+
+
+@dash_blueprint.route('/logs', methods=['GET', 'POST'])
+#@login_required
+def logs():
+ form = LoggedItem.query.all()
+ return render_template("logs.html", form=form)
+
+@dash_blueprint.route("/edit/
",methods=["GET", "POST"])
+#login_required
+def edit(plate: str):
+ print(plate)
+ editnp = AllowedPlate.query.filter_by(plate=plate).first_or_404()
+ form = npForm()
+ if form.validate_on_submit():
+ commit = False
+ if editnp.plate != form.numberplate.data:
+ editnp.plate = form.numberplate.data
+ commit = True
+ if commit:
+ db.session.commit()
+ return redirect(url_for("dash.dashboard"))
+ form.numberplate.data = editnp.plate
+ return render_template("edit.html",form=form)
+
+@dash_blueprint.route("/delete/", methods=["POST"])
+#@login_required
+def delete_plate(plate: str):
+ plate_obj = AllowedPlate.query.filter_by(plate=plate).first_or_404()
+ db.session.delete(plate_obj)
+ db.session.commit()
+ flash("Numberplate deleted successfully.")
+ return redirect(url_for("dash.dashboard"))
\ No newline at end of file