Slice 3 fits on one screen
builds on: Long sessions: lost instructions and drift, You own every line the agent writes
This is the whole diff for slice 3 (HttpResponseForbidden is already imported). With one concern on screen, you can ask the real question: is `is_staff` the rule you meant, or should it be "may this user view report 7"? The test only proves a non-staff user gets a 403. Nothing checks that an allowed user still gets the CSV. **Later cost:** every staff member can export every report, and users allowed to view report 7 are refused. In the 1,900-line version, this check sat in file 14 of 23, and nobody asked.
// Python
--- a/reports/views.py
+++ b/reports/views.py
@@ -12,1 +12,3 @@
report = get_report(report_id)
+ if not request.user.is_staff:
+ return HttpResponseForbidden()
--- a/reports/tests/test_export.py
+++ b/reports/tests/test_export.py
@@ -40,0 +41,4 @@
+def test_export_forbidden(client, user):
+ client.force_login(user)
+ r = client.get("/reports/7/export.csv")
+ assert r.status_code == 403