Files
cal_counter/forms.py
Stef a6f6cdf346 Add manual food item entry and update food item management
Introduces a new route and template for manually adding food items. Updates food item edit and delete operations to use the food item's ID instead of barcode and adds ownership checks. Adjusts form and model to make barcode optional, and updates navigation and dashboard templates to reflect these changes.
2025-06-29 17:41:58 +02:00

28 lines
1.0 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 = IntegerField("Barcode", validators=[Optional()])
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")
submit = SubmitField("Add Item")