diff options
author | Marius Peter <marius.peter@tutanota.com> | 2022-05-15 13:17:35 +0200 |
---|---|---|
committer | Marius Peter <marius.peter@tutanota.com> | 2022-05-15 13:17:35 +0200 |
commit | e084f90c19e779592f6e3f14eb8f70a7287f0dad (patch) | |
tree | 1215177356105452c39a916fd050f79c9721f523 /app/modules/ferti | |
parent | 1dad22d3e45d6506c8624e3a7111240fcc4ab786 (diff) |
Modularization.
Diffstat (limited to 'app/modules/ferti')
-rw-r--r-- | app/modules/ferti/forms.py | 47 | ||||
-rw-r--r-- | app/modules/ferti/routes.py | 46 |
2 files changed, 93 insertions, 0 deletions
diff --git a/app/modules/ferti/forms.py b/app/modules/ferti/forms.py new file mode 100644 index 0000000..d926931 --- /dev/null +++ b/app/modules/ferti/forms.py @@ -0,0 +1,47 @@ +from flask_wtf import FlaskForm +from wtforms import ( + SubmitField, + SelectField, + HiddenField, + StringField, + PasswordField, + IntegerField, + FloatField, + BooleanField, + DateTimeField, +) +from wtforms.validators import InputRequired, Length, NumberRange + + +class AddFertiLog(FlaskForm): + target = SelectField( + "Type", + choices=[("False", "Log"), ("True", "Target")], + validators=[InputRequired()], + ) + nno3 = FloatField("NNO3", default=0) + p = FloatField("P", default=0) + k = FloatField("K", default=0) + ca = FloatField("Ca", default=0) + mg = FloatField("Mg", default=0) + s = FloatField("S", default=0) + na = FloatField("Na", default=0) + cl = FloatField("Cl", default=0) + fe = FloatField("Fe", default=0) + zn = FloatField("Zn", default=0) + b = FloatField("B", default=0) + mn = FloatField("Mn", default=0) + cu = FloatField("Cu", default=0) + mo = FloatField("Mo", default=0) + si = FloatField("Si", default=0) + nnh4 = FloatField("NNH4", default=0) + submit = SubmitField("Add/Update Log") + + +class AddFertiTarget(AddFertiLog): + targeted_log = SelectField( + "Log to target", + choices=[("value1", "Last"), ("value2", "Named")], + validators=[InputRequired()], + ) + submit = SubmitField("Add/Update Log") diff --git a/app/modules/ferti/routes.py b/app/modules/ferti/routes.py new file mode 100644 index 0000000..b3bb03f --- /dev/null +++ b/app/modules/ferti/routes.py @@ -0,0 +1,46 @@ +# -*- mode: python; -*- + + +from flask import ( + Blueprint, + render_template, + send_file, + request, + redirect, + flash, + url_for, + jsonify, + abort, +) +from flask_login import login_required, current_user + + +# from datetime import datetime +import inspect + + + + +from ... import db +from ...models import * +from .forms import * + + +ferti = Blueprint("ferti", __name__) + + + +@ferti.route("/modules/ferti") +@login_required +def view(): + modules = Module.query.all() + logs = Fertilog.query.order_by(Fertilog.primary_key.desc()).all() + targets = Fertitarget.query.all() + module = "ferti" + flash(f"Latest target is {targets}.", "info") + flash(f"Still fighting against styling in {module}.", "error") + return render_template( + f"modules/{module}.html", + modules=modules, + logs=logs, + ) |