From c7c3b4a15e0c011b447b59785b3c9a61b1159ba0 Mon Sep 17 00:00:00 2001 From: Daniel Holbach Date: Wed, 1 Jul 2026 11:42:24 +0200 Subject: [PATCH] fix: clear TimeOff entries in seed --clear TimeOff records created by seed_sample_data were never deleted on --clear. Add SEED_TIMEOFF_TITLES constant and delete matching rows in _clear(), same pattern as SEED_TODO_TITLES. Co-Authored-By: Claude Sonnet 4.6 --- .../management/commands/seed_sample_data.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/my_practice/management/commands/seed_sample_data.py b/app/my_practice/management/commands/seed_sample_data.py index 9bafd3a..0522e16 100644 --- a/app/my_practice/management/commands/seed_sample_data.py +++ b/app/my_practice/management/commands/seed_sample_data.py @@ -450,6 +450,16 @@ SEED_TAG_NAMES: frozenset[str] = frozenset( ["Einzeltherapie", "Langzeitklient", "Kurzzeitintervention", "Gruppentherapie"] ) +SEED_TIMEOFF_TITLES: frozenset[str] = frozenset( + [ + "Osterurlaub", + "Fortbildung Traumatherapie", + "Sommerurlaub", + "Herbstpause", + "Weihnachtsurlaub", + "Supervision-Intensivtag", + ] +) class Command(BaseCommand): @@ -1107,12 +1117,14 @@ def _clear(self, skip_confirm: bool) -> None: demo_practice and CompanyExpense.objects.filter(practice=demo_practice).exists() ) has_inquiries = ClientInquiry.objects.filter(full_name__in=SEED_INQUIRY_NAMES).exists() + has_timeoff = TimeOff.objects.filter(title__in=SEED_TIMEOFF_TITLES).exists() if ( not seeded.exists() and not has_todos and not has_expenses and not has_inquiries + and not has_timeoff and not demo_practice ): self.stdout.write(" Nothing to clear.") @@ -1143,6 +1155,7 @@ def _clear(self, skip_confirm: bool) -> None: seeded.delete() ClientInquiry.objects.filter(full_name__in=SEED_INQUIRY_NAMES).delete() PracticeTodo.objects.filter(title__in=SEED_TODO_TITLES).delete() + TimeOff.objects.filter(title__in=SEED_TIMEOFF_TITLES).delete() if demo_practice: CompanyExpense.objects.filter(practice=demo_practice).delete() UserPractice.objects.filter(practice=demo_practice).delete() @@ -1163,6 +1176,8 @@ def _clear(self, skip_confirm: bool) -> None: parts.append("todos") if has_inquiries: parts.append("inquiries") + if has_timeoff: + parts.append("time-off entries") if has_expenses: parts.append("expenses") if n_tags: