Browse Source

adicionando ordem nas escolhas e melhorando o admin

stable/1.0
Felipe Vieira 13 years ago
parent
commit
0f40d2c0ba
  1. 20
      sigi/apps/diagnosticos/admin.py
  2. 2
      sigi/apps/diagnosticos/models.py

20
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)

2
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'

Loading…
Cancel
Save