Spaces:
Runtime error
Runtime error
Commit History
-
feat(ta-01): backend-proxy photo URLs so they stop expiring
Greg +1: Claude Opus 4.7 (1M context)Frontend now receives stable /api/v1/photos/{account_id}/{user_id}/{filename} URLs for face photos, regardless of which storage backend is active. The serve_photo endpoint authenticates against our own JWT and streams the bytes from disk (local) or Supabase (S3 via boto3.get_object). Browser caches the response privately for 5 minutes so re-renders don't hit the backend. This eliminates the 10-min signed-URL expiry pain — the URL never changes and never goes stale. Same behavior on the local-disk dev backend and on Supabase in prod. - PhotoStorage Protocol gains fetch_bytes(path) -> (bytes, content_type). - Implemented on all three adapters (Local, InMemory, Supabase). - serve_photo routes through the protocol; per-backend logic moves there. - users.py response mapping and the upload endpoint return the proxied URL instead of storage.get_url() so legacy signed URLs are gone. Tests: 22 passed (storage + photo upload), no regressions. Co-Authored-By: Claude Opus 4.7 (1M context) <n…8ca1e92 -
fix(ta-01): re-protect /photos/_debug with admin RBAC
Greg3263790 -
diag(ta-01): make /photos/_debug public so it's accessible without login
Greg232390f -
diag(ta-01): log resolved photo backend + admin /photos/_debug endpoint
Gregccc4fb4 -
fix(ta-01): treat blank PHOTO_STORAGE_BACKEND as unset (default to local)
Grega1c2d97 -
refactor(ta-01): swap supabase-py for boto3 S3 adapter
Greg +1: Claude Opus 4.7 (1M context)The supabase-py SDK was ~70MB with sub-deps and only used for storage. Switch to boto3 against Supabase's S3-compatible endpoint. Same class name (SupabaseStorage) for adapter-pattern continuity; the constructor now takes access_key/secret_key/endpoint/region and uses presigned URLs via generate_presigned_url for private buckets. Env vars (HF Space Secrets): SUPABASE_ACCESS_KEY_ID (from Dashboard → Project Settings → Storage → S3) SUPABASE_ACCESS_KEY_SECRET SUPABASE_ENDPOINT (e.g. https://<ref>.storage.supabase.co/storage/v1/s3) SUPABASE_REGION (default us-west-2) SUPABASE_PHOTO_BUCKET (default user-photos) Side benefit: vendor-agnostic. The same adapter works against AWS S3, R2, MinIO by changing endpoint and region. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>959bccd -
feat(ta-01): implement SupabaseStorage adapter with signed URLs
Greg +1: Claude Opus 4.7 (1M context)- SupabaseStorage uploads to {account_id}/{user_id}/{uuid}.{ext} inside the configured bucket via supabase-py. get_url() returns a short-lived signed URL (default 10 min TTL) so private buckets stay private. - _strip_url_prefix normalizes inputs so delete() works whether given a relative path or a full Supabase URL (with or without query token). - supabase>=2.0 added to requirements; SDK is lazily imported so the local backend (PHOTO_STORAGE_BACKEND=local) doesn't pay the cost. - AuthImage now passes http(s):// URLs through directly (Supabase signed URLs are already authenticated via the token query param). - Tests updated to cover credential check, prefix stripping for relative paths and signed URLs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>ea91fea
-
revert(ta-01): role stays immutable on edit (per user request)
Greg6360fcb -
feat(ta-01): allow editing sex and role in user create/edit modal
Greg +1: Claude Opus 4.7 (1M context)Frontend (UsersPage): - Sex selector (Sin especificar / Masculino / Femenino) on create and edit. - Role select no longer disabled while editing; changes are diffed and sent in the PUT payload. Backend (schemas/user.py): - UserUpdate gains optional `role` so PUT /users/{id} can change it. - sex was already supported; just wiring it on the client side. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>bee4db8 -
feat(ta-01): photo upload + camera capture in user create/edit modal
Greg +1: Claude Opus 4.7 (1M context)Frontend (UsersPage): - New uploadUserPhoto / dataUrlToBlob helpers in userService.ts - Both "Capturar foto" (camera) and "Subir foto" (file picker accepting png/jpg/webp ≤5MB) now route through POST /api/v1/users/{id}/photo - Hidden file input wired via ref; live preview from either source - Format/size hint shown under the controls - Removed enrollFace from this flow (still used by FacialPage kiosk) Backend (facial.py enroll_face): Bug introduced by TA-01: face_encodings.photo became VARCHAR(500) but the kiosk enroll endpoint still tried to persist the raw base64 dataURL, which silently broke camera enrollment. Now decodes → processes via photo_pipeline → uploads via PhotoStorage → stores the path. If photo step fails, encoding is still saved (best-effort) so recognition works. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>9b72922 -
fix(ta-01): unify all dashboard chart counts as gate+class (deduped)
Greg +1: Claude Opus 4.7 (1M context)Extract three helpers in dashboard.py: _presence_user_ids_in_range — union of EntranceLog + Attendance "in" _exit_user_ids_in_range — union of EntranceLog.checkout + Attendance "out" _presence_user_ids_by_day — per-day version of presence union Refactor: /stats today_checkins = |present_today| /stats today_checkouts = |exited_today| /stats currently_on_campus = |present_today - exited_today| /attendance-trend per-day count = |union per day| These apply uniformly to admin and teacher roles. A student with both a gate check-in and a classroom mark on the same day counts ONCE per metric; a student marked only via classroom (TA-01 contingency) is now included. Regression tests cover: class-only inclusion, gate+class dedup, currently_on_campus subtraction across both event sources, and per-day trend dedup. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1abf246 -
fix(ta-01): dashboard sex-by-section counts class marks without gate log
Greg +1: Claude Opus 4.7 (1M context)The /dashboard/sex-by-section endpoint joined only EntranceLog, so students marked present via teacher/admin classroom attendance with no gate check-in (contingency path enabled by TA-01) were excluded from the chart. Now unions EntranceLog (gate) with Attendance.action='in' (classroom) and dedupes per (section, student). Regression test covers a student present in Attendance with zero EntranceLog rows. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>a62864b -
feat(ta-01): show sex breakdown (M/F) in admin attendance counter
Greg +1: Claude Opus 4.7 (1M context)- RosterItem dataclass + AdminRosterItem TS interface gain `sex` field. - AdminAttendancePage counter now shows "(M: N · F: N)" alongside Presentes. - Teacher response unchanged (StudentCardResponse doesn't include sex). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>4aadf35 -
fix(ta-01): post-review hardening — traversal guard, dead code, kiosco doc
Greg +1: Claude Opus 4.7 (1M context)- photos.py: resolve()+is_relative_to() guard against path traversal in GET /photos/{account_id}/{user_id}/{filename}. The account scope check alone did not prevent ../-style escape outside LOCAL_PHOTO_ROOT. - teacher.py: remove skipped_ids dead code in submit_swipe and batch_toggle. The lists were declared but never populated after the gate decouple, and the secondary SELECT to resolve student names ran on every swipe for no effect. Response shape unchanged (skipped: list[dict] = [] always). - facial.py: module docstring explaining that the kiosk path does not write Attendance directly; if it ever does, marked_by_role='kiosco' should be set. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>0e087c3 -
feat(ta-01): admin attendance endpoints (sections, roster, swipe, batch-toggle)
Greg +1: Claude Sonnet 4.6Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>138c1eb -
feat(ta-01): decouple classroom attendance from gate entrance log
Greg +1: Claude Sonnet 4.6Removes the EntranceLog gate-filter from submit_swipe, batch_toggle, and toggle_attendance so teachers can mark students present even when the gate kiosk is offline (power outage, OpenCV crash, network failure). The entrance_logged flag is preserved as informational in the roster/summary endpoints; no existing tests were broken. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>71c3a32 -
test(ta-01): regression test for gate ↔ classroom decouple
Greg +1: Claude Sonnet 4.6Adds three tests that expose (and then verify removal of) the coupling between EntranceLog gate check-in and classroom attendance marking in submit_swipe, batch_toggle, and toggle_attendance. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>5bea392 -
refactor(ta-01): route teacher attendance + roster through services/attendance
Greg +1: Claude Sonnet 4.6Routes all three attendance-insert endpoints (submit_swipe, batch_toggle, toggle_attendance) through record_attendance() so marked_by_role and marked_by_user_id are populated. Replaces the inline roster build in section_students with list_section_roster(). Gate filter (entrance_logged_ids skip) preserved intact in all three write endpoints. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>6a6810e -
feat(ta-01): add attendance service (record_attendance + list_section_roster)
Greg +1: Claude Sonnet 4.6Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>238a12d -
chore(ta-01): wire photo storage env vars and local volume
Greg +1: Claude Sonnet 4.6Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>22557a9 -
feat(ta-01): map face_encodings.photo path to URL in user responses
Greg +1: Claude Sonnet 4.6Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>adcd19e -
feat(ta-01): GET /photos endpoint for local storage backend
Greg +1: Claude Sonnet 4.6Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>ccb2eb5 -
feat(ta-01): POST /users/{id}/photo endpoint with storage + best-effort face encoding
Greg +1: Claude Sonnet 4.6Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>d116d3f -
chore(ta-01): pin pytest in requirements so tests run after rebuild
Greg0a530b0 -
fix(ta-01): use libmagic1 apt + python-magic for Linux container
Greg +1: Claude Opus 4.7 (1M context)Previous commit aa308f0 added python-magic-bin which is Windows-only. The backend container is Linux, so we need libmagic1 (apt) plus python-magic (PyPI) bindings. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>a965311 -
feat(ta-01): add photo_pipeline with WebP compression and validation
Greg +1: Claude Opus 4.7 (1M context)Adds image processing service with: - MIME type validation (PNG, JPEG, WebP only) - EXIF transpose handling - Thumbnail scaling to max 800x800 - WebP conversion with quality 85 - Test suite with 5 comprehensive test cases Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>34ae3e8 -
chore(ta-01): add Pillow and python-magic-bin deps for photo pipeline
Greg +1: Claude Opus 4.7 (1M context)Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>aa308f0 -
feat(ta-01): add PhotoStorage abstraction with Local/InMemory/Supabase adapters
Greg +1: Claude Sonnet 4.6Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>9e5f651 -
feat(ta-01): update FaceEncoding and Attendance models for new columns
Greg +1: Claude Opus 4.7 (1M context)- FaceEncoding: add photo column as String(500), make encoding nullable - Attendance: add marked_by_role (String) and marked_by_user_id (BigInteger FK) columns These changes match the schema updates from migration 028. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>f2358b4 -
docs(ta-01): warn about photo data loss; tighten FK ondelete
Gregfa350fe -
feat(ta-01): migration for photo URL column + attendance attribution
Greg9f37e9c
-
feat(accounts): add U.E.C Maria Antonia Valero demo account migration
Greg +1: Claude Opus 4.7 (1M context)Creates a parallel is_demo=true account with admin user (Rosmery Contreras) on alembic upgrade. Schedule L-V 07:00-12:00, facial check-in mode, pro plan. Idempotent inserts. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>c4b0d0f -
fix(dashboard): 400 on malformed section_ids; harden test cleanup
Greg +1: Claude Opus 4.7 (1M context)Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>fad8e8a -
feat(dashboard): add GET /sex-by-section endpoint
Greg +1: Claude Opus 4.7 (1M context)Returns per-section and aggregate sex counts of students with entrance logs in the requested date range; supports section_ids filter and teacher-scoped access. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>0eebffb -
feat(teacher): include present_today in swipe and batch-toggle responses
Greg +1: Claude Opus 4.7 (1M context)Both submit_swipe and batch_toggle now return a present_today field with sex-aggregated counts (masculino, femenino, sin_especificar, total) of students marked present in the section for the relevant day. Cleanup helper updated to also delete EntranceLog rows. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>43b8be0 -
fix(teacher): restore return statement in submit_swipe lost during edit
Greg +1: Claude Opus 4.7 (1M context)Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>e3b7903 -
feat(teacher): add GET /sections/{id}/present-summary for M/F chip
Greg +1: Claude Opus 4.7 (1M context)Returns masculino/femenino/sin_especificar/total counts of students with an 'in' Attendance record today (or a given ?date=). RBAC-gated to teacher role; owner-check via _ensure_teacher_section. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>100eb7b -
feat(attendances): report-export CSV ends with M/F totals block
Greg +1: Claude Opus 4.7 (1M context)Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>4d635e1 -
feat(attendances): today-export CSV ends with M/F totals block
Greg +1: Claude Opus 4.7 (1M context)Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>6720653 -
feat(reports): late-arrivals CSV ends with M/F totals block
Greg +1: Claude Opus 4.7 (1M context)Append a blank-separated totals block to the late-arrivals-export CSV using count_by_sex so consumers get Masculino / Femenino / (Sin especificar) / Total general without a second request. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>81106b5 -
feat(scripts): backfill users.sex for is_demo accounts
Greg +1: Claude Opus 4.7 (1M context)Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>95bfceb -
refactor(sex): cleaner import, drop sex= on system users, harden empty input
Greg +1: Claude Opus 4.7 (1M context)Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>5b2025a -
feat(seed): assign sex to all seeded users via sex_for helper
Greg +1: Claude Opus 4.7 (1M context)Extends sex_counts.py with KNOWN_FEMALE/KNOWN_MALE dictionaries and a sex_for(first_name, rng) function; patches seed_demo.py to pass sex=sex_for(...) on every User constructor (teachers, administrativos, obreros, representatives, students, admin, dev). Adds 3 new tests (7 total, all passing). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>0f56cb1 -
test(utils): cover empty-string sex and harden cross-account teardown
Greg +1: Claude Opus 4.7 (1M context)Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>c5d1f72 -
feat(utils): add count_by_sex helper for M/F/null aggregations
Greg +1: Claude Opus 4.7 (1M context)Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>5fc7b3b
-
feat(swipe): report students skipped due to missing entrance log
Greg +1: Claude Opus 4.7 (1M context)El endpoint /teacher/attendance/swipe ya filtraba estudiantes que no habian hecho check-in en porteria (sin EntranceLog hoy), pero solo devolvia counts sin decir cuales quedaron skip. El docente marcaba 20 estudiantes, recibia 'guardado correctamente' y veia que todos quedaron ausentes -- sin explicacion. Backend ahora devuelve skipped: [{student_id, name}, ...] siguiendo el mismo patron que batch_toggle ya implementaba. Frontend muestra toast naranja explicito cuando hay skip: - Si created > 0 y hay skipped: 'Se marcaron N presentes. M no se pudieron marcar porque aun no han ingresado al colegio (sin check-in en porteria): names...' - Si created == 0 (todos skipped): 'Ningun estudiante pudo ser marcado presente: aun no han ingresado...' Muestra hasta 3 nombres + 'y X mas' si hay mas para mantener el toast legible. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>4205050 -
feat(holidays): expose GET /holidays/dates endpoint
Greg +1: Claude Sonnet 4.6New router expands all holiday date ranges into flat sorted list of ISO strings. Registered in api/v1/router.py. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>a2e4db7 -
feat(teacher-attendance): allow marking outside schedule, structured audit
Greg +1: Claude Sonnet 4.6Remove _check_active_schedule and _check_not_before_class calls from swipe, batch-toggle, and toggle endpoints. Add _is_out_of_schedule helper and structured AuditLog entries (fuera_de_horario flag, section, subject, students_marked, click_time_utc) after each successful mark. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>ca484ca -
fix(purge): return 400 instead of 401 on wrong password
Greg +1: Claude Opus 4.7 (1M context)El axios interceptor en frontend/src/services/api.ts dispara clearAuth() + redirect a /login ante cualquier 401. Eso significa que cuando el developer escribe la password mal en el modal de purge, queda deslogeado en vez de ver el error en el modal. 400 (Bad Request) es semanticamente mas correcto: el developer SI esta autenticado (su JWT es valido); el password supplemental que dio no coincide. Es input invalido, no sesion expirada. Modal ya muestra err.response.data.detail al usuario, asi que el mensaje "Contrasena incorrecta" se ve igual. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>a3df693 -
fix(seed): resolve admin user before referencing in audit samples
Greg +1: Claude Opus 4.7 (1M context)seed_demo.py linea 422-435 construye audit_samples referenciando 'admin' como variable, pero esa variable nunca era asignada en el scope de seed(). Resultado: seed() siempre crasheaba con NameError: name 'admin' is not defined cuando intentaba poblar la auditoria de ejemplo, dejando el demo sin auditoria (y, en el caso del purge, sin nada porque seed se invoca despues de borrar todo). Fix: hacer db.query(User).filter(...).first() para 'admin' antes de la lista de audit_samples, igual que como teachers/students/reps ya estaban resueltos. La variable estaba definida en _ensure_base() pero no se exportaba al scope de seed(). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>d0af11d