fix medicine form owner
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2024-01-04 10:41:06 +01:00
parent a32b885a28
commit 5ecd5c4ee8

View File

@@ -54,7 +54,9 @@ class NewMedicineState(rx.State):
results = session.exec(statement)
self.medicine = results.first()
if self.medicine is not None:
self.medicine_name = f"{self.medicine.name} - {self.medicine.owner.name}"
self.medicine_name = (
f"{self.medicine.name} - {self.medicine.owner.name}"
)
@rx.background
async def do_scanning(self):
@@ -66,6 +68,14 @@ class NewMedicineState(rx.State):
async with self:
self.load_last_scan()
@rx.var
def owners(self):
with rx.session() as session:
statement = select(Owner)
results = session.exec(statement)
owners = results.all()
return [owner.name for owner in owners]
def do_show_med_add_form(self):
self.set_show_med_add_form(True)
@@ -106,72 +116,68 @@ class NewMedicineState(rx.State):
def new_medicine_form():
with rx.session() as session:
statement = select(Owner)
results = session.exec(statement)
owners = results.all()
return rx.vstack(
rx.form(
rx.vstack(
rx.input(
placeholder="Name",
name="name",
),
rx.input(
placeholder="Packungsgröße",
name="pkg_size",
),
rx.input(
placeholder="PZN",
name="pzn",
),
rx.select(
[owner.name for owner in owners],
placeholder="Für wen",
name="owner",
),
rx.hstack(
rx.text("Crontab lines für Einnahme"),
rx.popover(
rx.popover_trigger(rx.button("Help")),
rx.popover_content(
rx.popover_header("Crontab help"),
rx.popover_body(
rx.html("<pre>0 7 * * * </pre>"),
"Täglich sieben Uhr",
),
rx.popover_body(
rx.html("<pre>0 21 * * 0 </pre>"),
"Jeden Sonntag um 21:00 Uhr.",
),
rx.popover_body(
rx.html("<pre>0 7 * * 1-5 </pre>"),
"Montags bis Freitags jeweils um 07:00",
),
rx.popover_close_button(),
),
),
),
rx.text_area(name="schedule"),
rx.input(
value=NewMedicineState.last_scan_uuid,
name="uuid",
placeholder="UUID",
disabled=True,
),
rx.hstack(
rx.text("Gescannt:"),
rx.text(
NewMedicineState.last_scan_time,
),
),
rx.button("Submit", type_="submit"),
return rx.vstack(
rx.form(
rx.vstack(
rx.input(
placeholder="Name",
name="name",
),
on_submit=NewMedicineState.handle_submit,
reset_on_submit=True,
rx.input(
placeholder="Packungsgröße",
name="pkg_size",
),
rx.input(
placeholder="PZN",
name="pzn",
),
rx.select(
NewMedicineState.owners,
placeholder="Für wen",
name="owner",
),
rx.hstack(
rx.text("Crontab lines für Einnahme"),
rx.popover(
rx.popover_trigger(rx.button("Help")),
rx.popover_content(
rx.popover_header("Crontab help"),
rx.popover_body(
rx.html("<pre>0 7 * * * </pre>"),
"Täglich sieben Uhr",
),
rx.popover_body(
rx.html("<pre>0 21 * * 0 </pre>"),
"Jeden Sonntag um 21:00 Uhr.",
),
rx.popover_body(
rx.html("<pre>0 7 * * 1-5 </pre>"),
"Montags bis Freitags jeweils um 07:00",
),
rx.popover_close_button(),
),
),
),
rx.text_area(name="schedule"),
rx.input(
value=NewMedicineState.last_scan_uuid,
name="uuid",
placeholder="UUID",
disabled=True,
),
rx.hstack(
rx.text("Gescannt:"),
rx.text(
NewMedicineState.last_scan_time,
),
),
rx.button("Submit", type_="submit"),
),
rx.divider(),
)
on_submit=NewMedicineState.handle_submit,
reset_on_submit=True,
),
rx.divider(),
)
def taken_form():