Skip to content

Validate constraints.meals_mode + meals_note (times-only meal schedules) - #267

Merged
gregv merged 1 commit into
developfrom
feature/meals-schedule-only-mode
Aug 19, 2026
Merged

Validate constraints.meals_mode + meals_note (times-only meal schedules)#267
gregv merged 1 commit into
developfrom
feature/meals-schedule-only-mode

Conversation

@gregv

@gregv gregv commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

What

Companion to frontend PR opportunity-hack/frontend-ohack.dev#350 (times-only meals mode). The frontend adds two hackathon constraint keys:

  • constraints.meals_mode: "menu" (default; hackers pick one item per slot) | "schedule" (times-only — the hacker application shows just the meal schedule, nothing to select)
  • constraints.meals_note: optional intro line shown above the times-only schedule

Both keys already flow through the permissive constraints passthrough; this PR makes them validated:

  • New ALLOWED_MEALS_MODES = {"menu", "schedule"} and MAX_MEALS_NOTE_LENGTH = 500 in common/utils/validators.py, kept in sync with MEALS_MODE_* / MEALS_NOTE_MAX_LENGTH in the frontend src/components/ApplicationForm/MealSchedule.js.
  • validate_hackathon_data: rejects unknown/non-string meals_mode and non-string/over-length meals_note (None/"" are fine — they resolve to the default menu mode).
  • validate_hackathon_data_partial: same checks with the established skip-and-strip semantics, so one bad key never blocks the rest of an admin save.

No change to validate_meals itself — a meal with no items was already valid, which is what times-only slots produce.

Tests

test/common/utils/test_validators.py: meals with no items pass validate_meals; both modes + unset/empty accepted; bad mode (string and unhashable) rejected; note length/type bounds; partial validator keeps valid values and strips invalid ones while saving the rest. python -m pytest test/common/utils/test_validators.py → 10 passed.

🤖 Generated with Claude Code

The frontend adds a times-only meals mode: meals_mode "schedule" shows
hackers just the meal times (no item selection) with an optional meals_note
intro line. Both hackathon validators now enforce meals_mode in
ALLOWED_MEALS_MODES {menu, schedule} and meals_note as a string capped at
MAX_MEALS_NOTE_LENGTH (500), with partial-save skip semantics. Kept in sync
with MEALS_MODE_* / MEALS_NOTE_MAX_LENGTH in the frontend MealSchedule.js.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@gregv
gregv merged commit 7720ff0 into develop Aug 19, 2026
6 checks passed
@gregv
gregv deleted the feature/meals-schedule-only-mode branch August 19, 2026 04:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant