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 -
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 -
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 -
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 -
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
-
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 -
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 -
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 -
feat(purge): backend marks purged account and exposes ack endpoint
Greg +1: Claude Sonnet 4.6- Account model: last_purged_at, last_purge_acknowledged_at columns - /developer/purge-demo: stamps last_purged_at + clears ack before commit - /auth/me: returns account_purged_at ISO string when purge unacknowledged - POST /auth/ack-purge: admin-only endpoint to dismiss the purge notice Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>a5f2d1b -
feat(developer): backend endpoint to purge and re-seed demo account
Greg +1: Claude Sonnet 4.6Adds POST /developer/purge-demo that verifies developer password, deletes all rows belonging to the demo account in dependency order, then calls seed_demo.seed() to restore the seeded state. Also adds PurgeDemoRequest schema to auth.py. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>ddae258 -
feat(schedule): fit PDF in single page + use plantel name as title
Greg +1: Claude Opus 4.7 (1M context)Backend: - /auth/me incluye organization_name desde Account; frontend lo persiste en authStore para uso en todo el cliente. Frontend: - ScheduleGrid en modo compact (print) ahora oculta filas de horas vacias (slots sin ningun bloque en dias visibles), reduciendo significativamente el alto total. Tamanos chicos: min-h 40px, text-xs, gap-1, time col 80px, padding ajustado. - ScheduleViewerModal usa organization_name del authStore como H1 primario del PDF y la seccion + periodo como subtitulo. - Print margin reducido de 0.5in a 0.35in para mas espacio util. Resultado: horario tipico (8-9 horas de clase, 5 dias) ahora cabe en una sola pagina letter landscape. Nota operativa: usuarios con session persistida vieja necesitan re-login para que organization_name aparezca en el authStore; mientras tanto el titulo PDF cae al subtitulo solo (Horario -- seccion). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>413032b -
fix(timezone): use UTC-aware datetime for DB storage
Greg +1: Claude Opus 4.7 (1M context)Bug: el container HF Space corre con TZ=America/Caracas (ver Dockerfile linea 24). datetime.now() retornaba naive datetime con hora local Caracas; psycopg2 lo almacenaba en columna timestamp with timezone asumiendo UTC. Resultado: el valor en BD quedaba 4h adelantado en UTC, y al leerlo y convertirlo de vuelta a local salia 4h atrasado (ej: usuario hace checkout a las 22:17, se muestra 18:17). checkin_time funcionaba bien porque usa server_default=func.now() de Postgres (genera timestamp tz-aware correcto del lado servidor). Fix: reemplazar datetime.now() por datetime.now(timezone.utc) en todas las asignaciones a columnas DateTime(timezone=True): - attendances.py: 3 checkouts (admin-early, late-note, self toggle) - facial.py: 2 checkouts (facial check-out, manual check-out) - teacher.py: 3 time_log assignments en Attendance (swipe + batch toggle + toggle_attendance) - developer.py: trial_end_date Comparaciones in-memory (now_minutes para verificar horario de clase) se dejan con d…4a12934 -
feat(schedule): spinner, filtered subjects, and teacher name in modal
Greg +1: Claude Opus 4.7 (1M context)Cambios coordinados al modal de horario por sección: Backend: - SectionScheduleResponse incluye teacher_id y teacher_name. - list_section_schedules + update_section_schedules baten un solo query contra TeacherSection para resolver (section_id, subject_id) -> teacher y populan teacher_name en la respuesta. Frontend: - ScheduleModal: nuevo state loading con LoadingState centrado mientras llega el fetch inicial. Antes mostraba grilla vacia durante ~750ms. - ScheduleModal: prop renombrada a sectionSubjects y filtra el dropdown a SOLO las materias asignadas a esa seccion. "+ Crear materia" sigue funcionando. - Bloque renderiza "Subject - Teacher" cuando hay docente asignado. - SectionsPage pasa items.find(...).subjects al nuevo prop. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>fc9e304 -
fix(dashboard): use string comparison for User.is_active (was boolean)
Greg +1: Claude Opus 4.7 (1M context)User.is_active es String(1) (legacy MariaDB) almacenando "1"/"0". La query del admin en /dashboard/stats usaba User.is_active == True que Postgres rechazaba con UndefinedFunction: "operator does not exist: character varying = boolean". El resto del codebase ya usaba == "1" correctamente; este endpoint estaba inconsistente. Bug visible: /dashboard/stats devolvía 500 al loguearse como admin. Fix mínimo: cambiar las 2 ocurrencias en dashboard.py (líneas 100,106). Account.is_active SÍ es Boolean real (account.py:18), no se toca. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>d7c5321 -
perf(section-subjects): eliminate N+1 in GET and PUT /section-subjects
Greg +1: Claude Opus 4.7 (1M context)Batch-load all subjects in a single query for the GET list. For the PUT, replace per-subject validation loop with a single batch query to fetch valid subject IDs, then filter on that set. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>db14bae -
perf(teacher-subjects): eliminate N+1 in GET and PUT /teacher-subjects
Greg +1: Claude Opus 4.7 (1M context)Batch-load all subjects in a single query for the GET list. For the PUT, replace per-subject conflict-check loop with a single filtered query plus batch user/subject lookups; also batch-validate subject ownership before inserting. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>7d5d51b -
perf(teacher-sections): eliminate N+1 in GET /teacher-sections
Greg +1: Claude Opus 4.7 (1M context)Refactor _enrich to accept pre-fetched users_by_id and subjects_by_id dicts. Build both dicts with single batch queries before the list comprehension; _enrich now does only dict lookups. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>8c218e0 -
perf(teacher): eliminate N+1 in /subjects, /sections, /schedule
Greg +1: Claude Opus 4.7 (1M context)Batch-load Subject, Section, and Enrollment counts before the assignment loop in /subjects and /sections. Inline _section_subjects helper with pre-fetched SectionSubject rows grouped by section_id. Batch-load Section+Subject before the schedule loop in /schedule. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>bc019a7
-
perf(representative): eliminate 1+6N in /children with full batch preload
Greg +1: Claude Opus 4.7 (1M context)Replace per-child queries for Enrollment, Section, SectionSchedule, Attendance (today + 30-day count), and EntranceLog with 6 batch queries upfront; loop now does only dict lookups — zero DB calls per child. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>dcc7429