2025-05-18 21:29:04 +03:00
|
|
|
from django.contrib import admin
|
2025-05-18 22:16:31 +03:00
|
|
|
from .models import Position, Department, Employee
|
2025-05-18 21:29:04 +03:00
|
|
|
|
2025-05-18 22:16:31 +03:00
|
|
|
|
|
|
|
|
@admin.register(Position)
|
|
|
|
|
class PositionAdmin(admin.ModelAdmin):
|
|
|
|
|
list_display = ('name',)
|
|
|
|
|
search_fields = ('name',)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@admin.register(Department)
|
|
|
|
|
class DepartmentAdmin(admin.ModelAdmin):
|
|
|
|
|
list_display = ('name',)
|
|
|
|
|
search_fields = ('name',)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@admin.register(Employee)
|
|
|
|
|
class EmployeeAdmin(admin.ModelAdmin):
|
|
|
|
|
list_display = ('full_name', 'position', 'department', 'account')
|
|
|
|
|
list_filter = ('department', 'position')
|
|
|
|
|
search_fields = (
|
2025-05-18 22:48:39 +03:00
|
|
|
'account__first_name', 'account__last_name', 'account__middle_name',
|
|
|
|
|
'account__phone', 'account__email', 'position__name', 'department__name'
|
2025-05-18 22:16:31 +03:00
|
|
|
)
|
|
|
|
|
autocomplete_fields = ('department', 'position', 'account')
|
|
|
|
|
|
|
|
|
|
fieldsets = (
|
|
|
|
|
('Основная информация', {
|
|
|
|
|
'fields': ('account', 'department', 'position')
|
|
|
|
|
}),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@admin.display(description='ФИО')
|
|
|
|
|
def full_name(self, obj):
|
|
|
|
|
return str(obj)
|