education + employees
This commit is contained in:
@@ -1,3 +1,58 @@
|
||||
from django.contrib import admin
|
||||
from .models import AcademicYear, Department, DepartmentHead, Specialty, Group, Student
|
||||
|
||||
# Register your models here.
|
||||
|
||||
@admin.register(AcademicYear)
|
||||
class AcademicYearAdmin(admin.ModelAdmin):
|
||||
list_display = ('year',)
|
||||
search_fields = ('year',)
|
||||
|
||||
|
||||
@admin.register(Department)
|
||||
class DepartmentAdmin(admin.ModelAdmin):
|
||||
list_display = ('name',)
|
||||
search_fields = ('name',)
|
||||
|
||||
|
||||
@admin.register(DepartmentHead)
|
||||
class DepartmentHeadAdmin(admin.ModelAdmin):
|
||||
list_display = ('department', 'head')
|
||||
list_filter = ('department',)
|
||||
autocomplete_fields = ('department', 'head')
|
||||
search_fields = ('department__name', 'head__first_name', 'head__last_name')
|
||||
|
||||
|
||||
@admin.register(Specialty)
|
||||
class SpecialtyAdmin(admin.ModelAdmin):
|
||||
list_display = ('code', 'name', 'department')
|
||||
list_filter = ('department',)
|
||||
search_fields = ('code', 'name', 'department__name')
|
||||
|
||||
|
||||
@admin.register(Group)
|
||||
class GroupAdmin(admin.ModelAdmin):
|
||||
list_display = ('name', 'specialty', 'curator')
|
||||
list_filter = ('specialty__department', 'specialty')
|
||||
search_fields = ('name', 'specialty__name', 'curator__first_name', 'curator__last_name')
|
||||
autocomplete_fields = ('specialty', 'curator')
|
||||
|
||||
|
||||
@admin.register(Student)
|
||||
class StudentAdmin(admin.ModelAdmin):
|
||||
list_display = ('full_name', 'group', 'account')
|
||||
list_filter = ('group__specialty__department', 'group__specialty', 'group')
|
||||
search_fields = (
|
||||
'first_name', 'last_name', 'middle_name',
|
||||
'group__name', 'account__login'
|
||||
)
|
||||
autocomplete_fields = ('group', 'account')
|
||||
|
||||
@admin.display(description='ФИО')
|
||||
def full_name(self, obj):
|
||||
return str(obj)
|
||||
|
||||
fieldsets = (
|
||||
('Основная информация', {
|
||||
'fields': ('account', 'group')
|
||||
}),
|
||||
)
|
||||
Reference in New Issue
Block a user