diff --git a/base/views.py b/base/views.py index 58138cc16..a466da1d1 100644 --- a/base/views.py +++ b/base/views.py @@ -1,6 +1,6 @@ import sapl from crispy_forms.helper import FormHelper -from crispy_forms.layout import ButtonHolder, Fieldset, Layout, Submit +from crispy_forms.layout import ButtonHolder, HTML, Fieldset, Layout, Submit from django import forms from django.core.exceptions import ObjectDoesNotExist from django.core.urlresolvers import reverse @@ -11,6 +11,8 @@ from vanilla import GenericView from .models import CasaLegislativa +from sapl import settings + class HelpView(TemplateView): # XXX treat non existing template as a 404!!!! @@ -76,7 +78,7 @@ class CasaLegislativaTabelaAuxForm(ModelForm): fax = forms.CharField(label='Fax', required=False, widget=forms.TextInput( - attrs={'class': 'telefone'})) + attrs={'class': 'telefone'})) class Meta: @@ -135,6 +137,10 @@ class CasaLegislativaTabelaAuxForm(ModelForm): row3, row4, row5, + HTML("""{% if form.logotipo.value %} + + {% endif %}""", ), row6, row7, row8, @@ -162,7 +168,7 @@ class CasaLegislativaTableAuxView(FormMixin, GenericView): return self.render_to_response({'form': form}) def post(self, request, *args, **kwargs): - form = CasaLegislativaTabelaAuxForm(request.POST or request.FILES) + form = CasaLegislativaTabelaAuxForm(request.POST, request.FILES) if form.is_valid(): try: @@ -171,16 +177,11 @@ class CasaLegislativaTableAuxView(FormMixin, GenericView): casa_save = form.save(commit=False) else: casa_save = CasaLegislativaTabelaAuxForm( - request.POST, instance=casa) - - if 'logotipo' in request.FILES: - casa_save.logotipo = request.FILES['logotipo'] - + request.POST, request.FILES, instance=casa).save(commit=False) casa_save.save() - return self.form_valid(form) else: return self.render_to_response({'form': form}) def get_success_url(self): - return reverse('casa_legislativa') + return reverse('casa_legislativa') \ No newline at end of file