diff --git a/app.py b/app.py index 56ccf0f..44067d6 100644 --- a/app.py +++ b/app.py @@ -2,7 +2,7 @@ from application import app from application.api.views import api_blueprint from application.auth.views import auth_blueprint from application.dashboard.views import dash_blueprint -from flask import redirect, url_for +from flask import redirect, url_for, render_template app.register_blueprint(api_blueprint, url_prefix="/api") app.register_blueprint(auth_blueprint, url_prefix="/auth") @@ -16,4 +16,4 @@ def home(): if __name__ == "__main__": - app.run(host="192.168.137.1", port=2222, debug=True) + app.run(host="localhost", port=2222, debug=True) diff --git a/application/dashboard/forms.py b/application/dashboard/forms.py new file mode 100644 index 0000000..16254fe --- /dev/null +++ b/application/dashboard/forms.py @@ -0,0 +1,8 @@ +from flask_wtf import FlaskForm +from wtforms.validators import DataRequired +from wtforms import StringField, SubmitField +from application import db + +class npForm(FlaskForm): + numberplate = StringField('add a numberplate', validators=[DataRequired()]) + submit = SubmitField('Submit') diff --git a/application/dashboard/templates/add.html b/application/dashboard/templates/add.html new file mode 100644 index 0000000..706cb22 --- /dev/null +++ b/application/dashboard/templates/add.html @@ -0,0 +1,23 @@ +{%extends 'base.html' %} +{% block content %} + +
+
+
+
Add numberplate
+
+
+ {{ form.hidden_tag() }} +
+ {{ form.numberplate.label }} {{ form.numberplate(class="form-input") }} +
+
+ {{ form.submit(class="submit-btn") }} +
+
+
+
+
+
+ +{% endblock %} \ No newline at end of file diff --git a/application/dashboard/templates/base.html b/application/dashboard/templates/base.html index dc98cae..de2d2a7 100644 --- a/application/dashboard/templates/base.html +++ b/application/dashboard/templates/base.html @@ -18,9 +18,12 @@
@@ -33,6 +36,7 @@

Dashboard

+ {%block content%} {% endblock %} diff --git a/application/dashboard/templates/dashboard.html b/application/dashboard/templates/dashboard.html index 9abe40c..4677a43 100644 --- a/application/dashboard/templates/dashboard.html +++ b/application/dashboard/templates/dashboard.html @@ -15,13 +15,13 @@ - {% for log in recent_logs %} + {% for form in recent_logs %} - {{ log.timestamp.strftime('%H:%M:%S') }} - {{ log.action }} + {{ form.timestamp.strftime('%H:%M:%S') }} + {{ form.plate }} - {{ log.status }} + {{ form.allowed }} diff --git a/application/dashboard/views.py b/application/dashboard/views.py index eaa1e36..4a18379 100644 --- a/application/dashboard/views.py +++ b/application/dashboard/views.py @@ -1,3 +1,33 @@ -from flask import Blueprint +from flask import Blueprint, render_template +from flask_login import login_required +from application.models import AllowedPlate, LoggedItem +from application import db, app +from application.dashboard.forms import npForm dash_blueprint = Blueprint("dash", __name__, template_folder="templates") + + + +@dash_blueprint.route('/dashboard') +#@login_required +def dashboard(): + form = LoggedItem.query.all() + return render_template("dashboard.html", form=form) + +@dash_blueprint.route('/add', methods=['GET', 'POST']) +#@login_required +def add(): + + form = npForm() + + if form.validate_on_submit(): + if form.numberplate.data: + print(form.numberplate.data) + ap = AllowedPlate(plate=form.numberplate.data) + + db.session.add(ap) + db.session.commit() + + + + return render_template("add.html", form=form) \ No newline at end of file