From eba4c1a3113d24319bccc5c52d4d93838334bd31 Mon Sep 17 00:00:00 2001 From: Marius Peter Date: Sun, 3 Jul 2022 20:21:02 +0200 Subject: db now in models; modules. --- app/modules/ferti/forms.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'app/modules/ferti/forms.py') 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() + ] -- cgit v1.2.3