From 54f90105c2f58c1b8f8d95219ac7b20b1d0dc4a6 Mon Sep 17 00:00:00 2001 From: Felipe Vieira Date: Wed, 30 Nov 2011 22:23:37 +0000 Subject: [PATCH] arrumando campos de multipla escolha na interface admin --- sigi/apps/diagnosticos/forms.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/sigi/apps/diagnosticos/forms.py b/sigi/apps/diagnosticos/forms.py index 0f9f9d1..46562e2 100644 --- a/sigi/apps/diagnosticos/forms.py +++ b/sigi/apps/diagnosticos/forms.py @@ -3,11 +3,15 @@ from copy import deepcopy from django import forms from django.forms.forms import BoundField +from django.forms import (BooleanField, CharField, CheckboxSelectMultiple, + DateField, FloatField, ModelChoiceField, + ModelMultipleChoiceField, RadioSelect) from django.contrib.contenttypes.generic import generic_inlineformset_factory from sigi.apps.casas.models import CasaLegislativa, Funcionario from sigi.apps.contatos.models import Telefone from sigi.apps.diagnosticos.models import Diagnostico from eav.forms import BaseDynamicEntityForm +from eav.fields import RangeField class DiagnosticoForm(BaseDynamicEntityForm): @@ -23,6 +27,22 @@ class DiagnosticoMobileForm(BaseDynamicEntityForm): do modelo Diagnostico, como também organizar sua estrutura via categorias. """ + + FIELD_CLASSES = { + 'text': CharField, + 'float': FloatField, + 'date': DateField, + 'bool': BooleanField, + 'one': ModelChoiceField, + 'many': ModelMultipleChoiceField, + 'range': RangeField, + } + + FIELD_EXTRA = { + 'one': {'widget': RadioSelect}, + 'many': {'widget': CheckboxSelectMultiple}, + } + class Meta: model = Diagnostico