latest changes

This commit is contained in:
Joren de Graaf
2026-10-07 14:33:21 +02:00
parent 86be3034c8
commit 98f76918dc
27 changed files with 1500 additions and 11 deletions
+3
View File
@@ -60,3 +60,6 @@ Thumbs.db
# Local development # Local development
*.sqlite3 *.sqlite3
playwright/.auth/
#AGENTS.md
@@ -0,0 +1,3 @@
- generic [active] [ref=e1]:
- heading "Bad Request (400)" [level=1] [ref=e2]
- paragraph
@@ -0,0 +1,29 @@
- generic [ref=f1e2]:
- banner [ref=f1e3]:
- generic [ref=f1e4]:
- link "Tasknest home" [ref=f1e5] [cursor=pointer]:
- /url: /
- generic [aria-hidden] [ref=f1e6]: ✓
- generic [ref=f1e7]: tasknest
- navigation "Primary navigation" [ref=f1e8]:
- link "Log in" [ref=f1e9] [cursor=pointer]:
- /url: /login/
- link "Create account" [ref=f1e10] [cursor=pointer]:
- /url: /register/
- main [ref=f1e11]:
- generic [ref=f1e12]:
- paragraph [ref=f1e13]: Welcome back
- heading "Log in to Tasknest" [level=1] [ref=f1e14]
- generic [ref=f1e15]:
- generic [ref=f1e16]:
- generic [ref=f1e17]: "Username:"
- textbox "Username:" [active] [ref=f1e18]
- generic [ref=f1e19]:
- generic [ref=f1e20]: "Password:"
- textbox "Password:" [ref=f1e21]
- button "Log in" [ref=f1e22] [cursor=pointer]
- paragraph [ref=f1e23]:
- text: New here?
- link "Create an account" [ref=f1e24] [cursor=pointer]:
- /url: /register/
- text: .
@@ -0,0 +1,662 @@
- generic [ref=f2e2]:
- banner [ref=f2e3]:
- generic [ref=f2e4]:
- link "Tasknest home" [ref=f2e5] [cursor=pointer]:
- /url: /
- generic [aria-hidden] [ref=f2e6]: ✓
- generic [ref=f2e7]: tasknest
- navigation "Primary navigation" [ref=f2e8]:
- link "My tasks" [ref=f2e9] [cursor=pointer]:
- /url: /
- link "Daily planner" [ref=f2e10] [cursor=pointer]:
- /url: /daily/
- link "Health" [ref=f2e11] [cursor=pointer]:
- /url: /health/
- link "Food" [ref=f2e12] [cursor=pointer]:
- /url: /food/
- link "Kitchen Inventory" [ref=f2e13] [cursor=pointer]:
- /url: /food/inventory/
- link "Settings" [ref=f2e14] [cursor=pointer]:
- /url: /settings/
- button "Use light mode" [ref=f2e16] [cursor=pointer]:
- generic [aria-hidden] [ref=f2e17]: ☀
- button "Log out" [ref=f2e20] [cursor=pointer]
- main [ref=f2e21]:
- region [ref=f2e22]:
- generic [ref=f2e23]:
- paragraph [ref=f2e24]: Personal planning
- heading "Make space for what matters." [level=1] [ref=f2e25]
- paragraph [ref=f2e26]: A focused view of your tasks, plans, and next steps.
- region [ref=f2e28]:
- generic [ref=f2e29]:
- generic [ref=f2e30]:
- paragraph [ref=f2e31]: Your forecast
- heading "Weather" [level=2] [ref=f2e32]
- generic [aria-hidden] [ref=f2e33]: 🌦
- paragraph [ref=f2e34]:
- strong [ref=f2e35]: 22 °C
- text: Rain
- paragraph [ref=f2e36]: 90% chance of precipitation
- generic [ref=f2e37]:
- generic [ref=f2e38]:
- region "Task list" [ref=f2e39]:
- generic [ref=f2e40]:
- generic [ref=f2e41]:
- generic [ref=f2e42]: Show
- combobox "Show" [ref=f2e43]:
- option "Active tasks" [selected]
- option "All tasks"
- option "Past tasks"
- generic [ref=f2e44]:
- button "Apply filter" [ref=f2e45] [cursor=pointer]
- link "New task" [ref=f2e46] [cursor=pointer]:
- /url: /tasks/new/
- generic [aria-hidden] [ref=f2e47]: +
- text: New task
- generic [ref=f2e49]:
- article [ref=f2e50]:
- generic [ref=f2e51]:
- generic [ref=f2e52]: High
- time [ref=f2e53]: Sat, 3 Oct
- heading [level=2] [ref=f2e54]:
- link "Run the washing machine" [ref=f2e55] [cursor=pointer]:
- /url: /tasks/22/
- paragraph [ref=f2e56]: A simple parent task to demonstrate dependencies.
- generic [ref=f2e57]:
- generic [ref=f2e58]: Home
- generic [ref=f2e59]: 10 min
- paragraph [ref=f2e60]: ↳ 1 subtask — complete this task to unlock
- generic [ref=f2e61]:
- button "Mark complete" [ref=f2e63] [cursor=pointer]
- button "Mark Run the washing machine as inactive" [ref=f2e65] [cursor=pointer]: Active
- link "Edit" [ref=f2e66] [cursor=pointer]:
- /url: /tasks/22/edit/
- article [ref=f2e67]:
- generic [ref=f2e68]:
- generic [ref=f2e69]: Low
- time [ref=f2e70]: Sat, 3 Oct
- heading [level=2] [ref=f2e71]:
- link "Take a neighbourhood walk" [ref=f2e72] [cursor=pointer]:
- /url: /tasks/26/
- paragraph [ref=f2e73]: An outdoor task with a weather preference.
- generic [ref=f2e74]:
- generic [ref=f2e75]: Health
- generic [ref=f2e76]: 30 min
- generic [ref=f2e77]: ☀ Dry
- generic [ref=f2e78]:
- button "Mark complete" [ref=f2e80] [cursor=pointer]
- button "Mark Take a neighbourhood walk as inactive" [ref=f2e82] [cursor=pointer]: Active
- link "Edit" [ref=f2e83] [cursor=pointer]:
- /url: /tasks/26/edit/
- region [ref=f2e84]:
- generic [ref=f2e85]:
- generic [ref=f2e86]:
- paragraph [ref=f2e87]: Daily movement
- heading "Daily Workout" [level=2] [ref=f2e88]
- paragraph [ref=f2e89]: Today, Wednesday, 7 October
- generic [ref=f2e90]:
- strong [ref=f2e91]: —
- generic [ref=f2e92]: No calorie data yet
- link "+ Add workout" [ref=f2e93] [cursor=pointer]:
- /url: /workouts/new/
- article [ref=f2e95]:
- generic [ref=f2e96]:
- heading "Morning stretch" [level=3] [ref=f2e97]
- paragraph [ref=f2e98]: Daily routine · 10 min · 35 kcal
- generic [ref=f2e99]:
- button "Mark complete" [ref=f2e101] [cursor=pointer]
- link "Edit" [ref=f2e102] [cursor=pointer]:
- /url: /workouts/10/edit/
- button "Remove" [ref=f2e104] [cursor=pointer]
- region [ref=f2e105]:
- generic [ref=f2e106]:
- generic [ref=f2e107]:
- paragraph [ref=f2e108]: Code garden
- heading "Gitea activity" [level=2] [ref=f2e109]
- link "View profile on Gitea" [ref=f2e110] [cursor=pointer]:
- /url: https://git.jorendegraaf.eu/jorenmartijn
- text: View profile
- generic [ref=f2e111]: on Gitea
- paragraph [ref=f2e112]:
- strong [ref=f2e113]: "26"
- text: contributions in the last year
- 'img "Gitea contribution calendar: 26 contributions in the last year" [ref=f2e115]':
- generic [aria-hidden] [ref=f2e116]:
- generic [ref=f2e118]: Mon
- generic [ref=f2e120]: Wed
- generic [ref=f2e122]: Fri
- generic [aria-hidden] [ref=f2e124]:
- generic [ref=f2e125]: Oct
- time [ref=f2e126]
- time [ref=f2e127]
- time [ref=f2e128]
- time [ref=f2e129]
- time [ref=f2e130]
- time [ref=f2e131]
- time [ref=f2e132]
- generic [aria-hidden] [ref=f2e133]:
- time [ref=f2e135]
- time [ref=f2e136]
- time [ref=f2e137]
- time [ref=f2e138]
- time [ref=f2e139]
- time [ref=f2e140]
- time [ref=f2e141]
- generic [aria-hidden] [ref=f2e142]:
- time [ref=f2e144]
- time [ref=f2e145]
- time [ref=f2e146]
- time [ref=f2e147]
- time [ref=f2e148]
- time [ref=f2e149]
- time [ref=f2e150]
- generic [aria-hidden] [ref=f2e151]:
- time [ref=f2e153]
- time [ref=f2e154]
- time [ref=f2e155]
- time [ref=f2e156]
- time [ref=f2e157]
- time [ref=f2e158]
- time [ref=f2e159]
- generic [aria-hidden] [ref=f2e160]:
- generic [ref=f2e161]: Nov
- time [ref=f2e162]
- time [ref=f2e163]
- time [ref=f2e164]
- time [ref=f2e165]
- time [ref=f2e166]
- time [ref=f2e167]
- time [ref=f2e168]
- generic [aria-hidden] [ref=f2e169]:
- time [ref=f2e171]
- time [ref=f2e172]
- time [ref=f2e173]
- time [ref=f2e174]
- time [ref=f2e175]
- time [ref=f2e176]
- time [ref=f2e177]
- generic [aria-hidden] [ref=f2e178]:
- time [ref=f2e180]
- time [ref=f2e181]
- time [ref=f2e182]
- time [ref=f2e183]
- time [ref=f2e184]
- time [ref=f2e185]
- time [ref=f2e186]
- generic [aria-hidden] [ref=f2e187]:
- time [ref=f2e189]
- time [ref=f2e190]
- time [ref=f2e191]
- time [ref=f2e192]
- time [ref=f2e193]
- time [ref=f2e194]
- time [ref=f2e195]
- generic [aria-hidden] [ref=f2e196]:
- time [ref=f2e198]
- time [ref=f2e199]
- time [ref=f2e200]
- time [ref=f2e201]
- time [ref=f2e202]
- time [ref=f2e203]
- time [ref=f2e204]
- generic [aria-hidden] [ref=f2e205]:
- generic [ref=f2e206]: Dec
- time [ref=f2e207]
- time [ref=f2e208]
- time [ref=f2e209]
- time [ref=f2e210]
- time [ref=f2e211]
- time [ref=f2e212]
- time [ref=f2e213]
- generic [aria-hidden] [ref=f2e214]:
- time [ref=f2e216]
- time [ref=f2e217]
- time [ref=f2e218]
- time [ref=f2e219]
- time [ref=f2e220]
- time [ref=f2e221]
- time [ref=f2e222]
- generic [aria-hidden] [ref=f2e223]:
- time [ref=f2e225]
- time [ref=f2e226]
- time [ref=f2e227]
- time [ref=f2e228]
- time [ref=f2e229]
- time [ref=f2e230]
- time [ref=f2e231]
- generic [aria-hidden] [ref=f2e232]:
- time [ref=f2e234]
- time [ref=f2e235]
- time [ref=f2e236]
- time [ref=f2e237]
- time [ref=f2e238]
- time [ref=f2e239]
- time [ref=f2e240]
- generic [aria-hidden] [ref=f2e241]:
- generic [ref=f2e242]: Jan
- time [ref=f2e243]
- time [ref=f2e244]
- time [ref=f2e245]
- time [ref=f2e246]
- time [ref=f2e247]
- time [ref=f2e248]
- time [ref=f2e249]
- generic [aria-hidden] [ref=f2e250]:
- time [ref=f2e252]
- time [ref=f2e253]
- time [ref=f2e254]
- time [ref=f2e255]
- time [ref=f2e256]
- time [ref=f2e257]
- time [ref=f2e258]
- generic [aria-hidden] [ref=f2e259]:
- time [ref=f2e261]
- time [ref=f2e262]
- time [ref=f2e263]
- time [ref=f2e264]
- time [ref=f2e265]
- time [ref=f2e266]
- time [ref=f2e267]
- generic [aria-hidden] [ref=f2e268]:
- time [ref=f2e270]
- time [ref=f2e271]
- time [ref=f2e272]
- time [ref=f2e273]
- time [ref=f2e274]
- time [ref=f2e275]
- time [ref=f2e276]
- generic [aria-hidden] [ref=f2e277]:
- generic [ref=f2e278]: Feb
- time [ref=f2e279]
- time [ref=f2e280]
- time [ref=f2e281]
- time [ref=f2e282]
- time [ref=f2e283]
- time [ref=f2e284]
- time [ref=f2e285]
- generic [aria-hidden] [ref=f2e286]:
- time [ref=f2e288]
- time [ref=f2e289]
- time [ref=f2e290]
- time [ref=f2e291]
- time [ref=f2e292]
- time [ref=f2e293]
- time [ref=f2e294]
- generic [aria-hidden] [ref=f2e295]:
- time [ref=f2e297]
- time [ref=f2e298]
- time [ref=f2e299]
- time [ref=f2e300]
- time [ref=f2e301]
- time [ref=f2e302]
- time [ref=f2e303]
- generic [aria-hidden] [ref=f2e304]:
- time [ref=f2e306]
- time [ref=f2e307]
- time [ref=f2e308]
- time [ref=f2e309]
- time [ref=f2e310]
- time [ref=f2e311]
- time [ref=f2e312]
- generic [aria-hidden] [ref=f2e313]:
- generic [ref=f2e314]: Mar
- time [ref=f2e315]
- time [ref=f2e316]
- time [ref=f2e317]
- time [ref=f2e318]
- time [ref=f2e319]
- time [ref=f2e320]
- time [ref=f2e321]
- generic [aria-hidden] [ref=f2e322]:
- time [ref=f2e324]
- time [ref=f2e325]
- time [ref=f2e326]
- time [ref=f2e327]
- time [ref=f2e328]
- time [ref=f2e329]
- time [ref=f2e330]
- generic [aria-hidden] [ref=f2e331]:
- time [ref=f2e333]
- time [ref=f2e334]
- time [ref=f2e335]
- time [ref=f2e336]
- time [ref=f2e337]
- time [ref=f2e338]
- time [ref=f2e339]
- generic [aria-hidden] [ref=f2e340]:
- time [ref=f2e342]
- time [ref=f2e343]
- time [ref=f2e344]
- time [ref=f2e345]
- time [ref=f2e346]
- time [ref=f2e347]
- time [ref=f2e348]
- generic [aria-hidden] [ref=f2e349]:
- time [ref=f2e351]
- time [ref=f2e352]
- time [ref=f2e353]
- time [ref=f2e354]
- time [ref=f2e355]
- time [ref=f2e356]
- time [ref=f2e357]
- generic [aria-hidden] [ref=f2e358]:
- generic [ref=f2e359]: Apr
- time [ref=f2e360]
- time [ref=f2e361]
- time [ref=f2e362]
- time [ref=f2e363]
- time [ref=f2e364]
- time [ref=f2e365]
- time [ref=f2e366]
- generic [aria-hidden] [ref=f2e367]:
- time [ref=f2e369]
- time [ref=f2e370]
- time [ref=f2e371]
- time [ref=f2e372]
- time [ref=f2e373]
- time [ref=f2e374]
- time [ref=f2e375]
- generic [aria-hidden] [ref=f2e376]:
- time [ref=f2e378]
- time [ref=f2e379]
- time [ref=f2e380]
- time [ref=f2e381]
- time [ref=f2e382]
- time [ref=f2e383]
- time [ref=f2e384]
- generic [aria-hidden] [ref=f2e385]:
- time [ref=f2e387]
- time [ref=f2e388]
- time [ref=f2e389]
- time [ref=f2e390]
- time [ref=f2e391]
- time [ref=f2e392]
- time [ref=f2e393]
- generic [aria-hidden] [ref=f2e394]:
- generic [ref=f2e395]: May
- time [ref=f2e396]
- time [ref=f2e397]
- time [ref=f2e398]
- time [ref=f2e399]
- time [ref=f2e400]
- time [ref=f2e401]
- time [ref=f2e402]
- generic [aria-hidden] [ref=f2e403]:
- time [ref=f2e405]
- time [ref=f2e406]
- time [ref=f2e407]
- time [ref=f2e408]
- time [ref=f2e409]
- time [ref=f2e410]
- time [ref=f2e411]
- generic [aria-hidden] [ref=f2e412]:
- time [ref=f2e414]
- time [ref=f2e415]
- time [ref=f2e416]
- time [ref=f2e417]
- time [ref=f2e418]
- time [ref=f2e419]
- time [ref=f2e420]
- generic [aria-hidden] [ref=f2e421]:
- time [ref=f2e423]
- time [ref=f2e424]
- time [ref=f2e425]
- time [ref=f2e426]
- time [ref=f2e427]
- time [ref=f2e428]
- time [ref=f2e429]
- generic [aria-hidden] [ref=f2e430]:
- time [ref=f2e432]
- time [ref=f2e433]
- time [ref=f2e434]
- time [ref=f2e435]
- time [ref=f2e436]
- time [ref=f2e437]
- time [ref=f2e438]
- generic [aria-hidden] [ref=f2e439]:
- generic [ref=f2e440]: Jun
- time [ref=f2e441]
- time [ref=f2e442]
- time [ref=f2e443]
- time [ref=f2e444]
- time [ref=f2e445]
- time [ref=f2e446]
- time [ref=f2e447]
- generic [aria-hidden] [ref=f2e448]:
- time [ref=f2e450]
- time [ref=f2e451]
- time [ref=f2e452]
- time [ref=f2e453]
- time [ref=f2e454]
- time [ref=f2e455]
- time [ref=f2e456]
- generic [aria-hidden] [ref=f2e457]:
- time [ref=f2e459]
- time [ref=f2e460]
- time [ref=f2e461]
- time [ref=f2e462]
- time [ref=f2e463]
- time [ref=f2e464]
- time [ref=f2e465]
- generic [aria-hidden] [ref=f2e466]:
- time [ref=f2e468]
- time [ref=f2e469]
- time [ref=f2e470]
- time [ref=f2e471]
- time [ref=f2e472]
- time [ref=f2e473]
- time [ref=f2e474]
- generic [aria-hidden] [ref=f2e475]:
- generic [ref=f2e476]: Jul
- time [ref=f2e477]
- time [ref=f2e478]
- time [ref=f2e479]
- time [ref=f2e480]
- time [ref=f2e481]
- time [ref=f2e482]
- time [ref=f2e483]
- generic [aria-hidden] [ref=f2e484]:
- time [ref=f2e486]
- time [ref=f2e487]
- time [ref=f2e488]
- time [ref=f2e489]
- time [ref=f2e490]
- time [ref=f2e491]
- time [ref=f2e492]
- generic [aria-hidden] [ref=f2e493]:
- time [ref=f2e495]
- time [ref=f2e496]
- time [ref=f2e497]
- time [ref=f2e498]
- time [ref=f2e499]
- time [ref=f2e500]
- time [ref=f2e501]
- generic [aria-hidden] [ref=f2e502]:
- time [ref=f2e504]
- time [ref=f2e505]
- time [ref=f2e506]
- time [ref=f2e507]
- time [ref=f2e508]
- time [ref=f2e509]
- time [ref=f2e510]
- generic [aria-hidden] [ref=f2e511]:
- generic [ref=f2e512]: Aug
- time [ref=f2e513]
- time [ref=f2e514]
- time [ref=f2e515]
- time [ref=f2e516]
- time [ref=f2e517]
- time [ref=f2e518]
- time [ref=f2e519]
- generic [aria-hidden] [ref=f2e520]:
- time [ref=f2e522]
- time [ref=f2e523]
- time [ref=f2e524]
- time [ref=f2e525]
- time [ref=f2e526]
- time [ref=f2e527]
- time [ref=f2e528]
- generic [aria-hidden] [ref=f2e529]:
- time [ref=f2e531]
- time [ref=f2e532]
- time [ref=f2e533]
- time [ref=f2e534]
- time [ref=f2e535]
- time [ref=f2e536]
- time [ref=f2e537]
- generic [aria-hidden] [ref=f2e538]:
- time [ref=f2e540]
- time [ref=f2e541]
- time [ref=f2e542]
- time [ref=f2e543]
- time [ref=f2e544]
- time [ref=f2e545]
- time [ref=f2e546]
- generic [aria-hidden] [ref=f2e547]:
- time [ref=f2e549]
- time [ref=f2e550]
- time [ref=f2e551]
- time [ref=f2e552]
- time [ref=f2e553]
- time [ref=f2e554]
- time [ref=f2e555]
- generic [aria-hidden] [ref=f2e556]:
- generic [ref=f2e557]: Sep
- time [ref=f2e558]
- time [ref=f2e559]
- time [ref=f2e560]
- time [ref=f2e561]
- time [ref=f2e562]
- time [ref=f2e563]
- time [ref=f2e564]
- generic [aria-hidden] [ref=f2e565]:
- time [ref=f2e567]
- time [ref=f2e568]
- time [ref=f2e569]
- time [ref=f2e570]
- time [ref=f2e571]
- time [ref=f2e572]
- time [ref=f2e573]
- generic [aria-hidden] [ref=f2e574]:
- time [ref=f2e576]
- time [ref=f2e577]
- time [ref=f2e578]
- time [ref=f2e579]
- time [ref=f2e580]
- time [ref=f2e581]
- time [ref=f2e582]
- generic [aria-hidden] [ref=f2e583]:
- time [ref=f2e585]
- time [ref=f2e586]
- time [ref=f2e587]
- time [ref=f2e588]
- time [ref=f2e589]
- time [ref=f2e590]
- time [ref=f2e591]
- generic [aria-hidden] [ref=f2e592]:
- generic [ref=f2e593]: Oct
- time [ref=f2e594]
- time [ref=f2e595]
- time [ref=f2e596]
- time [ref=f2e597]
- time [ref=f2e598]
- time [ref=f2e599]
- time [ref=f2e600]
- generic [aria-hidden] [ref=f2e601]:
- generic [ref=f2e602]: Less
- generic [ref=f2e608]: More
- complementary "Personal routines" [ref=f2e609]:
- article [ref=f2e610]:
- paragraph [ref=f2e611]: Daily routine
- heading "Teeth" [level=2] [ref=f2e612]
- generic [ref=f2e613]:
- generic [ref=f2e614]:
- time [ref=f2e615]: Monday
- generic [ref=f2e616]:
- button "Monday 5 October morning brushing, not done" [ref=f2e618] [cursor=pointer]: ○ Morning
- button "Monday 5 October evening brushing, done" [pressed] [ref=f2e620] [cursor=pointer]: ● Evening
- generic [ref=f2e621]:
- time [ref=f2e622]: Tuesday
- generic [ref=f2e623]:
- button "Tuesday 6 October morning brushing, not done" [ref=f2e625] [cursor=pointer]: ○ Morning
- button "Tuesday 6 October evening brushing, not done" [ref=f2e627] [cursor=pointer]: ○ Evening
- generic [ref=f2e628]:
- time [ref=f2e629]: Wednesday
- generic [ref=f2e630]:
- button "Wednesday 7 October morning brushing, not done" [ref=f2e632] [cursor=pointer]: ○ Morning
- button "Wednesday 7 October evening brushing, not done" [ref=f2e634] [cursor=pointer]: ○ Evening
- article [ref=f2e635]:
- paragraph [ref=f2e636]: Daily hydration
- heading "Water" [level=2] [ref=f2e637]
- generic [ref=f2e638]:
- generic [ref=f2e639]:
- paragraph [ref=f2e640]: 0 / 2000 ml
- paragraph [ref=f2e641]: 0% of daily goal
- progressbar "Daily water goal" [ref=f2e642]
- img [aria-hidden] [ref=f2e643]:
- generic [ref=f2e650]: "2000"
- generic [ref=f2e651]: "1500"
- generic [ref=f2e652]: "1000"
- generic [ref=f2e653]: "500"
- generic [ref=f2e654]:
- generic [ref=f2e655]:
- button "+250 ml" [ref=f2e656] [cursor=pointer]
- button "+500 ml" [ref=f2e657] [cursor=pointer]
- group [ref=f2e658]:
- generic "Other" [ref=f2e659] [cursor=pointer]
- generic [ref=f2e660]: No water logged today
- generic [ref=f2e662]:
- paragraph [ref=f2e663]: This week
- generic [ref=f2e664]:
- 'generic "Monday: 0 ml, no water logged" [ref=f2e665]': M
- 'generic "Tuesday: 13450 ml, goal met" [ref=f2e666]': T
- 'generic "Wednesday: 0 ml, no water logged" [ref=f2e667]': W
- 'generic "Thursday: 0 ml, no water logged" [ref=f2e668]': T
- 'generic "Friday: 0 ml, no water logged" [ref=f2e669]': F
- 'generic "Saturday: 0 ml, no water logged" [ref=f2e670]': S
- 'generic "Sunday: 0 ml, no water logged" [ref=f2e671]': S
- article [ref=f2e672]:
- generic [ref=f2e673]:
- paragraph [ref=f2e674]: Intermittent fasting
- generic [ref=f2e675]: Eating
- heading "Eating window open" [level=2] [ref=f2e676]
- 'timer "eating progress: 21 percent" [ref=f2e677]':
- generic [ref=f2e681]:
- strong [ref=f2e682]: 01:42:39
- generic [ref=f2e683]: Eating elapsed
- generic [ref=f2e684]:
- generic [ref=f2e685]:
- term [ref=f2e686]: Eating window
- definition [ref=f2e687]:
- time [ref=f2e688]: Wed 7 Oct, 12:00
- text: →
- time [ref=f2e689]: Wed 7 Oct, 20:00
- generic [ref=f2e690]:
- term [ref=f2e691]: Next fasting window
- definition [ref=f2e692]:
- time [ref=f2e693]: Wed 7 Oct, 20:00
- text: →
- time [ref=f2e694]: Thu 8 Oct, 12:00
- generic [ref=f2e695]:
- generic [ref=f2e696]:
- term [ref=f2e697]: Daily fast
- definition [ref=f2e698]: 16 hours
- generic [ref=f2e699]:
- term [ref=f2e700]: Eating window
- definition [ref=f2e701]: 8 hours
- generic [ref=f2e702]:
- button "Pause tracking" [ref=f2e704] [cursor=pointer]
- link "Adjust" [ref=f2e705] [cursor=pointer]:
- /url: /fasting/configure/
- region [ref=f2e706]:
- heading "Recent completed fasts" [level=3] [ref=f2e707]
- list [ref=f2e708]:
- listitem [ref=f2e709]:
- time [ref=f2e710]: 6 Oct
- generic [ref=f2e711]: 20:00–12:00
- listitem [ref=f2e712]:
- time [ref=f2e713]: 5 Oct
- generic [ref=f2e714]: 20:00–12:00
- listitem [ref=f2e715]:
- time [ref=f2e716]: 4 Oct
- generic [ref=f2e717]: 20:00–12:00
Binary file not shown.

