education + employees
This commit is contained in:
@@ -1,3 +1,35 @@
|
||||
from django.contrib import admin
|
||||
from .models import Position, Department, Employee
|
||||
|
||||
# Register your models here.
|
||||
|
||||
@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 = (
|
||||
'first_name', 'last_name', 'middle_name',
|
||||
'phone', 'email', 'position__name', 'department__name'
|
||||
)
|
||||
autocomplete_fields = ('department', 'position', 'account')
|
||||
|
||||
fieldsets = (
|
||||
('Основная информация', {
|
||||
'fields': ('account', 'department', 'position')
|
||||
}),
|
||||
)
|
||||
|
||||
@admin.display(description='ФИО')
|
||||
def full_name(self, obj):
|
||||
return str(obj)
|
||||
Reference in New Issue
Block a user