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. 10
      sigi/apps/pesquisas/admin.py
  3. 2
      sigi/apps/pesquisas/forms.py
  4. 6
      sigi/apps/pesquisas/models.py
  5. 2
      sigi/apps/pesquisas/templatetags/forms_builder_tags.py
  6. 30
      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',
url(r'^$', 'dashboard', name='metas-dashboardsss'), #tagerror
url(r'^mapa/$', 'mapa', name='metas-mapa'), #tagerror
url(r'^mapdata/$', 'map_data', name='metas-map_data'),
url(r'^mapsearch/$', 'map_search', name='metas-map_search'),
url(r'^mapsum/$', 'map_sum', name='metas-map_sum'),
url(r'^maplist/$', 'map_list', name='metas-map_list'),
url(r'^$', 'dashboard', name='metas-dashboardsss'), #tagerror
url(r'^mapa/$', 'mapa', name='metas-mapa'), #tagerror
url(r'^mapdata/$', 'map_data', name='metas-map_data'),
url(r'^mapsearch/$', 'map_search', name='metas-map_search'),
url(r'^mapsum/$', 'map_sum', name='metas-map_sum'),
url(r'^maplist/$', 'map_list', name='metas-map_list'),
)

10
sigi/apps/pesquisas/admin.py

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

2
sigi/apps/pesquisas/forms.py

@ -1,6 +1,6 @@
# -*- 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
class PesquisaForm(FormForForm):

6
sigi/apps/pesquisas/models.py

@ -2,7 +2,7 @@
from django.db import models
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.servidores.models import Servidor
@ -32,6 +32,7 @@ class Pergunta(AbstractField):
fields_after.update(order=models.F("order") - 1)
super(Pergunta, self).delete(*args, **kwargs)
class Formulario(AbstractFormEntry):
form = models.ForeignKey("Pesquisa", related_name="entries")
casa_legislativa = models.ForeignKey(CasaLegislativa, verbose_name=u"Casa legislativa")
@ -39,6 +40,7 @@ class Formulario(AbstractFormEntry):
class Meta(AbstractFormEntry.Meta):
unique_together = ('form', 'casa_legislativa')
class Resposta(AbstractFieldEntry):
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 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.forms import PesquisaForm

30
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
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…
Cancel
Save