mirror of
https://github.com/sstent/foodplanner.git
synced 2026-01-25 03:01:35 +00:00
updated the tracker to have more features
This commit is contained in:
@@ -290,7 +290,7 @@ async def detailed(request: Request, person: str = "Sarah", plan_date: str = Non
|
||||
|
||||
context = {
|
||||
"request": request,
|
||||
"title": f"{person}'s Detailed Plan for {plan_date_obj.strftime('%B %d, %Y')}",
|
||||
"title": f"Detailed Plan for {person} on {plan_date_obj.strftime('%B %d, %Y')}" if person else "Detailed View",
|
||||
"meal_details": meal_details,
|
||||
"day_totals": day_totals,
|
||||
"person": person,
|
||||
|
||||
@@ -87,7 +87,7 @@ async def tracker_add_meal(request: Request, db: Session = Depends(get_db)):
|
||||
date_str = form_data.get("date")
|
||||
meal_id = form_data.get("meal_id")
|
||||
meal_time = form_data.get("meal_time")
|
||||
quantity = float(form_data.get("quantity", 1.0))
|
||||
quantity = 1.0 # Default quantity to 1.0 as the field is removed from the UI
|
||||
|
||||
logging.info(f"DEBUG: Adding meal to tracker - person={person}, date={date_str}, meal_id={meal_id}, meal_time={meal_time}, quantity={quantity}")
|
||||
|
||||
|
||||
@@ -37,9 +37,6 @@
|
||||
<button class="btn btn-primary" onclick="applyTemplate()">
|
||||
<i class="bi bi-upload"></i> Apply Template
|
||||
</button>
|
||||
<button class="btn btn-info text-white" onclick="addSingleFood()">
|
||||
<i class="bi bi-plus-circle"></i> Add Single Food
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Meal Times -->
|
||||
@@ -69,10 +66,10 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
<div>
|
||||
<button class="btn btn-sm btn-outline-secondary me-1" onclick="editTrackedMeal({{ tracked_meal.id }})" title="Edit Meal">
|
||||
<button class="btn btn-sm btn-outline-secondary me-1" onclick="editTrackedMeal('{{ tracked_meal.id }}')" title="Edit Meal">
|
||||
<i class="bi bi-pencil"></i>
|
||||
</button>
|
||||
<button class="btn btn-sm btn-outline-danger" onclick="removeMeal({{ tracked_meal.id }})">
|
||||
<button class="btn btn-sm btn-outline-danger" onclick="removeMeal('{{ tracked_meal.id }}')">
|
||||
<i class="bi bi-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
@@ -101,9 +98,14 @@
|
||||
</div>
|
||||
|
||||
<!-- Add Meal Button -->
|
||||
<button class="btn btn-sm btn-outline-success mt-2" onclick="addMealToTime('{{ meal_time }}')">
|
||||
<i class="bi bi-plus"></i> Add Meal
|
||||
</button>
|
||||
<div class="d-flex gap-2 mt-2">
|
||||
<button class="btn btn-sm btn-outline-success" onclick="addMealToTime('{{ meal_time }}')">
|
||||
<i class="bi bi-plus"></i> Add Meal
|
||||
</button>
|
||||
<button class="btn btn-sm btn-info text-white" onclick="addSingleFoodToTime('{{ meal_time }}')">
|
||||
<i class="bi bi-plus-circle"></i> Add Food
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
@@ -193,10 +195,6 @@
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Quantity (multiplier)</label>
|
||||
<input type="number" step="0.1" class="form-control" name="quantity" value="1.0" min="0.1">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
@@ -317,7 +315,7 @@
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Quantity</label>
|
||||
<label class="form-label">Quantity (g)</label>
|
||||
<input type="number" step="0.1" class="form-control" name="quantity" value="1.0" min="0.1" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
@@ -637,12 +635,13 @@
|
||||
}).catch(error => console.error('Error updating quantity:', error));
|
||||
}
|
||||
});
|
||||
|
||||
// Show add single food modal
|
||||
function addSingleFood() {
|
||||
// Show add single food modal and pre-select meal time
|
||||
function addSingleFoodToTime(mealTime) {
|
||||
document.querySelector('#addSingleFoodModal select[name="meal_time"]').value = mealTime;
|
||||
new bootstrap.Modal(document.getElementById('addSingleFoodModal')).show();
|
||||
}
|
||||
|
||||
|
||||
// Submit add single food form
|
||||
async function submitAddSingleFood() {
|
||||
const form = document.getElementById('addSingleFoodForm');
|
||||
|
||||
@@ -43,7 +43,7 @@ def client_fixture(session):
|
||||
def test_detailed_page_no_params(client):
|
||||
response = client.get("/detailed")
|
||||
assert response.status_code == 200
|
||||
assert "Detailed View for" in response.text
|
||||
assert "Detailed Plan for Sarah" in response.text
|
||||
|
||||
|
||||
def test_detailed_page_default_date(client, session):
|
||||
|
||||
Reference in New Issue
Block a user