mirror of
https://github.com/StefBuwalda/cal_counter.git
synced 2025-10-30 11:19:59 +00:00
Squashed commit of the following:
commit 7fe30bfebf
Author: Stef <stbuwalda@gmail.com>
Date: Mon Aug 11 14:32:53 2025 +0200
Improve FoodItem uniqueness and add name constraint
Refactored add_meal routes to check for existing FoodItems by name or barcode and improved form handling. Made barcode optional in FoodItemForm. Added a unique constraint on (name, owner_id) for FoodItem in both the model and database migrations, while retaining the (barcode, owner_id) constraint. Updated FoodItem relationship to cascade deletes.
This commit is contained in:
2
forms.py
2
forms.py
@@ -16,7 +16,7 @@ class LoginForm(FlaskForm):
|
||||
|
||||
|
||||
class FoodItemForm(FlaskForm):
|
||||
barcode = StringField("Barcode", validators=[InputRequired()])
|
||||
barcode = StringField("Barcode", validators=[Optional()])
|
||||
name = StringField("Product Name", validators=[DataRequired()])
|
||||
energy = IntegerField("Energy per 100g", validators=[InputRequired()])
|
||||
protein = FloatField("protein per 100g", validators=[InputRequired()])
|
||||
|
||||
Reference in New Issue
Block a user