2025-05-18 21:29:04 +03:00
|
|
|
from django.contrib import admin
|
2025-05-18 22:48:39 +03:00
|
|
|
from .models import (
|
|
|
|
|
InstitutionType, Representative, School, Partner,
|
|
|
|
|
PartnerRepresentative, SchoolResponsibility
|
|
|
|
|
)
|
2025-05-18 21:29:04 +03:00
|
|
|
|
2025-05-18 22:48:39 +03:00
|
|
|
|
|
|
|
|
@admin.register(InstitutionType)
|
|
|
|
|
class InstitutionTypeAdmin(admin.ModelAdmin):
|
|
|
|
|
list_display = ('name',)
|
|
|
|
|
search_fields = ('name',)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@admin.register(Representative)
|
|
|
|
|
class RepresentativeAdmin(admin.ModelAdmin):
|
|
|
|
|
list_display = ('full_name', 'position')
|
|
|
|
|
search_fields = ('first_name', 'last_name', 'middle_name', 'phone', 'email', 'position')
|
|
|
|
|
|
|
|
|
|
@admin.display(description='ФИО')
|
|
|
|
|
def full_name(self, obj):
|
|
|
|
|
return str(obj)
|
|
|
|
|
|
|
|
|
|
fieldsets = (
|
|
|
|
|
('Основная информация', {
|
|
|
|
|
'fields': ('first_name', 'last_name', 'middle_name', 'position')
|
|
|
|
|
}),
|
|
|
|
|
('Контактные данные', {
|
|
|
|
|
'fields': ('phone', 'email')
|
|
|
|
|
}),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PartnerRepresentativeInline(admin.TabularInline):
|
|
|
|
|
model = PartnerRepresentative
|
|
|
|
|
extra = 1
|
|
|
|
|
autocomplete_fields = ('representative',)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@admin.register(Partner)
|
|
|
|
|
class PartnerAdmin(admin.ModelAdmin):
|
|
|
|
|
list_display = ('name',)
|
|
|
|
|
search_fields = ('name',)
|
|
|
|
|
inlines = [PartnerRepresentativeInline]
|
|
|
|
|
|
|
|
|
|
fieldsets = (
|
|
|
|
|
('Основная информация', {
|
|
|
|
|
'fields': ('name', 'description')
|
|
|
|
|
}),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@admin.register(PartnerRepresentative)
|
|
|
|
|
class PartnerRepresentativeAdmin(admin.ModelAdmin):
|
|
|
|
|
list_display = ('representative', 'partner')
|
|
|
|
|
search_fields = ('representative__first_name', 'representative__last_name', 'partner__name')
|
|
|
|
|
autocomplete_fields = ('representative', 'partner')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@admin.register(School)
|
|
|
|
|
class SchoolAdmin(admin.ModelAdmin):
|
|
|
|
|
list_display = ('name', 'institution_type', 'director')
|
|
|
|
|
list_filter = ('institution_type',)
|
|
|
|
|
search_fields = ('name', 'address', 'director__first_name', 'director__last_name')
|
|
|
|
|
autocomplete_fields = ('director', 'institution_type')
|
|
|
|
|
|
|
|
|
|
fieldsets = (
|
|
|
|
|
('Основная информация', {
|
|
|
|
|
'fields': ('name', 'institution_type', 'address')
|
|
|
|
|
}),
|
|
|
|
|
('Директор', {
|
|
|
|
|
'fields': ('director',)
|
|
|
|
|
}),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@admin.register(SchoolResponsibility)
|
|
|
|
|
class SchoolResponsibilityAdmin(admin.ModelAdmin):
|
|
|
|
|
list_display = ('academic_year', 'school', 'responsible')
|
|
|
|
|
list_filter = ('academic_year', 'school__institution_type')
|
|
|
|
|
search_fields = (
|
|
|
|
|
'school__name', 'responsible__first_name',
|
|
|
|
|
'responsible__last_name', 'academic_year__year'
|
|
|
|
|
)
|
|
|
|
|
autocomplete_fields = ('school', 'responsible', 'academic_year')
|
|
|
|
|
|
|
|
|
|
fieldsets = (
|
|
|
|
|
('Ответственность', {
|
|
|
|
|
'fields': ('academic_year', 'school', 'responsible')
|
|
|
|
|
}),
|
|
|
|
|
)
|