mirror of
https://github.com/StefBuwalda/cal_counter.git
synced 2025-10-29 19:00:00 +00:00
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.
28 lines
1.0 KiB
Python
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")
|