From a9f87541e0ef8940e2d8ea30cba031e2bea521c7 Mon Sep 17 00:00:00 2001 From: lizerk Date: Fri, 6 Mar 2026 20:59:25 +0300 Subject: [PATCH] =?UTF-8?q?fix(birthdays):=20=D0=B8=D1=81=D0=BF=D1=80?= =?UTF-8?q?=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=20=D0=BF=D0=BE=D0=B8=D1=81=D0=BA?= =?UTF-8?q?=20=D0=B8=20=D0=BE=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D1=81=D0=BE=D0=B1=D1=8B=D1=82=D0=B8=D0=B9=20?= =?UTF-8?q?=D0=94=D0=A0=20=D0=B8=D0=B7=20=D0=BF=D0=B5=D1=80=D1=81=D0=BE?= =?UTF-8?q?=D0=BD=D0=B0=D0=BB=D1=8C=D0=BD=D1=8B=D1=85=20=D0=BA=D0=B0=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B4=D0=B0=D1=80=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Убран фильтр по календарю при поиске существующих событий - События автоматически переносятся из personal-XX в общий календарь birthdays - Удаляются дубликаты событий ДР для одного сотрудника --- backend/employees/services/birthday_events.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/backend/employees/services/birthday_events.py b/backend/employees/services/birthday_events.py index d71a5f51..ce736d48 100644 --- a/backend/employees/services/birthday_events.py +++ b/backend/employees/services/birthday_events.py @@ -65,11 +65,10 @@ class UpsertBirthdayEventService(Service): title = f"🎂 День рождения: {str(employee)}" # Ищем существующее событие по creator + начало title (паттерн External ID) - # Используем startswith чтобы обновлять даже если имя сотрудника изменилось + # НЕ фильтруем по календарю, чтобы найти старые события в персональных календарях existing_event = Event.objects.filter( creator_id=employee.pk, - title__startswith='🎂 День рождения:', - calendar=calendar + title__startswith='🎂 День рождения:' ).first() # Создаем правило для ежегодного повторения @@ -94,14 +93,22 @@ class UpsertBirthdayEventService(Service): end_date = start_date + timedelta(hours=23, minutes=59, seconds=59) if existing_event: - # Обновляем существующее событие + # Обновляем существующее событие и переносим в правильный календарь existing_event.title = title existing_event.start = start_date existing_event.end = end_date + existing_event.calendar = calendar # Переносим в общий календарь birthdays existing_event.rule = rule existing_event.end_recurring_period = None # Бесконечное повторение existing_event.color_event = BIRTHDAY_COLOR existing_event.save() + + # Удаляем дубликаты (другие события ДР этого сотрудника) + Event.objects.filter( + creator_id=employee.pk, + title__startswith='🎂 День рождения:' + ).exclude(pk=existing_event.pk).delete() + return existing_event, False # Обновлено else: # Создаем новое событие