After

Width:  |  Height:  |  Size: 266 KiB

@@ -0,0 +1,207 @@
- generic [ref=f3e2]:
- banner [ref=f3e3]:
- generic [ref=f3e4]:
- link "Tasknest home" [ref=f3e5] [cursor=pointer]:
- /url: /
- generic [aria-hidden] [ref=f3e6]: ✓
- generic [ref=f3e7]: tasknest
- navigation "Primary navigation" [ref=f3e8]:
- link "My tasks" [ref=f3e9] [cursor=pointer]:
- /url: /
- link "Daily planner" [ref=f3e10] [cursor=pointer]:
- /url: /daily/
- link "Health" [ref=f3e11] [cursor=pointer]:
- /url: /health/
- link "Food" [ref=f3e12] [cursor=pointer]:
- /url: /food/
- link "Kitchen Inventory" [ref=f3e13] [cursor=pointer]:
- /url: /food/inventory/
- link "Settings" [ref=f3e14] [cursor=pointer]:
- /url: /settings/
- button "Use light mode" [ref=f3e16] [cursor=pointer]:
- generic [aria-hidden] [ref=f3e17]: ☀
- button "Log out" [ref=f3e20] [cursor=pointer]
- main [ref=f3e21]:
- region [ref=f3e22]:
- generic [ref=f3e23]:
- paragraph [ref=f3e24]: Personal planning
- heading "Make space for what matters." [level=1] [ref=f3e25]
- paragraph [ref=f3e26]: A focused view of your tasks, plans, and next steps.
- region [ref=f3e28]:
- generic [ref=f3e29]:
- generic [ref=f3e30]:
- paragraph [ref=f3e31]: Your forecast
- heading "Weather" [level=2] [ref=f3e32]
- generic [aria-hidden] [ref=f3e33]: 🌦
- paragraph [ref=f3e34]:
- strong [ref=f3e35]: 22 °C
- text: Rain
- paragraph [ref=f3e36]: 90% chance of precipitation
- generic [ref=f3e37]:
- generic [ref=f3e38]:
- region "Task list" [ref=f3e39]:
- generic [ref=f3e40]:
- generic [ref=f3e41]:
- generic [ref=f3e42]: Show
- combobox "Show" [ref=f3e43]:
- option "Active tasks" [selected]
- option "All tasks"
- option "Past tasks"
- generic [ref=f3e44]:
- button "Apply filter" [ref=f3e45] [cursor=pointer]
- link "New task" [ref=f3e46] [cursor=pointer]:
- /url: /tasks/new/
- generic [aria-hidden] [ref=f3e47]: +
- text: New task
- generic [ref=f3e49]:
- article [ref=f3e50]:
- generic [ref=f3e51]:
- generic [ref=f3e52]: High
- time [ref=f3e53]: Sat, 3 Oct
- heading [level=2] [ref=f3e54]:
- link "Run the washing machine" [ref=f3e55] [cursor=pointer]:
- /url: /tasks/22/
- paragraph [ref=f3e56]: A simple parent task to demonstrate dependencies.
- generic [ref=f3e57]:
- generic [ref=f3e58]: Home
- generic [ref=f3e59]: 10 min
- paragraph [ref=f3e60]: ↳ 1 subtask — complete this task to unlock
- generic [ref=f3e61]:
- button "Mark complete" [ref=f3e63] [cursor=pointer]
- button "Mark Run the washing machine as inactive" [ref=f3e65] [cursor=pointer]: Active
- link "Edit" [ref=f3e66] [cursor=pointer]:
- /url: /tasks/22/edit/
- article [ref=f3e67]:
- generic [ref=f3e68]:
- generic [ref=f3e69]: Low
- time [ref=f3e70]: Sat, 3 Oct
- heading [level=2] [ref=f3e71]:
- link "Take a neighbourhood walk" [ref=f3e72] [cursor=pointer]:
- /url: /tasks/26/
- paragraph [ref=f3e73]: An outdoor task with a weather preference.
- generic [ref=f3e74]:
- generic [ref=f3e75]: Health
- generic [ref=f3e76]: 30 min
- generic [ref=f3e77]: ☀ Dry
- generic [ref=f3e78]:
- button "Mark complete" [ref=f3e80] [cursor=pointer]
- button "Mark Take a neighbourhood walk as inactive" [ref=f3e82] [cursor=pointer]: Active
- link "Edit" [ref=f3e83] [cursor=pointer]:
- /url: /tasks/26/edit/
- region [ref=f3e84]:
- generic [ref=f3e85]:
- generic [ref=f3e86]:
- paragraph [ref=f3e87]: Daily movement
- heading "Daily Workout" [level=2] [ref=f3e88]
- paragraph [ref=f3e89]: Today, Wednesday, 7 October
- generic [ref=f3e90]:
- strong [ref=f3e91]: —
- generic [ref=f3e92]: No calorie data yet
- link "+ Add workout" [ref=f3e93] [cursor=pointer]:
- /url: /workouts/new/
- article [ref=f3e95]:
- generic [ref=f3e96]:
- heading "Morning stretch" [level=3] [ref=f3e97]
- paragraph [ref=f3e98]: Daily routine · 10 min · 35 kcal
- generic [ref=f3e99]:
- button "Mark complete" [ref=f3e101] [cursor=pointer]
- link "Edit" [ref=f3e102] [cursor=pointer]:
- /url: /workouts/10/edit/
- button "Remove" [ref=f3e104] [cursor=pointer]
- region "Gitea activity" [ref=f3e106]:
- paragraph [ref=f3e107]: Loading Gitea activity…
- complementary "Personal routines" [ref=f3e108]:
- article [ref=f3e109]:
- paragraph [ref=f3e110]: Daily routine
- heading "Teeth" [level=2] [ref=f3e111]
- generic [ref=f3e112]:
- generic [ref=f3e113]:
- time [ref=f3e114]: Monday
- generic [ref=f3e115]:
- button "Monday 5 October morning brushing, not done" [ref=f3e117] [cursor=pointer]: ○ Morning
- button "Monday 5 October evening brushing, done" [pressed] [ref=f3e119] [cursor=pointer]: ● Evening
- generic [ref=f3e120]:
- time [ref=f3e121]: Tuesday
- generic [ref=f3e122]:
- button "Tuesday 6 October morning brushing, not done" [ref=f3e124] [cursor=pointer]: ○ Morning
- button "Tuesday 6 October evening brushing, not done" [ref=f3e126] [cursor=pointer]: ○ Evening
- generic [ref=f3e127]:
- time [ref=f3e128]: Wednesday
- generic [ref=f3e129]:
- button "Wednesday 7 October morning brushing, not done" [ref=f3e131] [cursor=pointer]: ○ Morning
- button "Wednesday 7 October evening brushing, not done" [ref=f3e133] [cursor=pointer]: ○ Evening
- article [ref=f3e134]:
- paragraph [ref=f3e135]: Daily hydration
- heading "Water" [level=2] [ref=f3e136]
- generic [ref=f3e137]:
- generic [ref=f3e138]:
- paragraph [ref=f3e139]: 0 / 2000 ml
- paragraph [ref=f3e140]: 0% of daily goal
- progressbar "Daily water goal" [ref=f3e141]
- img [aria-hidden] [ref=f3e142]:
- generic [ref=f3e149]: "2000"
- generic [ref=f3e150]: "1500"
- generic [ref=f3e151]: "1000"
- generic [ref=f3e152]: "500"
- generic [ref=f3e153]:
- generic [ref=f3e154]:
- button "+250 ml" [ref=f3e155] [cursor=pointer]
- button "+500 ml" [ref=f3e156] [cursor=pointer]
- group [ref=f3e157]:
- generic "Other" [ref=f3e158] [cursor=pointer]
- generic [ref=f3e159]: No water logged today
- generic [ref=f3e161]:
- paragraph [ref=f3e162]: This week
- generic [ref=f3e163]:
- 'generic "Monday: 0 ml, no water logged" [ref=f3e164]': M
- 'generic "Tuesday: 13450 ml, goal met" [ref=f3e165]': T
- 'generic "Wednesday: 0 ml, no water logged" [ref=f3e166]': W
- 'generic "Thursday: 0 ml, no water logged" [ref=f3e167]': T
- 'generic "Friday: 0 ml, no water logged" [ref=f3e168]': F
- 'generic "Saturday: 0 ml, no water logged" [ref=f3e169]': S
- 'generic "Sunday: 0 ml, no water logged" [ref=f3e170]': S
- article [ref=f3e171]:
- generic [ref=f3e172]:
- paragraph [ref=f3e173]: Intermittent fasting
- generic [ref=f3e174]: Eating
- heading "Eating window open" [level=2] [ref=f3e175]
- 'timer "eating progress: 21 percent" [ref=f3e176]':
- generic [ref=f3e180]:
- strong [ref=f3e181]: 01:44:44
- generic [ref=f3e182]: Eating elapsed
- generic [ref=f3e183]:
- generic [ref=f3e184]:
- term [ref=f3e185]: Eating window
- definition [ref=f3e186]:
- time [ref=f3e187]: Wed 7 Oct, 12:00
- text: →
- time [ref=f3e188]: Wed 7 Oct, 20:00
- generic [ref=f3e189]:
- term [ref=f3e190]: Next fasting window
- definition [ref=f3e191]:
- time [ref=f3e192]: Wed 7 Oct, 20:00
- text: →
- time [ref=f3e193]: Thu 8 Oct, 12:00
- generic [ref=f3e194]:
- generic [ref=f3e195]:
- term [ref=f3e196]: Daily fast
- definition [ref=f3e197]: 16 hours
- generic [ref=f3e198]:
- term [ref=f3e199]: Eating window
- definition [ref=f3e200]: 8 hours
- generic [ref=f3e201]:
- button "Pause tracking" [ref=f3e203] [cursor=pointer]
- link "Adjust" [ref=f3e204] [cursor=pointer]:
- /url: /fasting/configure/
- region [ref=f3e205]:
- heading "Recent completed fasts" [level=3] [ref=f3e206]
- list [ref=f3e207]:
- listitem [ref=f3e208]:
- time [ref=f3e209]: 6 Oct
- generic [ref=f3e210]: 20:00–12:00
- listitem [ref=f3e211]:
- time [ref=f3e212]: 5 Oct
- generic [ref=f3e213]: 20:00–12:00
- listitem [ref=f3e214]:
- time [ref=f3e215]: 4 Oct
- generic [ref=f3e216]: 20:00–12:00
Binary file not shown.

