Browse Source

Fix successful return from Protocolar Doc Adm e Protocolar Matéria

pull/11/merge
Edward Ribeiro 9 years ago
parent
commit
bb463c923c
  1. 23
      protocoloadm/views.py

23
protocoloadm/views.py

@ -335,10 +335,7 @@ class AnularProtocoloAdmView(FormMixin, GenericView):
protocolo.user_anulacao = user_anulacao protocolo.user_anulacao = user_anulacao
protocolo.ip_anulacao = ip_addr protocolo.ip_anulacao = ip_addr
protocolo.save() protocolo.save()
message = "Protocolo criado com sucesso" return self.form_valid(form)
return render(request,
reverse("anular_protocolo"),
{'form': form, 'message': message})
except ObjectDoesNotExist: except ObjectDoesNotExist:
errors = form._errors.setdefault( errors = form._errors.setdefault(
@ -387,7 +384,7 @@ class ProtocoloDocumentoView(FormMixin, GenericView):
model = Protocolo model = Protocolo
def get_success_url(self): def get_success_url(self):
return reverse('protocolar_doc') return reverse('protocolo')
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
form = ProtocoloDocumentForm() form = ProtocoloDocumentForm()
@ -398,15 +395,12 @@ class ProtocoloDocumentoView(FormMixin, GenericView):
form = ProtocoloDocumentForm(request.POST) form = ProtocoloDocumentForm(request.POST)
if form.is_valid(): if form.is_valid():
if request.POST['numeracao'] == '1': if request.POST['numeracao'] == '1':
numeracao = Protocolo.objects.filter( numeracao = Protocolo.objects.filter(
ano=date.today().year).aggregate(Max('numero')) ano=date.today().year).aggregate(Max('numero'))
else: else:
numeracao = Protocolo.objects.all().aggregate(Max('numero')) numeracao = Protocolo.objects.all().aggregate(Max('numero'))
protocolo = Protocolo() protocolo = Protocolo()
protocolo.numero = numeracao['numero__max'] + 1 protocolo.numero = numeracao['numero__max'] + 1
protocolo.ano = datetime.now().year protocolo.ano = datetime.now().year
protocolo.data = datetime.now().strftime("%Y-%m-%d") protocolo.data = datetime.now().strftime("%Y-%m-%d")
@ -423,13 +417,7 @@ class ProtocoloDocumentoView(FormMixin, GenericView):
protocolo.numero_paginas = request.POST['num_paginas'] protocolo.numero_paginas = request.POST['num_paginas']
protocolo.observacao = sub( protocolo.observacao = sub(
' ', ' ', strip_tags(request.POST['observacao'])) ' ', ' ', strip_tags(request.POST['observacao']))
return self.form_valid(form)
protocolo.save()
message = "Protocolo criado com sucesso"
return render(request,
reverse('protocolo'),
{'form': form, 'message': message})
else: else:
return self.form_invalid(form) return self.form_invalid(form)
@ -516,10 +504,7 @@ class ProtocoloMateriaView(FormMixin, GenericView):
protocolo.save() protocolo.save()
message = "Protocolo criado com sucesso" return self.form_valid(form)
return render(request,
reverse('protocolo'),
{'form': form, 'message': message})
else: else:
return self.form_invalid(form) return self.form_invalid(form)

Loading…
Cancel
Save