PATCH /api/events/<id> updates the event but not its occurrences #67

Open
opened 2026-10-03 19:44:43 +00:00 by jalenluorion · 0 comments
Member

What's wrong
update_event() writes the new fields to the events row and stops (# TODO: update recurrence table, L844). Calendars, org pages and schedules read event_occurrences, so an edited event keeps its old title, time and location there. updated_recurrence from the web modal is ignored as well.

Simply calling regenerate_event_occurrences_by_event_ids() is not enough: it skips events that have no RecurrenceRule, and one-time events (the common case) have none.

How to reproduce
Seed an event and one ONETIME EventOccurrence for it, PATCH {"updated_event": {"title": "Renamed"}} as an admin, then GET /api/organizations/org/<org_id>: the response is 200 with title "Renamed", but the occurrence still says the old title.

Expected
After a successful PATCH, the event's occurrences match it: title, description, location, start/end and all-day.

Where to look

  • api/app/api/events.py update_event() (L792-855).
  • api/app/models/event_occurrence.py: regenerate_event_occurrences_by_event_ids() for events with a rule (PATCH sets last_updated_at first, so its timestamp check passes); for one-time events, delete_event_occurrences_by_event_id() plus save_event_occurrence(), the same as create_event_record() L226-248.
  • Line numbers are from main at 2c5f2e9.

Done when

  • one-time and recurring events both get updated occurrences in the same commit
  • tests in api/tests/api/test_event_patch_occurrences.py for both (see api/tests/factories/recurrence_rule_factory.py)
  • applying updated_recurrence is split into a follow-up issue
**What's wrong** `update_event()` writes the new fields to the `events` row and stops (`# TODO: update recurrence table`, L844). Calendars, org pages and schedules read `event_occurrences`, so an edited event keeps its old title, time and location there. `updated_recurrence` from the web modal is ignored as well. Simply calling `regenerate_event_occurrences_by_event_ids()` is not enough: it skips events that have no `RecurrenceRule`, and one-time events (the common case) have none. **How to reproduce** Seed an event and one ONETIME `EventOccurrence` for it, PATCH `{"updated_event": {"title": "Renamed"}}` as an admin, then GET `/api/organizations/org/<org_id>`: the response is 200 with title "Renamed", but the occurrence still says the old title. **Expected** After a successful PATCH, the event's occurrences match it: title, description, location, start/end and all-day. **Where to look** - `api/app/api/events.py` `update_event()` (L792-855). - `api/app/models/event_occurrence.py`: `regenerate_event_occurrences_by_event_ids()` for events with a rule (PATCH sets `last_updated_at` first, so its timestamp check passes); for one-time events, `delete_event_occurrences_by_event_id()` plus `save_event_occurrence()`, the same as `create_event_record()` L226-248. - Line numbers are from main at 2c5f2e9. **Done when** - [ ] one-time and recurring events both get updated occurrences in the same commit - [ ] tests in `api/tests/api/test_event_patch_occurrences.py` for both (see `api/tests/factories/recurrence_rule_factory.py`) - [ ] applying `updated_recurrence` is split into a follow-up issue
jalenluorion added this to the Phase 2 milestone 2026-10-03 19:44:43 +00:00
jalenluorion added this to the CMUCal project 2026-10-03 19:45:09 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ScottyLabs/cal#67
No description provided.