mirror of
				https://github.com/StefBuwalda/cal_counter.git
				synced 2025-10-29 19:00:00 +00:00 
			
		
		
		
	Moved login route and logic from app.py to application/auth/routes.py under the 'auth' blueprint. Updated all references to the login route to use 'auth.login'. Added a dedicated login.html template under application/auth/templates. Adjusted login_required utility and default_return logic for consistency.
		
			
				
	
	
		
			56 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			56 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
| from flask_wtf import FlaskForm
 | |
| from wtforms import (
 | |
|     StringField,
 | |
|     PasswordField,
 | |
|     SubmitField,
 | |
|     FloatField,
 | |
| )
 | |
| from wtforms.validators import DataRequired, InputRequired, Optional
 | |
| 
 | |
| 
 | |
| class LoginForm(FlaskForm):
 | |
|     username = StringField("Username", validators=[DataRequired()])
 | |
|     password = PasswordField("Password", validators=[DataRequired()])
 | |
|     submit = SubmitField("auth.login")
 | |
| 
 | |
| 
 | |
| class FoodItemForm(FlaskForm):
 | |
|     barcode = StringField("Barcode", validators=[Optional()])
 | |
|     name = StringField("Product Name", validators=[DataRequired()])
 | |
|     energy = FloatField(
 | |
|         "Energy per 100g",
 | |
|         validators=[InputRequired()],
 | |
|         render_kw={"inputmode": "decimal"},
 | |
|     )
 | |
|     protein = FloatField(
 | |
|         "protein per 100g",
 | |
|         validators=[InputRequired()],
 | |
|         render_kw={"inputmode": "decimal"},
 | |
|     )
 | |
|     carbs = FloatField(
 | |
|         "carbs per 100g",
 | |
|         validators=[InputRequired()],
 | |
|         render_kw={"inputmode": "decimal"},
 | |
|     )
 | |
|     sugar = FloatField(
 | |
|         "sugar per 100g",
 | |
|         validators=[Optional()],
 | |
|         render_kw={"inputmode": "decimal"},
 | |
|     )
 | |
|     fat = FloatField(
 | |
|         "fat per 100g",
 | |
|         validators=[InputRequired()],
 | |
|         render_kw={"inputmode": "decimal"},
 | |
|     )
 | |
|     saturated_fat = FloatField(
 | |
|         "saturated_fat per 100g",
 | |
|         validators=[Optional()],
 | |
|         render_kw={"inputmode": "decimal"},
 | |
|     )
 | |
|     submit = SubmitField("Add Item")
 | |
| 
 | |
| 
 | |
| class FoodLogForm(FlaskForm):
 | |
|     amount = FloatField("amount of food (g/ml)", validators=[DataRequired()])
 | |
|     submit = SubmitField("Log Item")
 |