Browse Source

Acrescentado e-mail no formulário de manifestação das Casas

stable/1.0
Sesostris Vieira 11 years ago
parent
commit
303ecf373b
  1. 5
      sigi/apps/servicos/models.py
  2. 6
      sigi/apps/servicos/views.py
  3. 27
      sigi/templates/servicos/casa_manifesta.html

5
sigi/apps/servicos/models.py

@ -183,8 +183,9 @@ class CasaManifesta(models.Model):
casa_legislativa = models.OneToOneField(CasaLegislativa) casa_legislativa = models.OneToOneField(CasaLegislativa)
data_manifestacao = models.DateTimeField(auto_now_add=True) data_manifestacao = models.DateTimeField(auto_now_add=True)
data_atualizacao = models.DateTimeField(auto_now=True) data_atualizacao = models.DateTimeField(auto_now=True)
informante = models.CharField(u'Nome do informante', max_length=100) informante = models.CharField(u'Nome do informante', max_length=100, blank=True)
cargo = models.CharField(u'Cargo do informante', max_length=100) cargo = models.CharField(u'Cargo do informante', max_length=100, blank=True)
email = models.EmailField(u'E-mail de contato', blank=True)
class ServicoManifesto(models.Model): class ServicoManifesto(models.Model):
casa_manifesta = models.ForeignKey(CasaManifesta) casa_manifesta = models.ForeignKey(CasaManifesta)

6
sigi/apps/servicos/views.py

@ -41,6 +41,7 @@ class CasaManifestaProtoForm(forms.Form):
fieldsets = None fieldsets = None
informante = forms.CharField(max_length=100, required=False) informante = forms.CharField(max_length=100, required=False)
cargo = forms.CharField(max_length=100, required=False) cargo = forms.CharField(max_length=100, required=False)
email = forms.EmailField(required=False)
def set_fieldsets(self, fieldsets): def set_fieldsets(self, fieldsets):
result = [] result = []
@ -66,7 +67,7 @@ def casa_manifesta_view(request):
# Criar um formulário dinâmico # Criar um formulário dinâmico
campos = {} campos = {}
fieldsets = ((None, ('informante', 'cargo'),),) fieldsets = ((None, ('informante', 'cargo', 'email'),),)
for ts in TipoServico.objects.all(): for ts in TipoServico.objects.all():
campos['possui_%s' % ts.pk] = forms.BooleanField(label=u'Possui o serviço de %s' % ts.nome, required=False) campos['possui_%s' % ts.pk] = forms.BooleanField(label=u'Possui o serviço de %s' % ts.nome, required=False)
@ -83,9 +84,11 @@ def casa_manifesta_view(request):
cm, created = CasaManifesta.objects.get_or_create(casa_legislativa=casa) cm, created = CasaManifesta.objects.get_or_create(casa_legislativa=casa)
cm.informante = cmf.cleaned_data['informante'] cm.informante = cmf.cleaned_data['informante']
cm.cargo = cmf.cleaned_data['cargo'] cm.cargo = cmf.cleaned_data['cargo']
cm.email = cmf.cleaned_data['email']
cm.save() cm.save()
thanks.append((u'Informante', cmf.cleaned_data['informante'])) thanks.append((u'Informante', cmf.cleaned_data['informante']))
thanks.append((u'Cargo', cmf.cleaned_data['cargo'])) thanks.append((u'Cargo', cmf.cleaned_data['cargo']))
thanks.append((u'E-mail', cmf.cleaned_data['email']))
for ts in TipoServico.objects.all(): for ts in TipoServico.objects.all():
if cmf.cleaned_data['possui_%s' % ts.pk]: if cmf.cleaned_data['possui_%s' % ts.pk]:
sm, created = ServicoManifesto.objects.get_or_create(casa_manifesta=cm, servico=ts) sm, created = ServicoManifesto.objects.get_or_create(casa_manifesta=cm, servico=ts)
@ -106,6 +109,7 @@ def casa_manifesta_view(request):
values = { values = {
'informante': cm.informante, 'informante': cm.informante,
'cargo': cm.cargo, 'cargo': cm.cargo,
'email': cm.email,
} }
for sm in cm.servicomanifesto_set.all(): for sm in cm.servicomanifesto_set.all():
values['possui_%s' % sm.servico.pk] = True values['possui_%s' % sm.servico.pk] = True

27
sigi/templates/servicos/casa_manifesta.html

@ -61,33 +61,6 @@
<h3>3. Informe os dados para a {{ casa.nome }} - {{ casa.municipio.uf }}</h3> <h3>3. Informe os dados para a {{ casa.nome }} - {{ casa.municipio.uf }}</h3>
<form action="" method="post" id="manifesta_form">{% csrf_token %} <form action="" method="post" id="manifesta_form">{% csrf_token %}
{% for fieldset in cmf.fieldsets %} {% for fieldset in cmf.fieldsets %}
{% comment %}
<fieldset class="module aligned {{ fieldset.classes }}">
{% if fieldset.name %}<h2>{{ fieldset.name }}</h2>{% endif %}
{% for line in fieldset.lines %}
<div class="form-row">
{% for field in line %}
<div class="field-box{% if not field.is_readonly and field.errors %} errors{% endif %}">
{% if not field.is_readonly %}{{ field.errors }}{% endif %}
{% if field.is_checkbox %}
{{ field }}{{ field.label_tag }}
{% else %}
{{ field.label_tag }}
{% if field.is_readonly %}
<p>{{ field.contents }}</p>
{% else %}
{{ field }}
{% endif %}
{% endif %}
{% if field.field.help_text %}
<p class="help">{{ field.field.help_text|safe }}</p>
{% endif %}
</div>
{% endfor %}
</div>
{% endfor %}
</fieldset>
{% endcomment %}
{% if forloop.first %} {% if forloop.first %}
<fieldset class="module aligned {{ fieldset.classes }}"> <fieldset class="module aligned {{ fieldset.classes }}">
{% if fieldset.name %}<h2>{{ fieldset.name }}</h2>{% endif %} {% if fieldset.name %}<h2>{{ fieldset.name }}</h2>{% endif %}

Loading…
Cancel
Save