Browse Source

Fix #1430

pull/1434/head
LeandroRoberto 7 years ago
parent
commit
073fb89527
  1. 11
      sapl/protocoloadm/forms.py
  2. 24
      sapl/protocoloadm/views.py

11
sapl/protocoloadm/forms.py

@ -1,6 +1,5 @@
from datetime import datetime
import django_filters
from crispy_forms.bootstrap import InlineRadios
from crispy_forms.helper import FormHelper
from crispy_forms.layout import HTML, Button, Fieldset, Layout, Submit
@ -9,9 +8,10 @@ from django.core.exceptions import ObjectDoesNotExist, ValidationError
from django.db import models
from django.forms import ModelForm
from django.utils.translation import ugettext_lazy as _
import django_filters
from sapl.base.models import Autor, TipoAutor
from sapl.crispy_layout_mixin import form_actions, to_row
from sapl.crispy_layout_mixin import form_actions, to_row, SaplFormLayout
from sapl.materia.models import (MateriaLegislativa, TipoMateriaLegislativa,
UnidadeTramitacao)
from sapl.utils import (RANGE_ANOS, AnoNumeroOrderingFilter,
@ -21,6 +21,7 @@ from .models import (DocumentoAcessorioAdministrativo, DocumentoAdministrativo,
Protocolo, TipoDocumentoAdministrativo,
TramitacaoAdministrativo)
TIPOS_PROTOCOLO = [('0', 'Recebido'), ('1', 'Enviado'), ('', 'Ambos')]
TIPOS_PROTOCOLO_CREATE = [('0', 'Recebido'), ('1', 'Enviado')]
@ -621,12 +622,10 @@ class DocumentoAdministrativoForm(ModelForm):
[('observacao', 12)])
self.helper = FormHelper()
self.helper.layout = Layout(
self.helper.layout = SaplFormLayout(
Fieldset(_('Identificação Básica'),
row1, row2, row3, row4, row5),
Fieldset(_('Outras Informações'),
row6, row7),
form_actions(more=[Submit('Excluir', 'Excluir')]),
)
row6, row7))
super(DocumentoAdministrativoForm, self).__init__(
*args, **kwargs)

24
sapl/protocoloadm/views.py

@ -11,10 +11,9 @@ from django.http import Http404, HttpResponse, JsonResponse
from django.shortcuts import redirect
from django.utils.translation import ugettext_lazy as _
from django.views.generic import CreateView, ListView
from django.views.generic.base import TemplateView
from django.views.generic.base import TemplateView, RedirectView
from django_filters.views import FilterView
import sapl
from sapl.base.models import Autor
from sapl.comissoes.models import Comissao
from sapl.crud.base import Crud, CrudAux, MasterDetailCrud, make_pagination
@ -22,6 +21,7 @@ from sapl.materia.models import MateriaLegislativa, TipoMateriaLegislativa
from sapl.parlamentares.models import Legislatura, Parlamentar
from sapl.protocoloadm.models import Protocolo
from sapl.utils import create_barcode, get_client_ip
import sapl
from .forms import (AnularProcoloAdmForm, DocumentoAcessorioAdministrativoForm,
DocumentoAdministrativoFilterSet,
@ -32,6 +32,7 @@ from .models import (DocumentoAcessorioAdministrativo, DocumentoAdministrativo,
StatusTramitacaoAdministrativo,
TipoDocumentoAdministrativo, TramitacaoAdministrativo)
TipoDocumentoAdministrativoCrud = CrudAux.build(
TipoDocumentoAdministrativo, '')
@ -99,14 +100,21 @@ class DocumentoAdministrativoCrud(Crud):
def list_url(self):
return ''
class ListView(DocumentoAdministrativoMixin, Crud.ListView):
pass
class ListView(RedirectView, DocumentoAdministrativoMixin, Crud.ListView):
class CreateView(DocumentoAdministrativoMixin, Crud.CreateView):
def get_redirect_url(self, *args, **kwargs):
namespace = self.model._meta.app_config.name
return reverse('%s:%s' % (namespace, 'pesq_doc_adm'))
class CreateView(Crud.CreateView):
form_class = DocumentoAdministrativoForm
layout_key = None
class UpdateView(DocumentoAdministrativoMixin, Crud.UpdateView):
@property
def cancel_url(self):
return self.search_url
class UpdateView(Crud.UpdateView):
form_class = DocumentoAdministrativoForm
layout_key = None
@ -126,10 +134,10 @@ class DocumentoAdministrativoCrud(Crud):
kwargs={'pk': self.object.pk}))
return context
class DeleteView(DocumentoAdministrativoMixin, Crud.DeleteView):
class DeleteView(Crud.DeleteView):
def get_success_url(self):
return reverse('sapl.protocoloadm:pesq_doc_adm', kwargs={})
return self.search_url
class StatusTramitacaoAdministrativoCrud(CrudAux):

Loading…
Cancel
Save