summaryrefslogtreecommitdiff
path: root/app/modules/ferti
diff options
context:
space:
mode:
authorMarius Peter <marius.peter@tutanota.com>2022-07-03 20:21:02 +0200
committerMarius Peter <marius.peter@tutanota.com>2022-07-03 20:21:02 +0200
commiteba4c1a3113d24319bccc5c52d4d93838334bd31 (patch)
treefe95881d42a0b4191a9371f82eaf66b9390af047 /app/modules/ferti
parent5160b8a3ac9fc27c2b31206aed735a15de0099e9 (diff)
db now in models; modules.
Diffstat (limited to 'app/modules/ferti')
-rw-r--r--app/modules/ferti/forms.py21
-rw-r--r--app/modules/ferti/routes.py7
2 files changed, 15 insertions, 13 deletions
diff --git a/app/modules/ferti/forms.py b/app/modules/ferti/forms.py
index d926931..1e25ec3 100644
--- a/app/modules/ferti/forms.py
+++ b/app/modules/ferti/forms.py
@@ -12,13 +12,10 @@ from wtforms import (
)
from wtforms.validators import InputRequired, Length, NumberRange
+from ...models import FertiLog
+
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)
@@ -39,9 +36,15 @@ class AddFertiLog(FlaskForm):
class AddFertiTarget(AddFertiLog):
- targeted_log = SelectField(
- "Log to target",
- choices=[("value1", "Last"), ("value2", "Named")],
+ target_id = SelectField(
+ "Target log",
+ choices=[],
validators=[InputRequired()],
)
- submit = SubmitField("Add/Update Log")
+ submit = SubmitField("Add target")
+
+ def __init__(self, **kwargs):
+ super().__init__()
+ self.target_id.choices = [
+ (target.primary_key, target.date_time_created) for target in FertiLog.query.all()
+ ]
diff --git a/app/modules/ferti/routes.py b/app/modules/ferti/routes.py
index b3bb03f..c0f3ab5 100644
--- a/app/modules/ferti/routes.py
+++ b/app/modules/ferti/routes.py
@@ -21,7 +21,7 @@ import inspect
-from ... import db
+# from ... import db
from ...models import *
from .forms import *
@@ -34,11 +34,10 @@ ferti = Blueprint("ferti", __name__)
@login_required
def view():
modules = Module.query.all()
- logs = Fertilog.query.order_by(Fertilog.primary_key.desc()).all()
- targets = Fertitarget.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,
Copyright 2019--2024 Marius PETER