mirror of
https://github.com/StefBuwalda/cal_counter.git
synced 2025-10-30 03:10:00 +00:00
Introduces a new add_meal blueprint with routes and templates for scanning barcodes, adding new food items, and logging meals. Updates FoodItemForm and FoodLogForm validation, changes FoodLog.amount to float, and integrates the new workflow into the daily log UI. Refactors user routes and templates to support the new meal logging process.
35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
from flask_wtf import FlaskForm
|
|
from wtforms import (
|
|
StringField,
|
|
PasswordField,
|
|
SubmitField,
|
|
IntegerField,
|
|
FloatField,
|
|
)
|
|
from wtforms.validators import DataRequired, InputRequired, Optional
|
|
|
|
|
|
class LoginForm(FlaskForm):
|
|
username = StringField("Username", validators=[DataRequired()])
|
|
password = PasswordField("Password", validators=[DataRequired()])
|
|
submit = SubmitField("Login")
|
|
|
|
|
|
class FoodItemForm(FlaskForm):
|
|
barcode = StringField("Barcode", validators=[InputRequired()])
|
|
name = StringField("Product Name", validators=[DataRequired()])
|
|
energy = IntegerField("Energy per 100g", validators=[InputRequired()])
|
|
protein = FloatField("protein per 100g", validators=[InputRequired()])
|
|
carbs = FloatField("carbs per 100g", validators=[InputRequired()])
|
|
sugar = FloatField("sugar per 100g", validators=[Optional()])
|
|
fat = FloatField("fat per 100g", validators=[InputRequired()])
|
|
saturated_fat = FloatField(
|
|
"saturated_fat per 100g", validators=[Optional()]
|
|
)
|
|
submit = SubmitField("Add Item")
|
|
|
|
|
|
class FoodLogForm(FlaskForm):
|
|
amount = FloatField("amount of food (g/ml)", validators=[DataRequired()])
|
|
submit = SubmitField("Log Item")
|