diff --git a/materia/forms.py b/materia/forms.py index 8e7361ef6..41ece0013 100644 --- a/materia/forms.py +++ b/materia/forms.py @@ -115,18 +115,11 @@ class AcompanhamentoMateriaForm(ModelForm): class DocumentoAcessorioForm(ModelForm): - autor = forms.CharField(widget=forms.HiddenInput(), required=False) + # autor = forms.CharField(widget=forms.HiddenInput(), required=False) class Meta: model = DocumentoAcessorio - fields = ['tipo', - 'nome', - 'data', - 'autor', - 'ementa'] - widgets = { - 'data': forms.DateInput(attrs={'class': 'dateinput'}) - } + fields = ['tipo', 'nome', 'data', 'autor', 'ementa'] def clean_autor(self): autor_field = self.cleaned_data['autor'] @@ -138,40 +131,6 @@ class DocumentoAcessorioForm(ModelForm): if autor_field: return str(Autor.objects.get(id=autor_field)) - def __init__(self, excluir=False, *args, **kwargs): - - row1 = crispy_layout_mixin.to_row( - [('tipo', 4), ('nome', 4), ('data', 4)]) - - row2 = crispy_layout_mixin.to_row( - [('autor', 0), - (Button('pesquisar', - 'Pesquisar Autor', - css_class='btn btn-primary btn-sm'), 2), - (Button('limpar', - 'Limpar Autor', - css_class='btn btn-primary btn-sm'), 10)]) - - row3 = crispy_layout_mixin.to_row( - [('ementa', 12)]) - - more = [] - if excluir: - more = [Submit('Excluir', 'Excluir')] - - self.helper = FormHelper() - self.helper.layout = Layout( - Fieldset( - _('Incluir Documento Acessório'), - row1, - HTML(sapl.utils.autor_label), - HTML(sapl.utils.autor_modal), - row2, row3, - form_actions(more=more) - ) - ) - super(DocumentoAcessorioForm, self).__init__(*args, **kwargs) - class RelatoriaForm(ModelForm): diff --git a/materia/layouts.yaml b/materia/layouts.yaml index 860628c38..74bb98c40 100644 --- a/materia/layouts.yaml +++ b/materia/layouts.yaml @@ -62,11 +62,9 @@ Autoria: DocumentoAcessorio: Documento Acessório: - - tipo nome - - data autor - - nom_arquivo_FIXME + - tipo nome data + - autor - ementa - - txt_observacao_FIXME Numeracao: Numeração: diff --git a/materia/urls.py b/materia/urls.py index 4f435a1c3..332623881 100644 --- a/materia/urls.py +++ b/materia/urls.py @@ -4,8 +4,8 @@ from materia.views import (AcompanhamentoConfirmarView, AcompanhamentoExcluirView, AcompanhamentoMateriaView, AnexadaCrud, AutorCrud, AutoriaCrud, DespachoInicialCrud, - DocumentoAcessorioEditView, DocumentoAcessorioView, - LegislacaoCitadaCrud, MateriaLegislativaCrud, + DocumentoAcessorioCrud, LegislacaoCitadaCrud, + MateriaLegislativaCrud, MateriaLegislativaPesquisaView, MateriaTaView, NumeracaoCrud, OrgaoCrud, OrigemCrud, ProposicaoEditView, ProposicaoListView, @@ -28,7 +28,8 @@ urlpatterns = [ NumeracaoCrud.get_urls() + LegislacaoCitadaCrud.get_urls() + TramitacaoCrud.get_urls() + - RelatoriaCrud.get_urls())) + RelatoriaCrud.get_urls() + + DocumentoAcessorioCrud.get_urls())), # Integração com Compilação url(r'^materia/(?P[0-9]+)/ta$', @@ -54,10 +55,6 @@ urlpatterns = [ url(r'^sistema/materia/status-tramitacao/', include(StatusTramitacaoCrud.get_urls())), url(r'^sistema/materia/orgao/', include(OrgaoCrud.get_urls())), - url(r'^materia/(?P\d+)/documento-acessorio$', - DocumentoAcessorioView.as_view(), name='documento_acessorio'), - url(r'^materia/(?P\d+)/documento-acessorio/(?P\d+)/edit', - DocumentoAcessorioEditView.as_view(), name='documento_acessorio_edit'), url(r'^materia/proposicao$', ProposicaoView.as_view(), name='adicionar_proposicao'), url(r'^materia/proposicao_list$', diff --git a/materia/views.py b/materia/views.py index adcedaefb..413bd156b 100644 --- a/materia/views.py +++ b/materia/views.py @@ -46,7 +46,6 @@ TipoFimRelatoriaCrud = Crud.build(TipoFimRelatoria, 'fim_relatoria') AnexadaCrud = Crud.build(Anexada, '') TipoAutorCrud = Crud.build(TipoAutor, 'tipo_autor') AutorCrud = Crud.build(Autor, 'autor') -DocumentoAcessorioCrud = Crud.build(DocumentoAcessorio, '') OrgaoCrud = Crud.build(Orgao, 'orgao') TipoProposicaoCrud = Crud.build(TipoProposicao, 'tipo_proposicao') ProposicaoCrud = Crud.build(Proposicao, '') @@ -122,6 +121,18 @@ class TramitacaoCrud(MasterDetailCrud): return HttpResponseRedirect(url) +class DocumentoAcessorioCrud(MasterDetailCrud): + model = DocumentoAcessorio + parent_field = 'materia' + help_path = '' + + class CreateView(MasterDetailCrud.CreateView): + form_class = DocumentoAcessorioForm + + class UpdateView(MasterDetailCrud.UpdateView): + form_class = DocumentoAcessorioForm + + class AutoriaCrud(MasterDetailCrud): model = Autoria parent_field = 'materia' @@ -226,42 +237,6 @@ class MateriaLegislativaCrud(Crud): list_field_names = ['tipo', 'numero', 'ano', 'data_apresentacao'] -class DocumentoAcessorioView(CreateView): - template_name = "materia/documento_acessorio.html" - form_class = DocumentoAcessorioForm - - def get(self, request, *args, **kwargs): - materia = MateriaLegislativa.objects.get(id=kwargs['pk']) - docs = DocumentoAcessorio.objects.filter( - materia_id=kwargs['pk']).order_by('data') - form = DocumentoAcessorioForm() - - return self.render_to_response( - {'object': materia, - 'form': form, - 'docs': docs}) - - def post(self, request, *args, **kwargs): - form = self.get_form() - materia = MateriaLegislativa.objects.get(id=kwargs['pk']) - docs_list = DocumentoAcessorio.objects.filter( - materia_id=kwargs['pk']) - - if form.is_valid(): - documento_acessorio = form.save(commit=False) - documento_acessorio.materia = materia - documento_acessorio.save() - return self.form_valid(form) - else: - return self.render_to_response({'form': form, - 'object': materia, - 'docs': docs_list}) - - def get_success_url(self): - pk = self.kwargs['pk'] - return reverse('materia:documento_acessorio', kwargs={'pk': pk}) - - class AcompanhamentoConfirmarView(TemplateView): def get_redirect_url(self): @@ -297,42 +272,6 @@ class AcompanhamentoExcluirView(TemplateView): return HttpResponseRedirect(self.get_redirect_url()) -class DocumentoAcessorioEditView(CreateView): - template_name = "materia/documento_acessorio_edit.html" - form_class = DocumentoAcessorioForm - - def get(self, request, *args, **kwargs): - materia = MateriaLegislativa.objects.get(id=kwargs['pk']) - documento = DocumentoAcessorio.objects.get(id=kwargs['id']) - form = DocumentoAcessorioForm(instance=documento, excluir=True) - return self.render_to_response({'object': materia, 'form': form}) - - def post(self, request, *args, **kwargs): - form = self.get_form() - materia = MateriaLegislativa.objects.get(id=kwargs['pk']) - documento = DocumentoAcessorio.objects.get(id=kwargs['id']) - if form.is_valid(): - if 'Excluir' in request.POST: - documento.delete() - elif 'salvar' in request.POST: - documento.materia = materia - documento.tipo = form.cleaned_data['tipo'] - documento.data = form.cleaned_data['data'] - documento.nome = form.cleaned_data['nome'] - documento.autor = form.cleaned_data['autor'] - documento.ementa = form.cleaned_data['ementa'] - documento.save() - return redirect(self.get_success_url()) - else: - return self.render_to_response({'form': form, - 'object': materia, - 'doc': documento}) - - def get_success_url(self): - pk = self.kwargs['pk'] - return reverse('materia:documento_acessorio', kwargs={'pk': pk}) - - def load_email_templates(templates, context={}): emails = [] diff --git a/templates/materia/subnav.yaml b/templates/materia/subnav.yaml index f9d42dbdf..8dc4db159 100644 --- a/templates/materia/subnav.yaml +++ b/templates/materia/subnav.yaml @@ -7,7 +7,7 @@ - title: Despacho Inicial url: despachoinicial_list - title: Documento Acessório - url: documento_acessorio + url: documentoacessorio_list - title: Legislação Citada url: legislacaocitada_list - title: Numeração