From c9d78fc1838416100fa92533705a9f4c2985190e Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Thu, 5 May 2016 09:22:51 -0300 Subject: [PATCH] =?UTF-8?q?Init=20crud=20documento=20acess=C3=B3rio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- materia/forms.py | 1 - materia/views.py | 72 ------------------------------------------------ 2 files changed, 73 deletions(-) diff --git a/materia/forms.py b/materia/forms.py index 9d2738218..e8bc7389d 100644 --- a/materia/forms.py +++ b/materia/forms.py @@ -119,7 +119,6 @@ class DocumentoAcessorioForm(ModelForm): class Meta: model = DocumentoAcessorio fields = ['tipo', 'nome', 'data', 'autor', 'ementa', 'arquivo'] - widgets = {'autor': forms.HiddenInput()} def clean_autor(self): diff --git a/materia/views.py b/materia/views.py index f8db7131c..10b0e382c 100644 --- a/materia/views.py +++ b/materia/views.py @@ -342,42 +342,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): @@ -413,42 +377,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 = []