Browse Source

Corrigido o bug no cadastro de competencias, que nao salvava pelo motivo do campo nome nao aceitar vazio.

diagnosticos
Gilson Filho 13 years ago
parent
commit
4a0b9ada26
  1. 2
      sigi/apps/casas/models.py
  2. 28
      sigi/apps/diagnosticos/views.py

2
sigi/apps/casas/models.py

@ -91,7 +91,7 @@ class Funcionario(models.Model):
("outros","Outros"),
]
casa_legislativa = models.ForeignKey(CasaLegislativa)
nome = models.CharField('nome completo', max_length=60)
nome = models.CharField('nome completo', max_length=60, blank=True)
nome.alphabetic_filter = True
nota = models.CharField(max_length=70, blank=True)
email = models.EmailField('e-mail', blank=True)

28
sigi/apps/diagnosticos/views.py

@ -7,7 +7,8 @@ from django.views.decorators.cache import cache_page
from sigi.apps.utils.decorators import login_required
from sigi.apps.diagnosticos.models import Diagnostico, Categoria
from sigi.apps.casas.models import Funcionario
from sigi.apps.diagnosticos.forms import DiagnosticoMobileForm, CasaLegislativaMobileForm, FuncionariosMobileForm
from sigi.apps.diagnosticos.forms import (DiagnosticoMobileForm,
CasaLegislativaMobileForm, FuncionariosMobileForm)
@login_required(login_url='/mobile/diagnosticos/login')
@ -78,15 +79,17 @@ def categoria_casa_legislativa(request, id_diagnostico):
return render_to_response('mobile/404.html', {})
if request.method == "POST":
form = CasaLegislativaMobileForm(request.POST, instance=casa_legislativa)
form = CasaLegislativaMobileForm(request.POST,
instance=casa_legislativa)
if form.is_valid():
form.save()
else:
form = CasaLegislativaMobileForm(instance=casa_legislativa)
context = RequestContext(request, {'form': form, 'diagnostico': diagnostico,
'casa_legislativa': casa_legislativa})
return render_to_response('diagnosticos/diagnosticos_categoria_casa_legislativa_form.html',
context = RequestContext(request, {'form': form,
'diagnostico': diagnostico, 'casa_legislativa': casa_legislativa})
return render_to_response(
'diagnosticos/diagnosticos_categoria_casa_legislativa_form.html',
context)
@ -95,22 +98,25 @@ def categoria_casa_legislativa(request, id_diagnostico):
def categoria_contatos(request, id_diagnostico):
try:
diagnostico = Diagnostico.objects.get(pk=id_diagnostico)
casa_legislativa = diagnostico.casa_legislativa
casa = diagnostico.casa_legislativa
except Diagnostico.DoesNotExist:
context = RequestContext(request)
return render_to_response('mobile/404.html', {})
funcionarios = [casa_legislativa.funcionario_set.get_or_create(setor=n) for n, l in Funcionario.SETOR_CHOICES]
funcionarios = [casa.funcionario_set.get_or_create(setor=n)
for n, l in Funcionario.SETOR_CHOICES]
if request.method == "POST":
forms = [FuncionariosMobileForm(request.POST, prefix=f.setor, instance=f) for f, c in funcionarios]
forms = [FuncionariosMobileForm(
request.POST, prefix=f.setor, instance=f) for f, c in funcionarios]
if all([form.is_valid() for form in forms]):
for form in forms:
form.save()
else:
forms = [FuncionariosMobileForm(prefix=f.setor, instance=f) for f, c in funcionarios]
forms = [FuncionariosMobileForm(prefix=f.setor, instance=f)
for f, c in funcionarios]
context = RequestContext(request, {'forms': forms, 'diagnostico': diagnostico,
'casa_legislativa': casa_legislativa})
context = RequestContext(request, {'forms': forms,
'diagnostico': diagnostico, 'casa_legislativa': casa})
return render_to_response('diagnosticos/diagnosticos_categoria_contatos_form.html',
context)

Loading…
Cancel
Save