|
|
|
@ -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 = [] |
|
|
|
|