33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
from django.contrib import admin
|
|
from .models import Test, TestAnswer, TestQuestion, TestAttempt, DictEmployee
|
|
import nested_admin
|
|
|
|
class TestAnswerInline(nested_admin.NestedStackedInline):
|
|
model = TestAnswer
|
|
extra = 0
|
|
|
|
class TestQuestionInline(nested_admin.NestedStackedInline):
|
|
model = TestQuestion
|
|
extra = 0
|
|
inlines = [TestAnswerInline]
|
|
|
|
class TestAdmin(nested_admin.NestedModelAdmin):
|
|
inlines = [TestQuestionInline]
|
|
|
|
@admin.register(TestAttempt)
|
|
class TestAttemptAdmin(admin.ModelAdmin):
|
|
# list_display = ('testing_user', 'testing_test', 'score', 'completion_date')
|
|
list_display = ('get_user_fio', 'testing_test', 'score', 'completion_date')
|
|
|
|
def get_user_fio(self, obj):
|
|
return obj.testing.user.user.fio
|
|
get_user_fio.admin_order_field = 'testing__user__user__fio'
|
|
|
|
def testing_test(self, obj):
|
|
return obj.testing.test
|
|
|
|
get_user_fio.short_description = 'Пользователь'
|
|
testing_test.short_description = 'Тест'
|
|
testing_test.admin_order_field = 'testing__test'
|
|
|
|
admin.site.register(Test, TestAdmin) |