Browse Source

Correção dos imports da app forms_builder

pesquisas
Breno Teixeira 11 years ago
parent
commit
b83391f7ce
  1. 12
      sigi/apps/metas/urls.py
  2. 8
      sigi/apps/pesquisas/admin.py
  3. 2
      sigi/apps/pesquisas/forms.py
  4. 4
      sigi/apps/pesquisas/models.py
  5. 2
      sigi/apps/pesquisas/templatetags/forms_builder_tags.py
  6. 26
      sigi/apps/pesquisas/views.py

12
sigi/apps/metas/urls.py

@ -3,10 +3,10 @@ from django.conf.urls import patterns, url
urlpatterns = patterns('sigi.apps.metas.views', urlpatterns = patterns('sigi.apps.metas.views',
url(r'^$', 'dashboard', name='metas-dashboardsss'), #tagerror url(r'^$', 'dashboard', name='metas-dashboardsss'), #tagerror
url(r'^mapa/$', 'mapa', name='metas-mapa'), #tagerror url(r'^mapa/$', 'mapa', name='metas-mapa'), #tagerror
url(r'^mapdata/$', 'map_data', name='metas-map_data'), url(r'^mapdata/$', 'map_data', name='metas-map_data'),
url(r'^mapsearch/$', 'map_search', name='metas-map_search'), url(r'^mapsearch/$', 'map_search', name='metas-map_search'),
url(r'^mapsum/$', 'map_sum', name='metas-map_sum'), url(r'^mapsum/$', 'map_sum', name='metas-map_sum'),
url(r'^maplist/$', 'map_list', name='metas-map_list'), url(r'^maplist/$', 'map_list', name='metas-map_list'),
) )

8
sigi/apps/pesquisas/admin.py

@ -1,12 +1,14 @@
# -*- coding: utf-8 -*- # coding: utf-8
from django.contrib import admin 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 sigi.apps.pesquisas.models import Pesquisa, Pergunta, Formulario, Resposta
from forms_builder.forms.admin import FieldAdmin, FormAdmin
class PerguntaAdmin(FieldAdmin): class PerguntaAdmin(FieldAdmin):
model = Pergunta model = Pergunta
class PesquisaAdmin(FormAdmin): class PesquisaAdmin(FormAdmin):
formentry_model = Formulario formentry_model = Formulario
fieldentry_model = Resposta fieldentry_model = Resposta

2
sigi/apps/pesquisas/forms.py

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from sigi.forms_builder.forms.forms import FormForForm from forms_builder.forms.forms import FormForForm
from sigi.apps.pesquisas.models import Formulario, Resposta from sigi.apps.pesquisas.models import Formulario, Resposta
class PesquisaForm(FormForForm): class PesquisaForm(FormForForm):

4
sigi/apps/pesquisas/models.py

@ -2,7 +2,7 @@
from django.db import models from django.db import models
from django.utils.translation import ungettext, ugettext_lazy as _ from django.utils.translation import ungettext, ugettext_lazy as _
from sigi.forms_builder.forms.models import AbstractForm, AbstractField, AbstractFormEntry, AbstractFieldEntry from forms_builder.forms.models import AbstractForm, AbstractField, AbstractFormEntry, AbstractFieldEntry
from sigi.apps.casas.models import CasaLegislativa from sigi.apps.casas.models import CasaLegislativa
from sigi.apps.servidores.models import Servidor from sigi.apps.servidores.models import Servidor
@ -32,6 +32,7 @@ class Pergunta(AbstractField):
fields_after.update(order=models.F("order") - 1) fields_after.update(order=models.F("order") - 1)
super(Pergunta, self).delete(*args, **kwargs) super(Pergunta, self).delete(*args, **kwargs)
class Formulario(AbstractFormEntry): class Formulario(AbstractFormEntry):
form = models.ForeignKey("Pesquisa", related_name="entries") form = models.ForeignKey("Pesquisa", related_name="entries")
casa_legislativa = models.ForeignKey(CasaLegislativa, verbose_name=u"Casa legislativa") casa_legislativa = models.ForeignKey(CasaLegislativa, verbose_name=u"Casa legislativa")
@ -40,5 +41,6 @@ class Formulario(AbstractFormEntry):
class Meta(AbstractFormEntry.Meta): class Meta(AbstractFormEntry.Meta):
unique_together = ('form', 'casa_legislativa') unique_together = ('form', 'casa_legislativa')
class Resposta(AbstractFieldEntry): class Resposta(AbstractFieldEntry):
entry = models.ForeignKey("Formulario", related_name="fields") entry = models.ForeignKey("Formulario", related_name="fields")

2
sigi/apps/pesquisas/templatetags/forms_builder_tags.py

@ -1,5 +1,5 @@
from django import template from django import template
from sigi.forms_builder.forms.templatetags.forms_builder_tags import BuiltFormNode from forms_builder.forms.templatetags.forms_builder_tags import BuiltFormNode
from sigi.apps.pesquisas.models import Pesquisa from sigi.apps.pesquisas.models import Pesquisa
from sigi.apps.pesquisas.forms import PesquisaForm from sigi.apps.pesquisas.forms import PesquisaForm

26
sigi/apps/pesquisas/views.py

@ -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, Pergunta, Resposta
from sigi.apps.pesquisas.models import Pesquisa
from sigi.apps.pesquisas.forms import PesquisaForm from sigi.apps.pesquisas.forms import PesquisaForm
from forms_builder.forms.views import FormDetail, FormSent
class PesquisaDetail(FormDetail): class PesquisaDetail(FormDetail):
form_class = Pesquisa form_class = Pesquisa
form_for_form_class = PesquisaForm form_for_form_class = PesquisaForm
class PesquisaSent(FormSent): class PesquisaSent(FormSent):
form_class = Pesquisa form_class = Pesquisa
form_detail = PesquisaDetail.as_view() 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…
Cancel
Save