Игорь Надеин 6fb2cdcea0 feat: enhance Employee model and integrate Telegram/WhatsApp bot
- Add birth_date, created_at/updated_at to Employee; remove username field
- Introduce EmployeeAction for tracking HR events and is_actually_active/status properties
- Create BotSubscriber model (OneToOne relation) for TG/WA binding
- Implement Aiogram-based Telegram bot:
  • request contact to bind by phone or @username
  • department selection keyboard from DEPARTMENTS dict
  • async ORM via sync_to_async, custom filters for bound & active employees
- Update profile view & template:
  • show “Bind Telegram/WhatsApp” button only when not already bound
  • preview avatar on upload
- Remove registration tokens in favor of contact-based auth
- Clean up templates, forms and add avatar validation mixin
2025-07-30 08:15:53 +03:00

42 lines
1.3 KiB
Python

# calendar_app/models.py
from django.db import models
from django.urls import reverse
from django.utils.translation import gettext_lazy as _
from django.contrib.auth import get_user_model
User = get_user_model()
class CompanyEvent(models.Model):
ONE_TIME = 'one_time'
ANNUAL = 'annual'
RECURRENCE_CHOICES = [
(ONE_TIME, _('Одноразовое')),
(ANNUAL, _('Ежегодно')),
]
title = models.CharField(_('Название'), max_length=200)
description = models.TextField(_('Описание'), blank=True)
date = models.DateField(_('Дата события'))
recurrence = models.CharField(
_('Повторение'),
max_length=20,
choices=RECURRENCE_CHOICES,
default=ONE_TIME
)
created_by = models.ForeignKey(
User, verbose_name=_('Создал'),
on_delete=models.SET_NULL, null=True, blank=True
)
class Meta:
verbose_name = _('Событие компании')
verbose_name_plural = _('События компании')
ordering = ['recurrence', 'date']
def __str__(self):
return f'{self.title} — {self.date:%d.%m.%Y}'
def get_absolute_url(self):
return reverse('calendar:event_detail', args=[self.pk])