After

Width:  |  Height:  |  Size: 265 KiB

+113
View File
@@ -0,0 +1,113 @@
Please update the project's `AGENTS.md` to document our browser-based UI testing workflow.
Playwright MCP is now available to you and should be used when working on frontend, UI, UX, responsive-layout, JavaScript, HTMX, accessibility, or other browser-visible changes.
Add an appropriate section to `AGENTS.md` covering the following requirements.
If needed you can install the required modules for it.
## Browser and visual testing
Playwright MCP is available for interacting with and inspecting the actual rendered application.
When working on browser-visible changes:
- Use Playwright to open the running Django application and inspect the actual rendered result.
- Do not judge whether a visual change is correct solely by reading Django templates, HTML, SCSS/CSS, or JavaScript.
- After significant UI changes, reload the relevant page and inspect the result in the browser.
- Use screenshots when evaluating visual appearance, spacing, typography, sizing, alignment, colour, hierarchy, overflow, or responsive behaviour.
- Use the accessibility/DOM representation where it is more appropriate for understanding page structure, controls, labels, state, and interactions.
- Test relevant interactions rather than assuming they work from reading the implementation.
- Check browser console errors after changes involving JavaScript or HTMX.
- Verify important HTMX interactions in the browser.
- Test both desktop and mobile-sized viewports when the affected interface is responsive.
- When appropriate, test intermediate viewport widths as well rather than only the two extremes.
- Do not consider a visual task complete until the rendered result has actually been inspected.
When reporting findings from browser inspection, distinguish between:
1. problems actually observed in the rendered application;
2. accessibility or functional problems discovered through browser inspection;
3. optional design suggestions.
Do not present subjective redesign suggestions as bugs.
Do not redesign unrelated parts of the application simply because browser inspection reveals opportunities for improvement. Keep changes within the requested scope unless explicitly asked otherwise.
## Authentication and demo account
The application has a dedicated demo/test account intended for development and browser testing.
Playwright may use this account when authentication is required.
The demo account may be used to:
- navigate authenticated parts of the application;
- create test data;
- edit test data belonging to the demo user;
- delete test data belonging to the demo user;
- exercise forms and interactive features;
- test authenticated HTMX/browser behaviour.
Never modify data belonging to other users.
Prefer reusing an existing authenticated Playwright browser session when one is available rather than repeatedly logging in.
The demo account credentials should not be written into `AGENTS.md`, source code, committed configuration, or other repository files. They can be supplied interactively when authentication is required.
Do not copy authentication cookies, session tokens, CSRF tokens, passwords, or other credentials into committed files.
If Playwright authentication state is ever exported to a file, store it in a dedicated location such as:
`playwright/.auth/`
and ensure that directory is excluded by `.gitignore`.
## Browser testing behaviour
Browser access is a verification and debugging tool, not permission to make arbitrary changes.
When asked to inspect something without modifying it:
- browse the application;
- reproduce the relevant state;
- inspect it;
- take screenshots if useful;
- report findings;
- do not change project files.
When asked to implement a browser-visible change:
1. inspect the current rendered state when useful;
2. implement the requested change;
3. reload/open the affected page;
4. inspect the rendered result;
5. exercise the relevant interaction if applicable;
6. check for browser/console errors;
7. inspect responsive behaviour where relevant;
8. fix problems introduced by the change before considering the task complete.
For visual verification, prefer observations from the actual rendered application over assumptions derived from source code.
If the Django development server is not running, determine the project's normal development command from the repository rather than inventing a new development setup. Starting the existing development server for browser testing is allowed when appropriate.
Do not alter production configuration merely to make browser testing easier.
## Accessibility
Use browser testing to help catch accessibility regressions when working on UI.
Where relevant, verify:
- semantic controls and headings;
- accessible names and labels;
- keyboard-operable interactive elements;
- visible focus behaviour;
- sensible form validation/error presentation;
- appropriate ARIA state where custom controls require it;
- obvious colour/contrast or readability problems;
- behaviour at narrow/mobile viewport sizes.
Do not treat the accessibility tree alone as proof that the visual interface is correct. Likewise, do not treat a screenshot alone as proof that the interface is accessible. Use the appropriate browser information for each.
Please integrate these rules cleanly into the existing `AGENTS.md` rather than blindly appending duplicate or conflicting instructions.
Preserve any existing useful project-specific instructions.
Before editing, read the current `AGENTS.md` if one exists and adapt the new section to its existing structure and terminology.
Afterwards, show me the resulting section or summarise exactly what you added. Do not make unrelated project changes.
+19 -1
View File
@@ -1,6 +1,6 @@
from django.contrib import admin from django.contrib import admin
from .models import FoodFavourite, FoodLogEntry, FoodPortion, FoodProduct from .models import FoodFavourite, FoodLogEntry, FoodPortion, FoodProduct, InventoryCategory, InventoryLocation, KitchenInventoryItem
@admin.register(FoodProduct) @admin.register(FoodProduct)
@@ -25,3 +25,21 @@ class FoodFavouriteAdmin(admin.ModelAdmin):
@admin.register(FoodPortion) @admin.register(FoodPortion)
class FoodPortionAdmin(admin.ModelAdmin): class FoodPortionAdmin(admin.ModelAdmin):
list_display = ('user', 'product', 'label', 'amount', 'unit', 'is_default') list_display = ('user', 'product', 'label', 'amount', 'unit', 'is_default')
@admin.register(InventoryLocation)
class InventoryLocationAdmin(admin.ModelAdmin):
list_display = ('name', 'user', 'sort_order')
search_fields = ('name',)
@admin.register(InventoryCategory)
class InventoryCategoryAdmin(admin.ModelAdmin):
list_display = ('name', 'user')
search_fields = ('name',)
@admin.register(KitchenInventoryItem)
class KitchenInventoryItemAdmin(admin.ModelAdmin):
list_display = ('product', 'user', 'quantity', 'location', 'category', 'best_before', 'archived_at')
list_filter = ('opened', 'archived_at')
+46 -1
View File
@@ -1,7 +1,7 @@
from django import forms from django import forms
from decimal import Decimal from decimal import Decimal
from .models import FoodLogEntry, FoodPortion, FoodProduct from .models import FoodLogEntry, FoodPortion, FoodProduct, KitchenInventoryItem
class ManualFoodForm(forms.ModelForm): class ManualFoodForm(forms.ModelForm):
@@ -139,3 +139,48 @@ class FoodLogForm(forms.ModelForm):
elif data.get('make_default'): elif data.get('make_default'):
self.add_error('make_default', 'Save the portion before making it the default.') self.add_error('make_default', 'Save the portion before making it the default.')
return data return data
class InventoryItemForm(forms.ModelForm):
location_name = forms.CharField(max_length=100, label='Location', widget=forms.TextInput(attrs={'list': 'inventory-locations', 'autocomplete': 'off'}))
category_name = forms.CharField(max_length=100, required=False, label='My category', widget=forms.TextInput(attrs={'list': 'inventory-categories', 'autocomplete': 'off'}))
class Meta:
model = KitchenInventoryItem
fields = ('quantity', 'opened', 'best_before', 'notes')
widgets = {'quantity': forms.NumberInput(attrs={'min': 1, 'step': 1}),
'best_before': forms.DateInput(attrs={'type': 'date'}),
'notes': forms.Textarea(attrs={'rows': 2})}
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
if self.instance.pk:
self.fields['location_name'].initial = self.instance.location.name
self.fields['category_name'].initial = self.instance.category.name if self.instance.category else ''
def clean_location_name(self):
value = ' '.join(self.cleaned_data['location_name'].split())
if not value:
raise forms.ValidationError('Enter a location.')
return value
def clean_category_name(self):
return ' '.join(self.cleaned_data['category_name'].split())
class InventoryManualProductForm(forms.ModelForm):
class Meta:
model = FoodProduct
fields = ('product_name', 'brand', 'barcode', 'package_quantity')
def __init__(self, *args, user=None, **kwargs):
super().__init__(*args, **kwargs)
self.user = user
def clean_barcode(self):
barcode = self.cleaned_data['barcode'].strip()
if barcode and (not barcode.isascii() or not barcode.isdigit()):
raise forms.ValidationError('Enter a numeric barcode.')
if barcode and self.user and FoodProduct.objects.filter(owner=self.user, barcode=barcode).exists():
raise forms.ValidationError('This barcode is already saved in your products.')
return barcode
+185
View File
@@ -0,0 +1,185 @@
from datetime import timedelta
from django.contrib import messages
from django.contrib.auth.decorators import login_required
from django.db import transaction
from django.db.models import F, Q
from django.http import HttpResponseBadRequest
from django.shortcuts import get_object_or_404, redirect, render
from django.urls import reverse
from django.utils import timezone
from django.views.decorators.http import require_http_methods, require_POST
from .forms import InventoryItemForm, InventoryManualProductForm
from .models import FoodProduct, InventoryCategory, InventoryLocation, KitchenInventoryItem
from .services.openfoodfacts import OpenFoodFactsError, cached_product, cached_search
from .services.products import local_products
def _owned_items(user):
return KitchenInventoryItem.objects.filter(user=user, archived_at__isnull=True).select_related('product', 'location', 'category')
@login_required
def overview(request):
items = _owned_items(request.user)
query = request.GET.get('q', '').strip()[:100]
if query:
items = items.filter(Q(product__product_name__icontains=query) | Q(product__brand__icontains=query) |
Q(product__barcode__icontains=query) | Q(location__name__icontains=query) |
Q(category__name__icontains=query))
location = request.GET.get('location', '')
category = request.GET.get('category', '')
if location.isdigit():
items = items.filter(location_id=location)
if category.isdigit():
items = items.filter(category_id=category)
opened = request.GET.get('opened', '')
if opened in ('yes', 'no'):
items = items.filter(opened=(opened == 'yes'))
if request.GET.get('use_soon') == '1':
items = items.filter(best_before__isnull=False, best_before__lte=timezone.localdate() + timedelta(days=14))
sort = request.GET.get('sort', 'location')
orderings = {'location': ('location__sort_order', 'location__name', 'product__product_name'),
'category': ('category__name', 'product__product_name'),
'name': ('product__product_name',), 'recent': ('-added_at',),
'best_before': (F('best_before').asc(nulls_last=True), 'product__product_name')}
items = items.order_by(*orderings.get(sort, orderings['location']))
return render(request, 'food/inventory_overview.html', {
'items': items, 'query': query, 'sort': sort, 'selected_location': location,
'selected_category': category, 'opened': opened, 'use_soon': request.GET.get('use_soon'),
'locations': InventoryLocation.objects.filter(user=request.user),
'categories': InventoryCategory.objects.filter(user=request.user),
'today': timezone.localdate(), 'soon_date': timezone.localdate() + timedelta(days=14),
})
@login_required
@require_http_methods(['GET', 'POST'])
def add(request):
product_id = request.GET.get('product') or request.POST.get('product')
product = get_object_or_404(FoodProduct, owner=request.user, pk=product_id) if product_id else None
query = request.GET.get('q', '').strip()[:100]
products = local_products(request.user, query)
form = InventoryItemForm(request.POST or None, initial={'quantity': 1, 'location_name': request.session.get('inventory_location', '')}) if product else None
existing = _owned_items(request.user).filter(product=product) if product else []
if request.method == 'POST':
if not product:
return HttpResponseBadRequest('Choose a product.')
if form.is_valid():
with transaction.atomic():
location, _ = InventoryLocation.objects.get_or_create(user=request.user, name__iexact=form.cleaned_data['location_name'], defaults={'name': form.cleaned_data['location_name']})
category_name = form.cleaned_data['category_name']
category = None
if category_name:
category, _ = InventoryCategory.objects.get_or_create(user=request.user, name__iexact=category_name, defaults={'name': category_name})
item = form.save(commit=False)
item.user, item.product, item.location, item.category = request.user, product, location, category
item.full_clean()
item.save()
request.session['inventory_location'] = location.name
messages.success(request, f'{product.product_name} added. Scan the next item when ready.')
return redirect('food:inventory-add')
return render(request, 'food/inventory_add.html', {
'product': product, 'products': products.order_by('product_name')[:40], 'query': query,
'form': form, 'existing': existing,
'locations': InventoryLocation.objects.filter(user=request.user),
'categories': InventoryCategory.objects.filter(user=request.user),
'off_categories': product.raw_data.get('categories', '') if product and isinstance(product.raw_data, dict) else '',
})
@login_required
@require_POST
def lookup(request):
barcode = request.POST.get('barcode', '').strip()
try:
if not barcode.isascii() or not barcode.isdigit() or len(barcode) > 64:
raise ValueError('Enter a numeric barcode.')
product = FoodProduct.objects.filter(owner=request.user, barcode=barcode).first()
if not product:
product = cached_product(request.user, barcode)
except (ValueError, OpenFoodFactsError) as error:
messages.warning(request, str(error))
return redirect('food:inventory-add')
if product:
return redirect(f"{reverse('food:inventory-add')}?product={product.pk}")
return redirect(f"{reverse('food:inventory-manual')}?barcode={barcode}")
@login_required
@require_http_methods(['GET', 'POST'])
def external_search(request):
query = (request.POST.get('q') or request.GET.get('q') or '').strip()[:100]
results, notice = [], ''
if request.method == 'POST':
try:
results = cached_search(request.user, query)
except (ValueError, OpenFoodFactsError) as error:
notice = str(error)
return render(request, 'food/inventory_external.html', {'query': query, 'results': results, 'notice': notice})
@login_required
@require_http_methods(['GET', 'POST'])
def manual(request):
form = InventoryManualProductForm(request.POST or None, user=request.user, initial={'barcode': request.GET.get('barcode', '')})
if request.method == 'POST' and form.is_valid():
product = form.save(commit=False)
product.owner = request.user
product.save()
return redirect(f"{reverse('food:inventory-add')}?product={product.pk}")
return render(request, 'food/inventory_manual.html', {'form': form})
@login_required
@require_http_methods(['GET', 'POST'])
def edit(request, pk):
item = get_object_or_404(_owned_items(request.user), pk=pk)
form = InventoryItemForm(request.POST or None, instance=item)
if request.method == 'POST' and form.is_valid():
with transaction.atomic():
location, _ = InventoryLocation.objects.get_or_create(user=request.user, name__iexact=form.cleaned_data['location_name'], defaults={'name': form.cleaned_data['location_name']})
category_name = form.cleaned_data['category_name']
category = None
if category_name:
category, _ = InventoryCategory.objects.get_or_create(user=request.user, name__iexact=category_name, defaults={'name': category_name})
item = form.save(commit=False)
item.location, item.category = location, category
item.full_clean()
item.save()
return redirect('food:inventory')
return render(request, 'food/inventory_edit.html', {'item': item, 'form': form,
'locations': InventoryLocation.objects.filter(user=request.user),
'categories': InventoryCategory.objects.filter(user=request.user)})
@login_required
@require_POST
def change_quantity(request, pk):
with transaction.atomic():
item = get_object_or_404(KitchenInventoryItem.objects.select_for_update(), pk=pk, user=request.user, archived_at__isnull=True)
action = request.POST.get('action')
if action == 'increase':
item.quantity += 1
elif action == 'used':
if item.quantity == 1:
item.archived_at = timezone.now()
messages.success(request, f'{item.product.product_name} used up.')
else:
item.quantity -= 1
else:
return HttpResponseBadRequest('Invalid action.')
item.save()
return redirect('food:inventory')
@login_required
@require_POST
def add_existing(request, pk):
with transaction.atomic():
item = get_object_or_404(KitchenInventoryItem.objects.select_for_update(), pk=pk, user=request.user, archived_at__isnull=True)
item.quantity += 1
item.save(update_fields=('quantity', 'updated_at'))
messages.success(request, f'{item.product.product_name} quantity increased.')
return redirect('food:inventory-add')
@@ -0,0 +1,65 @@
# Generated by Django 6.1.1 on 2026-10-03 23:54
import django.core.validators
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('food', '0002_foodportion_food_one_default_portion'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='InventoryCategory',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=100)),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
options={
'ordering': ('name',),
},
),
migrations.CreateModel(
name='InventoryLocation',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=100)),
('sort_order', models.PositiveIntegerField(default=0)),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
options={
'ordering': ('sort_order', 'name'),
},
),
migrations.CreateModel(
name='KitchenInventoryItem',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('quantity', models.PositiveIntegerField(default=1, validators=[django.core.validators.MinValueValidator(1)])),
('notes', models.TextField(blank=True)),
('opened', models.BooleanField(default=False)),
('best_before', models.DateField(blank=True, null=True)),
('archived_at', models.DateTimeField(blank=True, null=True)),
('added_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('category', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='food.inventorycategory')),
('location', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='food.inventorylocation')),
('product', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='inventory_items', to='food.foodproduct')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='kitchen_inventory', to=settings.AUTH_USER_MODEL)),
],
),
migrations.AddConstraint(
model_name='inventorycategory',
constraint=models.UniqueConstraint(fields=('user', 'name'), name='food_unique_inventory_category'),
),
migrations.AddConstraint(
model_name='inventorylocation',
constraint=models.UniqueConstraint(fields=('user', 'name'), name='food_unique_inventory_location'),
),
]
+48
View File
@@ -128,3 +128,51 @@ class FoodPortion(models.Model):
raise ValidationError({'product': 'Choose one of your own food products.'}) raise ValidationError({'product': 'Choose one of your own food products.'})
if self.product_id and self.unit != self.product.base_unit: if self.product_id and self.unit != self.product.base_unit:
raise ValidationError({'unit': 'Use the same unit as the product nutrition basis.'}) raise ValidationError({'unit': 'Use the same unit as the product nutrition basis.'})
class InventoryLocation(models.Model):
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
name = models.CharField(max_length=100)
sort_order = models.PositiveIntegerField(default=0)
class Meta:
constraints = [models.UniqueConstraint(fields=('user', 'name'), name='food_unique_inventory_location')]
ordering = ('sort_order', 'name')
def __str__(self):
return self.name
class InventoryCategory(models.Model):
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
name = models.CharField(max_length=100)
class Meta:
constraints = [models.UniqueConstraint(fields=('user', 'name'), name='food_unique_inventory_category')]
ordering = ('name',)
def __str__(self):
return self.name
class KitchenInventoryItem(models.Model):
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name='kitchen_inventory')
product = models.ForeignKey(FoodProduct, on_delete=models.PROTECT, related_name='inventory_items')
quantity = models.PositiveIntegerField(default=1, validators=[MinValueValidator(1)])
location = models.ForeignKey(InventoryLocation, on_delete=models.PROTECT)
category = models.ForeignKey(InventoryCategory, on_delete=models.PROTECT, null=True, blank=True)
notes = models.TextField(blank=True)
opened = models.BooleanField(default=False)
best_before = models.DateField(null=True, blank=True)
archived_at = models.DateTimeField(null=True, blank=True)
added_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
def clean(self):
super().clean()
if self.user_id and self.product_id and self.product.owner_id != self.user_id:
raise ValidationError({'product': 'Choose one of your own products.'})
if self.user_id and self.location_id and self.location.user_id != self.user_id:
raise ValidationError({'location': 'Choose one of your own locations.'})
if self.user_id and self.category_id and self.category.user_id != self.user_id:
raise ValidationError({'category': 'Choose one of your own categories.'})
+3 -1
View File
@@ -17,7 +17,7 @@ from django.utils import timezone
from food.models import FoodProduct, Unit from food.models import FoodProduct, Unit
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
FIELDS = 'code,product_name,brands,quantity,serving_size,serving_quantity,image_front_small_url,image_front_url,nutriments' FIELDS = 'code,product_name,brands,quantity,serving_size,serving_quantity,image_front_small_url,image_front_url,nutriments,categories,categories_tags'
NUTRIENTS = { NUTRIENTS = {
'energy-kcal_100g': 'energy_kcal_100', 'energy-kcal_100g': 'energy_kcal_100',
'carbohydrates_100g': 'carbohydrates_100', 'carbohydrates_100g': 'carbohydrates_100',
@@ -154,6 +154,8 @@ def cached_product(user, barcode, *, refresh=False):
mapped['fetched_at'] = timezone.now() mapped['fetched_at'] = timezone.now()
nutrients = data.get('nutriments') if isinstance(data.get('nutriments'), dict) else {} nutrients = data.get('nutriments') if isinstance(data.get('nutriments'), dict) else {}
mapped['raw_data'] = {'code': barcode, 'product_name': mapped['product_name'], mapped['raw_data'] = {'code': barcode, 'product_name': mapped['product_name'],
'categories': str(data.get('categories') or '')[:1000],
'categories_tags': data.get('categories_tags', []) if isinstance(data.get('categories_tags'), list) else [],
'nutriments': {key: nutrients.get(key) for key in NUTRIENTS}} 'nutriments': {key: nutrients.get(key) for key in NUTRIENTS}}
product, _ = FoodProduct.objects.update_or_create(owner=user, barcode=barcode, defaults=mapped) product, _ = FoodProduct.objects.update_or_create(owner=user, barcode=barcode, defaults=mapped)
return product return product
+12
View File
@@ -0,0 +1,12 @@
from django.db.models import Q
from food.models import FoodProduct
def local_products(user, query=''):
"""Shared user-owned catalogue search for food logging and inventory."""
products = FoodProduct.objects.filter(owner=user)
for token in query.strip().split():
products = products.filter(Q(product_name__icontains=token) | Q(brand__icontains=token) |
Q(barcode__icontains=token))
return products
+2
View File
@@ -15,6 +15,8 @@ body[data-theme="dark"]{--food-surface:#202923;--food-border:#3b473f;--food-ink:
.food-progress span{background:var(--food-green)} .food-progress span{background:var(--food-green)}
.food-entry-main span,.food-entry-main small,.food-card>p:not(.food-remaining),.food-attribution{color:var(--food-muted);opacity:1} .food-entry-main span,.food-entry-main small,.food-card>p:not(.food-remaining),.food-attribution{color:var(--food-muted);opacity:1}
.food-entry-main strong,.food-card h2,.food-card h3,.food-remaining{color:var(--food-ink)} .food-entry-main strong,.food-card h2,.food-card h3,.food-remaining{color:var(--food-ink)}
.inventory-page .inventory-group{margin:1.5rem 0 .5rem}.inventory-filters{display:flex;flex-wrap:wrap;gap:.75rem;align-items:end}.inventory-filters label{display:grid;gap:.25rem;min-width:130px;flex:1}.inventory-filters .inventory-check{display:flex;align-items:center;min-width:auto}.inventory-row{display:flex;align-items:center;gap:1rem}.inventory-row>img,.inventory-product>img{width:68px;height:68px;object-fit:contain;background:#fff;border-radius:.6rem}.inventory-row-main{flex:1;min-width:0}.inventory-row-main p{margin:.2rem 0}.inventory-row-actions{display:flex;align-items:center;gap:.5rem;flex-wrap:wrap}.inventory-row-actions form{display:flex;gap:.4rem}.inventory-row-actions button,.inventory-row-actions a{min-height:44px;padding:.5rem .75rem}.inventory-tag{display:inline-block;padding:.2rem .45rem;margin:.2rem .2rem 0 0;border-radius:.5rem;background:#eef1ed;color:#263828}.inventory-soon{background:#fff0c2;color:#533c00}.inventory-expired{background:#f9d9d9;color:#6b1717}.inventory-product{display:flex;gap:1rem;align-items:center}.inventory-existing{display:flex;justify-content:space-between;align-items:center;gap:.7rem;margin:.7rem 0}.inventory-form{display:grid;gap:.8rem}.inventory-form .form-field{display:grid;gap:.25rem}.inventory-form input:not([type=checkbox]),.inventory-form textarea{width:100%}@media(max-width:650px){.inventory-row{align-items:flex-start;flex-wrap:wrap}.inventory-row-actions{width:100%}.inventory-existing{align-items:flex-start;flex-direction:column}}
.inventory-quantity{display:flex;align-items:center;gap:.5rem}.inventory-quantity input{text-align:center;max-width:6rem}.inventory-quantity button{min-width:44px;min-height:44px;border:1px solid currentColor;border-radius:.5rem;background:transparent;color:inherit;font-size:1.3rem}
.food-tabs a[aria-current=page]{background:var(--food-green);border-color:var(--food-green);color:#fff} .food-tabs a[aria-current=page]{background:var(--food-green);border-color:var(--food-green);color:#fff}
.food-export-actions a{color:var(--food-ink);border-color:var(--food-border)} .food-export-actions a{color:var(--food-ink);border-color:var(--food-border)}
.food-export-actions a:hover,.food-export-actions a:focus-visible{background:var(--food-progress-track)} .food-export-actions a:hover,.food-export-actions a:focus-visible{background:var(--food-progress-track)}
+7
View File
@@ -0,0 +1,7 @@
document.addEventListener('click', (event) => {
const button = event.target.closest('[data-inventory-step]');
if (!button) return;
const input = button.closest('[data-inventory-quantity]').querySelector('input');
input.value = Math.max(1, (Number.parseInt(input.value, 10) || 1) + Number(button.dataset.inventoryStep));
input.dispatchEvent(new Event('change', { bubbles: true }));
});
@@ -0,0 +1,18 @@
{% extends 'planner/base.html' %}{% load static %}
{% block title %}Add to Kitchen Inventory · Tasknest{% endblock %}
{% block content %}<link rel="stylesheet" href="{% static 'food/food.css' %}">
<div class="food-form-page inventory-page"><a href="{% url 'food:inventory' %}">← Kitchen Inventory</a><h1>Add to inventory</h1>
{% if product %}
<section class="food-card inventory-product">{% if product.image_url %}<img src="{{ product.image_url }}" alt="" loading="lazy">{% endif %}<div><h2>{{ product.product_name }}</h2>{% if product.brand %}<p>{{ product.brand }}</p>{% endif %}{% if product.package_quantity %}<p>{{ product.package_quantity }}</p>{% endif %}{% if off_categories %}<p><small>Open Food Facts: {{ off_categories }}</small></p>{% endif %}</div></section>
{% if existing %}<section class="food-card"><h2>Already in inventory</h2>{% for item in existing %}<div class="inventory-existing"><span>{{ item.location.name }} · Quantity {{ item.quantity }}{% if item.best_before %} · Best before {{ item.best_before }}{% endif %}</span><form method="post" action="{% url 'food:inventory-add-one' item.pk %}">{% csrf_token %}<button class="button button--secondary" type="submit">+1 existing item</button></form></div>{% endfor %}<p>Use the form below to add this product separately.</p></section>{% endif %}
<form class="food-card inventory-form" method="post">{% csrf_token %}<input type="hidden" name="product" value="{{ product.pk }}">{{ form.non_field_errors }}
{% for field in form %}<div class="form-field">{{ field.label_tag }}{% if field.name == 'quantity' %}<div class="inventory-quantity" data-inventory-quantity><button type="button" data-inventory-step="-1" aria-label="Decrease quantity">−</button>{{ field }}<button type="button" data-inventory-step="1" aria-label="Increase quantity">+</button></div>{% else %}{{ field }}{% endif %}{{ field.errors }}</div>{% endfor %}
<datalist id="inventory-locations">{% for location in locations %}<option value="{{ location.name }}">{% endfor %}</datalist><datalist id="inventory-categories">{% for category in categories %}<option value="{{ category.name }}">{% endfor %}</datalist>
<button class="button" type="submit">Add to inventory</button></form>
<a href="{% url 'food:inventory-add' %}">Choose another product</a>
{% else %}
<form method="get" class="food-search"><label for="inventory-query">Search saved products</label><input id="inventory-query" name="q" type="search" value="{{ query }}" autofocus><button class="button" type="submit">Search</button></form>
<ul class="food-product-list">{% for item in products %}<li><a href="{% url 'food:inventory-add' %}?product={{ item.pk }}">{% if item.image_url %}<img src="{{ item.image_url }}" alt="" loading="lazy">{% endif %}<span><strong>{{ item.product_name }}</strong>{% if item.brand %}<small>{{ item.brand }}</small>{% endif %}</span></a></li>{% empty %}<li>No saved products found.</li>{% endfor %}</ul>
<div class="food-actions"><a class="button" href="{% url 'food:scanner' %}?mode=inventory">Scan barcode</a><a class="button button--secondary" href="{% url 'food:inventory-external' %}?q={{ query|urlencode }}">Search Open Food Facts</a><a class="button button--secondary" href="{% url 'food:inventory-manual' %}">Create manual product</a></div>
<form method="post" action="{% url 'food:inventory-lookup' %}" class="food-barcode-form">{% csrf_token %}<label for="inventory-barcode">Enter barcode</label><input id="inventory-barcode" name="barcode" inputmode="numeric" pattern="[0-9]+" required><button class="button button--secondary" type="submit">Look up</button></form>
{% endif %}</div><script src="{% static 'food/inventory.js' %}" defer></script>{% endblock %}
@@ -0,0 +1,3 @@
{% extends 'planner/base.html' %}{% load static %}
{% block title %}Edit inventory item · Tasknest{% endblock %}
{% block content %}<link rel="stylesheet" href="{% static 'food/food.css' %}"><div class="food-form-page inventory-page"><a href="{% url 'food:inventory' %}">← Kitchen Inventory</a><h1>Edit {{ item.product.product_name }}</h1><form method="post" class="food-card inventory-form">{% csrf_token %}{{ form.non_field_errors }}{% for field in form %}<div class="form-field">{{ field.label_tag }}{% if field.name == 'quantity' %}<div class="inventory-quantity" data-inventory-quantity><button type="button" data-inventory-step="-1" aria-label="Decrease quantity">−</button>{{ field }}<button type="button" data-inventory-step="1" aria-label="Increase quantity">+</button></div>{% else %}{{ field }}{% endif %}{{ field.errors }}</div>{% endfor %}<datalist id="inventory-locations">{% for location in locations %}<option value="{{ location.name }}">{% endfor %}</datalist><datalist id="inventory-categories">{% for category in categories %}<option value="{{ category.name }}">{% endfor %}</datalist><button class="button" type="submit">Save changes</button></form></div><script src="{% static 'food/inventory.js' %}" defer></script>{% endblock %}
@@ -0,0 +1,3 @@
{% extends 'planner/base.html' %}{% load static %}
{% block title %}Search products · Tasknest{% endblock %}
{% block content %}<link rel="stylesheet" href="{% static 'food/food.css' %}"><div class="food-form-page"><a href="{% url 'food:inventory-add' %}">← Add item</a><h1>Search Open Food Facts</h1><form method="post" class="food-search">{% csrf_token %}<label for="inventory-external-query">Product name</label><input id="inventory-external-query" name="q" type="search" value="{{ query }}" required><button class="button" type="submit">Search</button></form>{% if notice %}<p role="status">{{ notice }}</p>{% endif %}<ul class="food-product-list">{% for item in results %}<li><form method="post" action="{% url 'food:inventory-lookup' %}">{% csrf_token %}<input type="hidden" name="barcode" value="{{ item.barcode }}"><button type="submit" class="food-result-button">{% if item.image_url %}<img src="{{ item.image_url }}" alt="" loading="lazy">{% endif %}<span><strong>{{ item.product_name }}</strong>{% if item.brand %}<small>{{ item.brand }}</small>{% endif %}</span></button></form></li>{% empty %}{% if request.method == 'POST' and not notice %}<li>No products found. <a href="{% url 'food:inventory-manual' %}">Create one manually</a>.</li>{% endif %}{% endfor %}</ul><p class="food-attribution">Product data from <a href="https://world.openfoodfacts.org/" rel="noopener noreferrer">Open Food Facts</a>.</p></div>{% endblock %}
@@ -0,0 +1,3 @@
{% extends 'planner/base.html' %}{% load static %}
{% block title %}Create inventory product · Tasknest{% endblock %}
{% block content %}<link rel="stylesheet" href="{% static 'food/food.css' %}"><div class="food-form-page"><a href="{% url 'food:inventory-add' %}">← Add item</a><h1>Create product</h1><p>Save a product to the shared food catalogue. Nutrition can be added later.</p><form method="post" class="food-card inventory-form">{% csrf_token %}{% for field in form %}<div class="form-field">{{ field.label_tag }}{{ field }}{{ field.errors }}</div>{% endfor %}<button class="button" type="submit">Continue to inventory</button></form></div>{% endblock %}
@@ -0,0 +1,6 @@
{% extends 'planner/base.html' %}{% load static %}
{% block title %}Kitchen Inventory · Tasknest{% endblock %}
{% block content %}<link rel="stylesheet" href="{% static 'food/food.css' %}">
<div class="food-page inventory-page"><header class="food-heading"><div><h1>Kitchen Inventory</h1><p>What you have and where it lives.</p></div><a class="button" href="{% url 'food:inventory-add' %}">+ Add item</a></header>
<form method="get" class="food-card inventory-filters"><label>Search<input type="search" name="q" value="{{ query }}"></label><label>Location<select name="location"><option value="">All locations</option>{% for location in locations %}<option value="{{ location.pk }}" {% if selected_location == location.pk|stringformat:'s' %}selected{% endif %}>{{ location.name }}</option>{% endfor %}</select></label><label>Category<select name="category"><option value="">All categories</option>{% for category in categories %}<option value="{{ category.pk }}" {% if selected_category == category.pk|stringformat:'s' %}selected{% endif %}>{{ category.name }}</option>{% endfor %}</select></label><label>Opened<select name="opened"><option value="">All</option><option value="yes" {% if opened == 'yes' %}selected{% endif %}>Opened</option><option value="no" {% if opened == 'no' %}selected{% endif %}>Unopened</option></select></label><label>Sort<select name="sort"><option value="location" {% if sort == 'location' %}selected{% endif %}>Location</option><option value="category" {% if sort == 'category' %}selected{% endif %}>Category</option><option value="name" {% if sort == 'name' %}selected{% endif %}>Product name</option><option value="recent" {% if sort == 'recent' %}selected{% endif %}>Recently added</option><option value="best_before" {% if sort == 'best_before' %}selected{% endif %}>Best before</option></select></label><label class="inventory-check"><input type="checkbox" name="use_soon" value="1" {% if use_soon == '1' %}checked{% endif %}> Use soon</label><button class="button" type="submit">Apply</button></form>
{% for item in items %}{% if sort == 'location' %}{% ifchanged item.location_id %}<h2 class="inventory-group">{{ item.location.name }}</h2>{% endifchanged %}{% endif %}<article class="food-card inventory-row">{% if item.product.image_url %}<img src="{{ item.product.image_url }}" alt="" loading="lazy">{% endif %}<div class="inventory-row-main"><h3>{{ item.product.product_name }}</h3>{% if item.product.brand %}<p>{{ item.product.brand }}</p>{% endif %}<p>Qty: {{ item.quantity }} · {{ item.location.name }}{% if item.category %} · {{ item.category.name }}{% endif %}</p>{% if item.opened %}<span class="inventory-tag">Opened</span>{% endif %}{% if item.best_before %}<span class="inventory-tag {% if item.best_before < today %}inventory-expired{% elif item.best_before <= soon_date %}inventory-soon{% endif %}">{% if item.best_before < today %}Expired{% elif item.best_before <= soon_date %}Use soon{% else %}Best before{% endif %} {{ item.best_before }}</span>{% endif %}</div><div class="inventory-row-actions"><form method="post" action="{% url 'food:inventory-quantity' item.pk %}">{% csrf_token %}<button type="submit" name="action" value="increase" aria-label="Increase quantity of {{ item.product.product_name }}">+1</button><button type="submit" name="action" value="used">Used up</button></form><a href="{% url 'food:inventory-edit' item.pk %}">Edit</a></div></article>{% empty %}<section class="food-card"><p>No inventory items found.</p><a class="button" href="{% url 'food:inventory-add' %}">Add your first item</a></section>{% endfor %}</div>{% endblock %}
+3 -3
View File
@@ -3,19 +3,19 @@
{% block content %} {% block content %}
<link rel="stylesheet" href="{% static 'food/food.css' %}"> <link rel="stylesheet" href="{% static 'food/food.css' %}">
<div class="food-scanner" data-food-scanner data-zxing-url="{% static 'food/vendor/zxing-browser.min.js' %}"> <div class="food-scanner" data-food-scanner data-zxing-url="{% static 'food/vendor/zxing-browser.min.js' %}">
<header class="food-scanner-header"><a href="{% url 'food:add' %}?date={{ day|date:'Y-m-d' }}&amp;meal={{ meal }}" data-scanner-close aria-label="Close barcode scanner">×</a><h1>Scan barcode</h1></header> <header class="food-scanner-header"><a href="{% if inventory_mode %}{% url 'food:inventory-add' %}{% else %}{% url 'food:add' %}?date={{ day|date:'Y-m-d' }}&amp;meal={{ meal }}{% endif %}" data-scanner-close aria-label="Close barcode scanner">×</a><h1>Scan barcode</h1></header>
<p>Point your camera at an EAN or UPC food barcode.</p> <p>Point your camera at an EAN or UPC food barcode.</p>
<div class="food-camera-frame"><video data-scanner-video autoplay muted playsinline aria-label="Camera preview"></video><div class="food-scan-guide" aria-hidden="true"></div></div> <div class="food-camera-frame"><video data-scanner-video autoplay muted playsinline aria-label="Camera preview"></video><div class="food-scan-guide" aria-hidden="true"></div></div>
<p data-scanner-status role="status" aria-live="polite">Camera is off.</p> <p data-scanner-status role="status" aria-live="polite">Camera is off.</p>
<button class="button" type="button" data-scanner-start>Start camera</button> <button class="button" type="button" data-scanner-start>Start camera</button>
<button class="button button--secondary" type="button" data-scanner-stop hidden>Stop camera</button> <button class="button button--secondary" type="button" data-scanner-stop hidden>Stop camera</button>
<form method="post" action="{% url 'food:import-product' %}" data-scanner-form class="food-barcode-form"> <form method="post" action="{% if inventory_mode %}{% url 'food:inventory-lookup' %}{% else %}{% url 'food:import-product' %}{% endif %}" data-scanner-form class="food-barcode-form">
{% csrf_token %}<input type="hidden" name="date" value="{{ day|date:'Y-m-d' }}"><input type="hidden" name="meal" value="{{ meal }}"> {% csrf_token %}<input type="hidden" name="date" value="{{ day|date:'Y-m-d' }}"><input type="hidden" name="meal" value="{{ meal }}">
<label for="scanner-barcode">Enter barcode manually</label><input id="scanner-barcode" data-scanner-barcode name="barcode" inputmode="numeric" pattern="[0-9]+" required> <label for="scanner-barcode">Enter barcode manually</label><input id="scanner-barcode" data-scanner-barcode name="barcode" inputmode="numeric" pattern="[0-9]+" required>
<button class="button button--secondary" type="submit">Look up barcode</button> <button class="button button--secondary" type="submit">Look up barcode</button>
</form> </form>
<p class="food-attribution">Product data from <a href="https://world.openfoodfacts.org/" rel="noopener noreferrer">Open Food Facts</a>.</p> <p class="food-attribution">Product data from <a href="https://world.openfoodfacts.org/" rel="noopener noreferrer">Open Food Facts</a>.</p>
</div> </div>
<nav class="food-mobile-switch" aria-label="Add food method"><a href="{% url 'food:add' %}?date={{ day|date:'Y-m-d' }}&amp;meal={{ meal }}">Search</a><span aria-current="page">Barcode</span></nav> <nav class="food-mobile-switch" aria-label="Add food method"><a href="{% if inventory_mode %}{% url 'food:inventory-add' %}{% else %}{% url 'food:add' %}?date={{ day|date:'Y-m-d' }}&amp;meal={{ meal }}{% endif %}">Search</a><span aria-current="page">Barcode</span></nav>
<script src="{% static 'food/scanner.js' %}" defer></script> <script src="{% static 'food/scanner.js' %}" defer></script>
{% endblock %} {% endblock %}
+45
View File
@@ -0,0 +1,45 @@
from unittest.mock import patch
from django.contrib.auth import get_user_model
from django.test import TestCase
from django.urls import reverse
from .models import FoodProduct, KitchenInventoryItem
class KitchenInventoryTests(TestCase):
def setUp(self):
self.user = get_user_model().objects.create_user(username='inventory-user', password='test-password')
self.other = get_user_model().objects.create_user(username='other-user', password='test-password')
self.client.force_login(self.user)
self.product = FoodProduct.objects.create(owner=self.user, barcode='12345678', product_name='Miso paste')
def test_cached_barcode_and_inventory_add(self):
with patch('food.inventory.cached_product') as lookup:
response = self.client.post(reverse('food:inventory-lookup'), {'barcode': '12345678'})
lookup.assert_not_called()
self.assertRedirects(response, f"{reverse('food:inventory-add')}?product={self.product.pk}", fetch_redirect_response=False)
response = self.client.post(reverse('food:inventory-add'), {
'product': self.product.pk, 'quantity': 2, 'location_name': 'Top cupboard', 'category_name': 'Sauces',
})
self.assertRedirects(response, reverse('food:inventory-add'))
item = KitchenInventoryItem.objects.get(user=self.user)
self.assertEqual((item.product, item.quantity, item.location.name, item.category.name),
(self.product, 2, 'Top cupboard', 'Sauces'))
self.assertContains(self.client.get(reverse('food:inventory')), 'Miso paste')
def test_used_up_archives_and_other_users_cannot_change_item(self):
self.client.post(reverse('food:inventory-add'), {'product': self.product.pk, 'quantity': 1, 'location_name': 'Fridge'})
item = KitchenInventoryItem.objects.get(user=self.user)
self.client.force_login(self.other)
self.assertEqual(self.client.post(reverse('food:inventory-quantity', args=[item.pk]), {'action': 'used'}).status_code, 404)
self.client.force_login(self.user)
self.client.post(reverse('food:inventory-quantity', args=[item.pk]), {'action': 'used'})
item.refresh_from_db()
self.assertIsNotNone(item.archived_at)
def test_manual_product_is_shared_with_food_log(self):
response = self.client.post(reverse('food:inventory-manual'), {'product_name': 'Loose onions', 'brand': '', 'barcode': '', 'package_quantity': ''})
product = FoodProduct.objects.get(owner=self.user, product_name='Loose onions')
self.assertRedirects(response, f"{reverse('food:inventory-add')}?product={product.pk}", fetch_redirect_response=False)
self.assertContains(self.client.get(reverse('food:add'), {'q': 'Loose onions'}), 'Loose onions')
+9 -1
View File
@@ -1,10 +1,18 @@
from django.urls import path from django.urls import path
from . import views from . import views, inventory
app_name = 'food' app_name = 'food'
urlpatterns = [ urlpatterns = [
path('inventory/', inventory.overview, name='inventory'),
path('inventory/add/', inventory.add, name='inventory-add'),
path('inventory/lookup/', inventory.lookup, name='inventory-lookup'),
path('inventory/search/openfoodfacts/', inventory.external_search, name='inventory-external'),
path('inventory/manual/', inventory.manual, name='inventory-manual'),
path('inventory/<int:pk>/edit/', inventory.edit, name='inventory-edit'),
path('inventory/<int:pk>/quantity/', inventory.change_quantity, name='inventory-quantity'),
path('inventory/<int:pk>/add-one/', inventory.add_existing, name='inventory-add-one'),
path('', views.diary, name='diary'), path('', views.diary, name='diary'),
path('add/', views.add_food, name='add'), path('add/', views.add_food, name='add'),
path('search/openfoodfacts/', views.external_search, name='external-search'), path('search/openfoodfacts/', views.external_search, name='external-search'),
+5 -4
View File
@@ -20,6 +20,7 @@ from .forms import FoodLogForm, ManualFoodForm
from .models import FoodFavourite, FoodLogEntry, FoodPortion, FoodProduct, MealType from .models import FoodFavourite, FoodLogEntry, FoodPortion, FoodProduct, MealType
from .services.diary import diary_context, selected_date from .services.diary import diary_context, selected_date
from .services.openfoodfacts import OpenFoodFactsError, cached_product, cached_search from .services.openfoodfacts import OpenFoodFactsError, cached_product, cached_search
from .services.products import local_products
from planner.timezones import localdate_for_user from planner.timezones import localdate_for_user
@@ -169,7 +170,7 @@ def add_food(request):
tab = request.GET.get('tab', 'overview') tab = request.GET.get('tab', 'overview')
if tab not in ('overview', 'recent', 'favourites', 'mine'): if tab not in ('overview', 'recent', 'favourites', 'mine'):
tab = 'overview' tab = 'overview'
products = FoodProduct.objects.filter(owner=request.user) products = local_products(request.user, query)
favourite_ids = set(FoodFavourite.objects.filter(user=request.user).values_list('product_id', flat=True)) favourite_ids = set(FoodFavourite.objects.filter(user=request.user).values_list('product_id', flat=True))
recent_ids = list(FoodLogEntry.objects.filter(user=request.user, product__isnull=False) recent_ids = list(FoodLogEntry.objects.filter(user=request.user, product__isnull=False)
.values('product_id').annotate(last_used=Max('created_at')) .values('product_id').annotate(last_used=Max('created_at'))
@@ -177,8 +178,6 @@ def add_food(request):
recent_rank = {product_id: index for index, product_id in enumerate(recent_ids)} recent_rank = {product_id: index for index, product_id in enumerate(recent_ids)}
if query: if query:
normalized = ' '.join(query.split()).casefold() normalized = ' '.join(query.split()).casefold()
for token in normalized.split():
products = products.filter(Q(product_name__icontains=token) | Q(brand__icontains=token) | Q(barcode__icontains=token))
def rank(item): def rank(item):
name = ' '.join(item.product_name.split()).casefold() name = ' '.join(item.product_name.split()).casefold()
return (0 if item.barcode == normalized else 1 if name == normalized else return (0 if item.barcode == normalized else 1 if name == normalized else
@@ -304,13 +303,15 @@ def import_product(request):
@login_required @login_required
def scanner(request): def scanner(request):
if request.GET.get('mode') == 'inventory':
return render(request, 'food/scanner.html', {'inventory_mode': True})
day, error = _day(request) day, error = _day(request)
if error: if error:
return error return error
meal = request.GET.get('meal') or MealType.BREAKFAST meal = request.GET.get('meal') or MealType.BREAKFAST
if meal not in MealType.values: if meal not in MealType.values:
return HttpResponseBadRequest('Invalid meal.') return HttpResponseBadRequest('Invalid meal.')
return render(request, 'food/scanner.html', {'day': day, 'meal': meal}) return render(request, 'food/scanner.html', {'day': day, 'meal': meal, 'inventory_mode': False})
@login_required @login_required
+1
View File
@@ -24,6 +24,7 @@
<a id="daily-planner-nav" class="{% if onboarding_tour.target == 'daily-planner' %}onboarding-highlight{% endif %}" href="{% url 'planner:daily-planner' %}">Daily planner</a> <a id="daily-planner-nav" class="{% if onboarding_tour.target == 'daily-planner' %}onboarding-highlight{% endif %}" href="{% url 'planner:daily-planner' %}">Daily planner</a>
<a id="health-nav" class="{% if onboarding_tour.target == 'wellbeing' %}onboarding-highlight{% endif %}" href="{% url 'planner:health' %}">Health</a> <a id="health-nav" class="{% if onboarding_tour.target == 'wellbeing' %}onboarding-highlight{% endif %}" href="{% url 'planner:health' %}">Health</a>
<a href="{% url 'food:diary' %}">Food</a> <a href="{% url 'food:diary' %}">Food</a>
<a href="{% url 'food:inventory' %}">Kitchen Inventory</a>
<a id="settings-nav" class="{% if onboarding_tour.target == 'settings' %}onboarding-highlight{% endif %}" href="{% url 'planner:user-settings' %}">Settings</a> <a id="settings-nav" class="{% if onboarding_tour.target == 'settings' %}onboarding-highlight{% endif %}" href="{% url 'planner:user-settings' %}">Settings</a>
<form method="post" action="{% url 'planner:user-settings' %}" class="theme-toggle">{% csrf_token %}<input type="hidden" name="section" value="appearance"><input type="hidden" name="next" value="{{ request.path }}">{% if user_appearance == 'dark' %}<input type="hidden" name="appearance" value="light"><button type="submit" aria-label="Use light mode" title="Use light mode"><span aria-hidden="true">☀</span><span class="sr-only">Use light mode</span></button>{% else %}<input type="hidden" name="appearance" value="dark"><button type="submit" aria-label="Use dark mode" title="Use dark mode"><span aria-hidden="true">☾</span><span class="sr-only">Use dark mode</span></button>{% endif %}</form> <form method="post" action="{% url 'planner:user-settings' %}" class="theme-toggle">{% csrf_token %}<input type="hidden" name="section" value="appearance"><input type="hidden" name="next" value="{{ request.path }}">{% if user_appearance == 'dark' %}<input type="hidden" name="appearance" value="light"><button type="submit" aria-label="Use light mode" title="Use light mode"><span aria-hidden="true">☀</span><span class="sr-only">Use light mode</span></button>{% else %}<input type="hidden" name="appearance" value="dark"><button type="submit" aria-label="Use dark mode" title="Use dark mode"><span aria-hidden="true">☾</span><span class="sr-only">Use dark mode</span></button>{% endif %}</form>
<form method="post" action="{% url 'planner:logout' %}" class="nav-logout">{% csrf_token %}<button type="submit">Log out</button></form> <form method="post" action="{% url 'planner:logout' %}" class="nav-logout">{% csrf_token %}<button type="submit">Log out</button></form>