admin.py 723 Bytes
Newer Older
1 2 3 4 5 6 7 8 9
"""
Provide accessors to these models via the Django Admin pages
"""

from django import forms
from django.contrib import admin
from survey.models import SurveyForm


10
class SurveyFormAdminForm(forms.ModelForm):
11 12
    """Form providing validation of SurveyForm content."""

stv committed
13
    class Meta(object):  # pylint: disable=missing-docstring
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
        model = SurveyForm
        fields = ('name', 'form')

    def clean_form(self):
        """Validate the HTML template."""
        form = self.cleaned_data["form"]
        SurveyForm.validate_form_html(form)
        return form


class SurveyFormAdmin(admin.ModelAdmin):
    """Admin for SurveyForm"""
    form = SurveyFormAdminForm


admin.site.register(SurveyForm, SurveyFormAdmin)