Browse Source

Fix qa_check related alerts

pull/7/head
Edward Ribeiro 9 years ago
parent
commit
d4c164805b
  1. 8
      protocoloadm/urls.py
  2. 26
      protocoloadm/views.py

8
protocoloadm/urls.py

@ -1,7 +1,6 @@
from django.conf.urls import include, url
from protocoloadm.views import (ProtocoloPesquisaView,
#anular_protocolo_crud,
AnularProtocoloAdmView,
from protocoloadm.views import (AnularProtocoloAdmView, ProtocoloPesquisaView,
documento_acessorio_administrativo_crud,
documento_administrativo_crud,
protocolo_documento_crud,
@ -28,6 +27,7 @@ urlpatterns = [
# url(r'^protocoloadm/anular-protocolo/',
# include(anular_protocolo_crud.urls), name='anular_protocolo'),
url(r'^protocoladm/anular-protocolo', AnularProtocoloAdmView.as_view(), name='anular_protocolo'),
url(r'^protocoladm/anular-protocolo',
AnularProtocoloAdmView.as_view(), name='anular_protocolo'),
]

26
protocoloadm/views.py

@ -1,22 +1,13 @@
from datetime import datetime
from django import forms
from django.core.exceptions import ObjectDoesNotExist
from django.core.urlresolvers import reverse
from django.utils.html import strip_tags
from django.utils.translation import ugettext_lazy as _
from django.views.generic import ListView, TemplateView
from django.views.generic import ListView
from django.views.generic import View
from django.views.generic.base import TemplateView
from django.views.generic.edit import UpdateView
from django.views.generic.edit import FormMixin
from django.core.exceptions import ObjectDoesNotExist
from django.utils.html import strip_tags
from materia.models import TipoMateriaLegislativa
from sapl.crud import build_crud
@ -202,8 +193,10 @@ class ProtocoloPesquisaView(TemplateView, FormMixin):
else:
return self.form_invalid(form)
class AnularProcoloAdmForm(forms.Form):
numero_protocolo = forms.CharField(label='Número de Protocolo', required=True)
numero_protocolo = forms.CharField(
label='Número de Protocolo', required=True)
ano = forms.CharField(label='Ano', required=True)
motivo = forms.CharField(label='Motivo', required=True)
@ -216,6 +209,7 @@ def get_client_ip(request):
ip = request.META.get('REMOTE_ADDR')
return ip
class AnularProtocoloAdmView(FormMixin, TemplateView):
template_name = 'protocoloadm/anular_protocoloadm.html'
@ -233,15 +227,17 @@ class AnularProtocoloAdmView(FormMixin, TemplateView):
numero = request.POST['numero_protocolo']
ano = request.POST['ano_protocolo']
justificativa_anulacao = strip_tags(request.POST['justificativa_anulacao'])
justificativa_anulacao = strip_tags(
request.POST['justificativa_anulacao'])
user_anulacao = "NOUSER" # TODO get user from session
ip_addr = get_client_ip(request)
try:
protocolo = Protocolo.objects.get(numero = numero, ano = ano)
protocolo = Protocolo.objects.get(numero=numero, ano=ano)
if protocolo.anulado:
form._errors = {'error_message': 'Procolo encontra-se anulado'}
form._errors = {
'error_message': 'Procolo encontra-se anulado'}
return self.form_invalid(form)
protocolo.anulado = True

Loading…
Cancel
Save