1. Jernej Kos
  2. teapoll

Source

teapoll / survey / admin.py

from django.contrib import admin

from . import models as survey_models

class QuestionInline(admin.TabularInline):
  model = survey_models.Question
  extra = 0

class SurveyAdmin(admin.ModelAdmin):
  inlines = [
    QuestionInline
  ]

admin.site.register(survey_models.Survey, SurveyAdmin)

class SimpleChoiceInline(admin.TabularInline):
  model = survey_models.SimpleChoice

class SimpleChoiceQuestionAdmin(admin.ModelAdmin):
  inlines = [
    SimpleChoiceInline
  ]

admin.site.register(survey_models.SimpleChoice)
admin.site.register(survey_models.SimpleChoiceQuestion, SimpleChoiceQuestionAdmin)

class ChoiceColumnInline(admin.TabularInline):
  model = survey_models.ChoiceColumn

class ChoiceRowInline(admin.TabularInline):
  model = survey_models.ChoiceRow

class ColumnChoiceQuestionAdmin(admin.ModelAdmin):
  inlines = [
    ChoiceColumnInline,
    ChoiceRowInline
  ]

admin.site.register(survey_models.ChoiceColumn)
admin.site.register(survey_models.ChoiceRow)
admin.site.register(survey_models.ColumnChoiceQuestion, ColumnChoiceQuestionAdmin)

class MultipleChoiceInline(admin.TabularInline):
  model = survey_models.MultipleChoice

class MultipleChoiceQuestionAdmin(admin.ModelAdmin):
  inlines = [
    MultipleChoiceInline
  ]

admin.site.register(survey_models.MultipleChoice)
admin.site.register(survey_models.MultipleChoiceQuestion, MultipleChoiceQuestionAdmin)

admin.site.register(survey_models.NumericRangeQuestion)

admin.site.register(survey_models.NumericEntryQuestion)

admin.site.register(survey_models.SeparatorQuestion)

admin.site.register(survey_models.Subject)