feat(events): series-level gathering and deadline offsets

EventSeries gains gathering_offset and deadline_offset (durations before
the start). Each generated occurrence derives its gathering/deadline from
them (and clears them when unset); propagate_series pushes offset changes
to non-detached future occurrences. Surface them in the admin. 100%
coverage.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-12 18:04:14 +02:00
parent ca34d26a8e
commit c535e5dc8c
5 changed files with 59 additions and 3 deletions

View File

@@ -245,6 +245,24 @@ class GenerateOccurrencesTests(RecurrenceTestBase):
self.assertEqual(series.occurrences.count(), 4)
def test_gathering_and_deadline_come_from_offsets(self):
series = self.make_series(gathering_offset=timedelta(minutes=30), deadline_offset=timedelta(days=1))
generate_occurrences(series, self.anchor + timedelta(days=30))
first = series.occurrences.order_by("start").first()
self.assertEqual(first.gathering, self.anchor - timedelta(minutes=30))
self.assertEqual(first.deadline, self.anchor - timedelta(days=1))
def test_without_offsets_gathering_and_deadline_are_blank(self):
series = self.make_series()
generate_occurrences(series, self.anchor + timedelta(days=30))
first = series.occurrences.order_by("start").first()
self.assertIsNone(first.gathering)
self.assertIsNone(first.deadline)
class SingleOccurrenceTests(RecurrenceTestBase):
def test_cancel_deletes_and_prevents_regeneration(self):
@@ -298,6 +316,17 @@ class SingleOccurrenceTests(RecurrenceTestBase):
event = series.occurrences.order_by("start").first()
self.assertIn(carol.id, set(event.attendances.values_list("member_id", flat=True)))
def test_propagation_updates_timing_offsets(self):
series = self.make_series()
generate_occurrences(series, self.anchor + timedelta(days=30))
series.gathering_offset = timedelta(minutes=45)
series.save()
propagate_series(series)
first = series.occurrences.order_by("start").first()
self.assertEqual(first.gathering, self.anchor - timedelta(minutes=45))
class ExtendSeriesCommandTests(RecurrenceTestBase):
def test_command_generates_occurrences(self):