From 9c1ba20f8331eca4d4596f957f4ae77d2e480e0b Mon Sep 17 00:00:00 2001 From: Edward Ribeiro Date: Mon, 7 Mar 2016 11:52:59 -0300 Subject: [PATCH] =?UTF-8?q?Refatora=20Casa=20Legislativa=20e=20Adicionar?= =?UTF-8?q?=20comiss=C3=B5es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base/views.py | 5 ++--- comissoes/views.py | 27 +++++---------------------- 2 files changed, 7 insertions(+), 25 deletions(-) diff --git a/base/views.py b/base/views.py index ac935b3e2..a04a3e700 100644 --- a/base/views.py +++ b/base/views.py @@ -50,12 +50,11 @@ class CasaLegislativaTableAuxView(FormMixin, GenericView): except OSError: pass # Should log this error!!!!! casa.logotipo = None - casa_save = CasaLegislativaTabelaAuxForm( + CasaLegislativaTabelaAuxForm( request.POST, request.FILES, instance=casa - ).save(commit=False) - casa_save.save() + ).save() else: form.save() diff --git a/comissoes/views.py b/comissoes/views.py index 2b14b214a..33cfd3358 100644 --- a/comissoes/views.py +++ b/comissoes/views.py @@ -1,7 +1,7 @@ from django.contrib import messages -from django.core.urlresolvers import reverse +from django.core.urlresolvers import reverse, reverse_lazy from django.utils.translation import ugettext_lazy as _ -from django.views.generic import ListView +from django.views.generic import CreateView, ListView from django.views.generic.edit import FormMixin from vanilla import GenericView @@ -20,28 +20,11 @@ tipo_comissao_crud = Crud(TipoComissao, 'tipo_comissao') comissao_crud = Crud(Comissao, 'modulo_comissoes') -class CadastrarComissaoView(FormMixin, GenericView): +class CadastrarComissaoView(CreateView): template_name = "comissoes/cadastrar_comissao.html" - - def get(self, request, *args, **kwargs): - form = CadastrarComissaoForm() - - return self.render_to_response({'form': form}) - - def post(self, request, *args, **kwargs): - form = CadastrarComissaoForm(request.POST, request.FILES) - - if form.is_valid(): - - form.save() - - return self.form_valid(form) - else: - return self.render_to_response({'form': form}) - - def get_success_url(self): - return reverse('comissao:list') + form_class = CadastrarComissaoForm + success_url = reverse_lazy('comissao:list') class ComposicaoView(FormMixin, GenericView):