From d1ea2d8c6ed368ffdfcdf102364782b31e41ff62 Mon Sep 17 00:00:00 2001 From: lizerk Date: Fri, 6 Mar 2026 17:47:19 +0300 Subject: [PATCH] =?UTF-8?q?fix(birthdays):=20=D0=B8=D0=B7=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D0=B5=D0=BD=D0=B0=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D0=B0?= =?UTF-8?q?=20=D0=BA=D0=B0=D0=BB=D0=B5=D0=BD=D0=B4=D0=B0=D1=80=D1=8F=20?= =?UTF-8?q?=D0=94=D0=A0=20=D0=BD=D0=B0=20=D0=BE=D0=B1=D1=89=D0=B8=D0=B9=20?= =?UTF-8?q?=D0=BA=D0=B0=D0=BB=D0=B5=D0=BD=D0=B4=D0=B0=D1=80=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Изменено событие на длительность до конца дня вместо 2 дней - Все ДР теперь добавляются в общий календарь '🎂 Дни рождения' - Убрана логика личных календарей для каждого сотрудника --- backend/employees/services/birthday_events.py | 34 +++++-------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/backend/employees/services/birthday_events.py b/backend/employees/services/birthday_events.py index 8efa65f1..d5097586 100644 --- a/backend/employees/services/birthday_events.py +++ b/backend/employees/services/birthday_events.py @@ -22,7 +22,7 @@ class UpsertBirthdayEventService(Service): Сервис создания/обновления события дня рождения сотрудника. Использует паттерн External ID: creator_id + title для идентификации. - Создает ежегодное повторяющееся событие в личном календаре сотрудника. + Создает ежегодное повторяющееся событие в общем календаре "🎂 Дни рождения". """ employee = ModelField(Employee) @@ -37,11 +37,11 @@ class UpsertBirthdayEventService(Service): 'event': None } - # Получаем личный календарь сотрудника - personal_calendar = self._get_or_create_personal_calendar(employee) + # Получаем общий календарь дней рождений + birthday_calendar = self._get_or_create_birthday_calendar() # Создаем или обновляем событие - event, created = self._upsert_birthday_event(employee, personal_calendar) + event, created = self._upsert_birthday_event(employee, birthday_calendar) return { 'success': True, @@ -49,31 +49,15 @@ class UpsertBirthdayEventService(Service): 'created': created } - def _get_or_create_personal_calendar(self, employee: Employee) -> Calendar: - """Получить или создать личный календарь сотрудника.""" + def _get_or_create_birthday_calendar(self) -> Calendar: + """Получить или создать общий календарь дней рождений.""" calendar, created = Calendar.objects.get_or_create( - slug=f'personal-{employee.pk}', + slug='birthdays', defaults={ - 'name': '👤 Мой календарь' + 'name': '🎂 Дни рождения' } ) - # Убедиться что есть связь owner - if created: - from schedule.models import CalendarRelation - from django.contrib.contenttypes.models import ContentType - - ct = ContentType.objects.get_for_model(Employee) - CalendarRelation.objects.get_or_create( - calendar=calendar, - content_type=ct, - object_id=employee.pk, - defaults={ - 'distinction': 'owner', - 'inheritable': True - } - ) - return calendar def _upsert_birthday_event(self, employee: Employee, calendar: Calendar) -> tuple[Event, bool]: @@ -100,7 +84,7 @@ class UpsertBirthdayEventService(Service): hour=0, minute=0 ) - end_date = start_date + timedelta(days=1) + end_date = start_date + timedelta(hours=23, minutes=59, seconds=59) # Делаем aware если USE_TZ=True if timezone.is_naive(start_date):