mirror of https://github.com/interlegis/sigi.git
Breno Teixeira
11 years ago
6 changed files with 43 additions and 19 deletions
@ -1,15 +1,17 @@ |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
# coding: utf-8 |
|||
from django.contrib import admin |
|||
from sigi.forms_builder.forms.admin import FieldAdmin, FormAdmin |
|||
from sigi.apps.pesquisas.models import Pesquisa, Pergunta, Formulario, Resposta |
|||
|
|||
from forms_builder.forms.admin import FieldAdmin, FormAdmin |
|||
|
|||
|
|||
class PerguntaAdmin(FieldAdmin): |
|||
model = Pergunta |
|||
|
|||
|
|||
class PesquisaAdmin(FormAdmin): |
|||
formentry_model = Formulario |
|||
fieldentry_model = Resposta |
|||
inlines = (PerguntaAdmin,) |
|||
|
|||
admin.site.register(Pesquisa, PesquisaAdmin) |
|||
admin.site.register(Pesquisa, PesquisaAdmin) |
|||
|
@ -1,15 +1,35 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# coding: utf-8 |
|||
from django.views.generic.base import TemplateView |
|||
from django.db.models import Count |
|||
|
|||
from forms_builder.forms.views import FormDetail, FormSent |
|||
from sigi.apps.pesquisas.models import Pesquisa |
|||
from sigi.apps.pesquisas.models import Pesquisa, Pergunta, Resposta |
|||
from sigi.apps.pesquisas.forms import PesquisaForm |
|||
|
|||
from forms_builder.forms.views import FormDetail, FormSent |
|||
|
|||
|
|||
class PesquisaDetail(FormDetail): |
|||
form_class = Pesquisa |
|||
form_for_form_class = PesquisaForm |
|||
|
|||
|
|||
|
|||
class PesquisaSent(FormSent): |
|||
form_class = Pesquisa |
|||
|
|||
form_detail = PesquisaDetail.as_view() |
|||
form_sent = PesquisaSent.as_view() |
|||
form_sent = PesquisaSent.as_view() |
|||
|
|||
|
|||
class ChartView(TemplateView): |
|||
template_name = 'pesquisas/chart.html' |
|||
|
|||
def get_context_data(self, **kwargs): |
|||
context = super(ChartView, self).get_context_data(**kwargs) |
|||
field_id = self.kwargs['field_id'] |
|||
context['label'] = Pergunta.objects.filter(id=field_id) |
|||
dados = Resposta.objects.filter(field_id=field_id).values('value').annotate(total=Count('value')) |
|||
context['dados'] = dados |
|||
context['field_id'] = field_id |
|||
return context |
|||
|
|||
chart_view = ChartView.as_view() |
Loading…
Reference in new issue