Skip to content

Remaining "not in the future" date bounds compare against the server date, not the user's today (follow-up to #520) #534

Description

@gonzalesedwin1123

Follow-up to #520 / PR #533, which aligned registration_date and the birthdate checks in spp_registry on fields.Date.context_today. The same server-date comparison remains at these sites (found in the #533 review, repo-wide grep on 19.0 @ 1a3c591). A user west of UTC is refused their own today after 00:00 UTC; a user east of UTC is refused a date they have already reached.

Sites

  • spp_registry/models/phone_number.py:30-32, 46-49date_collected defaults to fields.Date.today and _check_date_collected refuses > fields.Date.today(). Same module and same registrant form as spp_registry: registration_date default and _birthdate_onchange still use the server date, refusing valid births east of UTC #520 (Phone Numbers tab). Secondary: it is an @api.onchange raising ValidationError, so it is UI-only and ORM/API/import writes bypass it, the gap Fix/362 birthdate not future #397 closed for birthdate with a stored-field constraint.
  • spp_programs/models/cycle.py:1355if record.start_date < fields.Date.today(): "The Start Date cannot be earlier than today." A user-picked date in a form; west of UTC the user's own today is refused. Arguably the most user-visible of the set.
  • spp_dci_client_crvs/models/crvs_event.py:154event_date > fields.Date.today().
  • spp_dci_client_dr/models/disability_status.py:129assessment_date > fields.Date.today().

Also noted in the same review (optional, same PR or separate)

  • spp_registry/models/registrant.py _check_registration_date: both error strings are not wrapped in _() and describe the boundary wrongly ("must be less than the current date" / "must be later than the birth date" while equality is accepted). Fix/362 birthdate not future #397 set the precedent of a translated message naming the record and the offending value.
  • spp_demo/models/demo_data_generator.py:381-385, 419-422dateto=fields.Date.today() for Faker's inclusive date_between_dates; hitting the end date is a ~1e-9 event, so purely tidiness, as Fix/362 birthdate not future #397 did for spp_mis_demo_v2.
  • spp_registry/models/individual.py:79 — the age compute uses fields.Datetime.now() (server), a different "today" than the constraint. Cosmetic: relativedelta clamps at 0 for a newborn born on the user's today east of UTC.

Fix

Per site: compare against fields.Date.context_today(record) (default: lambda self: fields.Date.context_today(self)), with tests on a frozen clock east and west of UTC as in spp_registry/tests/test_constraints.py::TestUserTodayAcrossTimezones. Each touched module needs its patch bump + HISTORY fragment.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions