- 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
27 lines
867 B
Python
27 lines
867 B
Python
from django.contrib import admin
|
|
from .models import CompanyEvent
|
|
|
|
|
|
@admin.register(CompanyEvent)
|
|
class CompanyEventAdmin(admin.ModelAdmin):
|
|
list_display = ('title', 'date', 'recurrence', 'created_by')
|
|
list_filter = ('recurrence', 'date', 'created_by')
|
|
search_fields = ('title', 'description', 'created_by__username', 'created_by__phone_number')
|
|
date_hierarchy = 'date'
|
|
ordering = ('recurrence', 'date')
|
|
fieldsets = (
|
|
(None, {
|
|
'fields': ('title', 'description', 'date', 'recurrence')
|
|
}),
|
|
('Meta', {
|
|
'fields': ('created_by',),
|
|
'classes': ('collapse',),
|
|
}),
|
|
)
|
|
readonly_fields = ('created_by',)
|
|
|
|
def save_model(self, request, obj, form, change):
|
|
if not obj.pk:
|
|
obj.created_by = request.user
|
|
super().save_model(request, obj, form, change)
|