from django.contrib import admin
from .models import Survey, Question, Answer


class AdminQuestion(admin.ModelAdmin):
    list_display = ('survey', 'label', 'type_field', 'help_text', 'required')
    search_fields = ('survey', )


class AdminAnswer(admin.ModelAdmin):
    list_display = ('question', 'get_label', 'value',)
    search_fields = ('question__label', 'value',)
    list_filter = ('question__survey',)

    def get_label(self, obj):
        return obj.question.label
    get_label.admin_order_field = 'question'
    get_label.short_description = 'Label'


admin.site.register(Survey)
admin.site.register(Question, AdminQuestion)
admin.site.register(Answer, AdminAnswer)
