diff --git a/sigi/apps/diagnosticos/admin.py b/sigi/apps/diagnosticos/admin.py index b5f1c2a..5e73c1d 100644 --- a/sigi/apps/diagnosticos/admin.py +++ b/sigi/apps/diagnosticos/admin.py @@ -74,19 +74,25 @@ class DiagnosticoAdmin(BaseEntityAdmin): 'classes': ['collapse'] })) - -class PerguntaAdmin (BaseSchemaAdmin): - search_fields = ('title', 'help_text', 'name',) - list_display = ('title', 'categoria', 'datatype', 'help_text', 'required') - list_filter = ('datatype', 'categoria', 'required') - - class EscolhaAdmin(admin.ModelAdmin): search_fields = ('title',) list_display = ('title', 'schema', 'schema_to_open') raw_id_fields = ('schema', 'schema_to_open') ordering = ('schema', 'title') +class EscolhaInline(admin.TabularInline): + model = Escolha + fk_name = 'schema' + raw_id_fields = ('schema_to_open',) + verbose_name = 'Escolhas (apenas para choices ou multiple choices)' + extra = 0 + +class PerguntaAdmin (BaseSchemaAdmin): + search_fields = ('title', 'help_text', 'name',) + list_display = ('title', 'categoria', 'datatype', 'help_text', 'required') + list_filter = ('datatype', 'categoria', 'required') + inlines = (EscolhaInline,) + admin.site.register(Diagnostico, DiagnosticoAdmin) admin.site.register(Pergunta, PerguntaAdmin) admin.site.register(Escolha, EscolhaAdmin) diff --git a/sigi/apps/diagnosticos/models.py b/sigi/apps/diagnosticos/models.py index a9eedad..05af7b8 100644 --- a/sigi/apps/diagnosticos/models.py +++ b/sigi/apps/diagnosticos/models.py @@ -158,8 +158,10 @@ class Escolha(BaseChoice): related_name='choices', verbose_name='pergunta') schema_to_open = models.ForeignKey(Pergunta, related_name='', verbose_name='pergunta para abrir', blank=True, null=True) + ordem = models.PositiveIntegerField(blank=True, null=True) class Meta: + ordering = ('schema','ordem') verbose_name, verbose_name_plural = 'escolha', 'escolhas'