mirror of
https://github.com/sstent/foodplanner.git
synced 2026-02-18 00:35:23 +00:00
sync - added week menus
This commit is contained in:
10
main.py
10
main.py
@@ -74,7 +74,7 @@ class Plan(Base):
|
|||||||
__tablename__ = "plans"
|
__tablename__ = "plans"
|
||||||
|
|
||||||
id = Column(Integer, primary_key=True, index=True)
|
id = Column(Integer, primary_key=True, index=True)
|
||||||
person = Column(String, index=True) # Person A or Person B
|
person = Column(String, index=True) # Sarah or Stuart
|
||||||
date = Column(Date, index=True) # Store actual calendar dates
|
date = Column(Date, index=True) # Store actual calendar dates
|
||||||
meal_id = Column(Integer, ForeignKey("meals.id"))
|
meal_id = Column(Integer, ForeignKey("meals.id"))
|
||||||
meal_time = Column(String) # Breakfast, Lunch, Dinner, Snack 1, Snack 2, Beverage 1, Beverage 2
|
meal_time = Column(String) # Breakfast, Lunch, Dinner, Snack 1, Snack 2, Beverage 1, Beverage 2
|
||||||
@@ -126,7 +126,7 @@ class TrackedDay(Base):
|
|||||||
__tablename__ = "tracked_days"
|
__tablename__ = "tracked_days"
|
||||||
|
|
||||||
id = Column(Integer, primary_key=True, index=True)
|
id = Column(Integer, primary_key=True, index=True)
|
||||||
person = Column(String, index=True) # Person A or Person B
|
person = Column(String, index=True) # Sarah or Stuart
|
||||||
date = Column(Date, index=True) # Date being tracked
|
date = Column(Date, index=True) # Date being tracked
|
||||||
is_modified = Column(Boolean, default=False) # Whether this day has been modified from original plan
|
is_modified = Column(Boolean, default=False) # Whether this day has been modified from original plan
|
||||||
|
|
||||||
@@ -928,7 +928,7 @@ async def delete_meals(meal_ids: dict = Body(...), db: Session = Depends(get_db)
|
|||||||
|
|
||||||
# Plan tab
|
# Plan tab
|
||||||
@app.get("/plan", response_class=HTMLResponse)
|
@app.get("/plan", response_class=HTMLResponse)
|
||||||
async def plan_page(request: Request, person: str = "Person A", week_start_date: str = None, db: Session = Depends(get_db)):
|
async def plan_page(request: Request, person: str = "Sarah", week_start_date: str = None, db: Session = Depends(get_db)):
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
# If no week_start_date provided, use current week starting from Monday
|
# If no week_start_date provided, use current week starting from Monday
|
||||||
@@ -1095,7 +1095,7 @@ async def remove_from_plan(plan_id: int, db: Session = Depends(get_db)):
|
|||||||
return {"status": "error", "message": str(e)}
|
return {"status": "error", "message": str(e)}
|
||||||
|
|
||||||
@app.get("/detailed", response_class=HTMLResponse)
|
@app.get("/detailed", response_class=HTMLResponse)
|
||||||
async def detailed(request: Request, person: str = "Person A", plan_date: str = None, template_id: int = None, db: Session = Depends(get_db)):
|
async def detailed(request: Request, person: str = "Sarah", plan_date: str = None, template_id: int = None, db: Session = Depends(get_db)):
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
if template_id:
|
if template_id:
|
||||||
@@ -1458,7 +1458,7 @@ async def delete_weekly_menu(weekly_menu_id: int, db: Session = Depends(get_db))
|
|||||||
|
|
||||||
# Tracker tab
|
# Tracker tab
|
||||||
@app.get("/tracker", response_class=HTMLResponse)
|
@app.get("/tracker", response_class=HTMLResponse)
|
||||||
async def tracker_page(request: Request, person: str = "Person A", date: str = None, db: Session = Depends(get_db)):
|
async def tracker_page(request: Request, person: str = "Sarah", date: str = None, db: Session = Depends(get_db)):
|
||||||
from datetime import datetime, date as date_type
|
from datetime import datetime, date as date_type
|
||||||
|
|
||||||
# If no date provided, use today
|
# If no date provided, use today
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class TrackedDay(Base):
|
|||||||
__tablename__ = "tracked_days"
|
__tablename__ = "tracked_days"
|
||||||
|
|
||||||
id = Column(Integer, primary_key=True, index=True)
|
id = Column(Integer, primary_key=True, index=True)
|
||||||
person = Column(String, index=True) # Person A or Person B
|
person = Column(String, index=True) # Sarah or Stuart
|
||||||
date = Column(Date, index=True) # Date being tracked
|
date = Column(Date, index=True) # Date being tracked
|
||||||
|
|
||||||
class TrackedMeal(Base):
|
class TrackedMeal(Base):
|
||||||
|
|||||||
@@ -47,8 +47,8 @@
|
|||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="person-toggle">
|
<div class="person-toggle">
|
||||||
<select id="personSelect" class="form-select" onchange="switchPerson()">
|
<select id="personSelect" class="form-select" onchange="switchPerson()">
|
||||||
<option value="Person A" {% if person == "Person A" %}selected{% endif %}>Person A</option>
|
<option value="Sarah" {% if person == "Sarah" %}selected{% endif %}>Sarah</option>
|
||||||
<option value="Person B" {% if person == "Person B" %}selected{% endif %}>Person B</option>
|
<option value="Stuart" {% if person == "Stuart" %}selected{% endif %}>Stuart</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -104,6 +104,7 @@
|
|||||||
<script>
|
<script>
|
||||||
function switchPerson() {
|
function switchPerson() {
|
||||||
const person = document.getElementById('personSelect').value;
|
const person = document.getElementById('personSelect').value;
|
||||||
|
localStorage.setItem('selectedPerson', person);
|
||||||
const currentUrl = new URL(window.location);
|
const currentUrl = new URL(window.location);
|
||||||
currentUrl.searchParams.set('person', person);
|
currentUrl.searchParams.set('person', person);
|
||||||
window.location.href = currentUrl.toString();
|
window.location.href = currentUrl.toString();
|
||||||
@@ -111,6 +112,15 @@
|
|||||||
|
|
||||||
// Set active tab based on current URL
|
// Set active tab based on current URL
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
// Set person selection from localStorage if available
|
||||||
|
const savedPerson = localStorage.getItem('selectedPerson');
|
||||||
|
if (savedPerson) {
|
||||||
|
const personSelect = document.getElementById('personSelect');
|
||||||
|
if (personSelect) {
|
||||||
|
personSelect.value = savedPerson;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const currentPath = window.location.pathname;
|
const currentPath = window.location.pathname;
|
||||||
const tabs = document.querySelectorAll('.nav-link');
|
const tabs = document.querySelectorAll('.nav-link');
|
||||||
|
|
||||||
|
|||||||
@@ -34,8 +34,8 @@
|
|||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="person-toggle">
|
<div class="person-toggle">
|
||||||
<select id="personSelect" class="form-select" onchange="switchPerson()">
|
<select id="personSelect" class="form-select" onchange="switchPerson()">
|
||||||
<option value="Person A" {% if person == "Person A" %}selected{% endif %}>Person A</option>
|
<option value="Sarah" {% if person == "Sarah" %}selected{% endif %}>Sarah</option>
|
||||||
<option value="Person B" {% if person == "Person B" %}selected{% endif %}>Person B</option>
|
<option value="Stuart" {% if person == "Stuart" %}selected{% endif %}>Stuart</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -65,6 +65,7 @@
|
|||||||
<script>
|
<script>
|
||||||
function switchPerson() {
|
function switchPerson() {
|
||||||
const person = document.getElementById('personSelect').value;
|
const person = document.getElementById('personSelect').value;
|
||||||
|
localStorage.setItem('selectedPerson', person);
|
||||||
const currentUrl = new URL(window.location);
|
const currentUrl = new URL(window.location);
|
||||||
currentUrl.searchParams.set('person', person);
|
currentUrl.searchParams.set('person', person);
|
||||||
window.location.href = currentUrl.toString();
|
window.location.href = currentUrl.toString();
|
||||||
|
|||||||
@@ -162,8 +162,8 @@
|
|||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="person" class="form-label">Person</label>
|
<label for="person" class="form-label">Person</label>
|
||||||
<select class="form-control" id="person" name="person" required>
|
<select class="form-control" id="person" name="person" required>
|
||||||
<option value="Person A">Person A</option>
|
<option value="Sarah">Sarah</option>
|
||||||
<option value="Person B">Person B</option>
|
<option value="Stuart">Stuart</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div id="overwriteWarning" class="alert alert-warning" style="display: none;">
|
<div id="overwriteWarning" class="alert alert-warning" style="display: none;">
|
||||||
|
|||||||
@@ -162,8 +162,8 @@
|
|||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="applyPerson" class="form-label">Person</label>
|
<label for="applyPerson" class="form-label">Person</label>
|
||||||
<select class="form-control" id="applyPerson" name="person" required>
|
<select class="form-control" id="applyPerson" name="person" required>
|
||||||
<option value="Person A">Person A</option>
|
<option value="Sarah">Sarah</option>
|
||||||
<option value="Person B">Person B</option>
|
<option value="Stuart">Stuart</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div id="applyOverwriteWarning" class="alert alert-warning" style="display: none;">
|
<div id="applyOverwriteWarning" class="alert alert-warning" style="display: none;">
|
||||||
|
|||||||
Reference in New Issue
Block a user