|
@ -1,17 +1,16 @@ |
|
|
import sapl |
|
|
import sapl |
|
|
|
|
|
from crispy_forms.helper import FormHelper |
|
|
from django.views.generic.base import TemplateView |
|
|
from crispy_forms.layout import ButtonHolder, Fieldset, Layout, Submit |
|
|
from .models import CasaLegislativa |
|
|
|
|
|
from django.forms import ModelForm |
|
|
|
|
|
from django import forms |
|
|
from django import forms |
|
|
|
|
|
from django.core.exceptions import ObjectDoesNotExist |
|
|
|
|
|
from django.core.urlresolvers import reverse |
|
|
|
|
|
from django.forms import ModelForm |
|
|
|
|
|
from django.views.generic.base import TemplateView |
|
|
from django.views.generic.edit import FormMixin |
|
|
from django.views.generic.edit import FormMixin |
|
|
from vanilla import GenericView |
|
|
from vanilla import GenericView |
|
|
from crispy_forms.helper import FormHelper |
|
|
|
|
|
from crispy_forms.layout import (HTML, ButtonHolder, Column, Fieldset, Layout, |
|
|
|
|
|
Submit) |
|
|
|
|
|
from django.core.exceptions import ObjectDoesNotExist |
|
|
|
|
|
|
|
|
|
|
|
from django.core.urlresolvers import reverse |
|
|
from .models import CasaLegislativa |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class HelpView(TemplateView): |
|
|
class HelpView(TemplateView): |
|
|
# XXX treat non existing template as a 404!!!! |
|
|
# XXX treat non existing template as a 404!!!! |
|
@ -54,14 +53,29 @@ class CasaLegislativaTabelaAuxForm(ModelForm): |
|
|
|
|
|
|
|
|
uf = forms.ChoiceField(required=False, |
|
|
uf = forms.ChoiceField(required=False, |
|
|
label='UF', |
|
|
label='UF', |
|
|
choices=[(a,a) for a in ESTADOS], |
|
|
choices=[(a, a) for a in ESTADOS], |
|
|
widget=forms.Select( |
|
|
widget=forms.Select( |
|
|
attrs={'class': 'selector'})) |
|
|
attrs={'class': 'selector'})) |
|
|
|
|
|
|
|
|
informacao_geral = forms.CharField(widget=forms.Textarea, |
|
|
informacao_geral = forms.CharField(widget=forms.Textarea, |
|
|
label='informacao_geral', |
|
|
label='informacao_geral', |
|
|
required=True) |
|
|
required=True) |
|
|
|
|
|
|
|
|
|
|
|
telefone = forms.CharField(label='Telefone', |
|
|
|
|
|
required=True, |
|
|
|
|
|
widget=forms.TextInput( |
|
|
|
|
|
attrs={'class': 'telefone'})) |
|
|
|
|
|
|
|
|
|
|
|
cep = forms.CharField(label='Cep', |
|
|
|
|
|
required=True, |
|
|
|
|
|
widget=forms.TextInput( |
|
|
|
|
|
attrs={'class': 'cep'})) |
|
|
|
|
|
|
|
|
|
|
|
fax = forms.CharField(label='Fax', |
|
|
|
|
|
required=True, |
|
|
|
|
|
widget=forms.TextInput( |
|
|
|
|
|
attrs={'class': 'telefone'})) |
|
|
|
|
|
|
|
|
class Meta: |
|
|
class Meta: |
|
|
|
|
|
|
|
|
model = CasaLegislativa |
|
|
model = CasaLegislativa |
|
@ -81,10 +95,10 @@ class CasaLegislativaTabelaAuxForm(ModelForm): |
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs): |
|
|
def __init__(self, *args, **kwargs): |
|
|
|
|
|
|
|
|
row1 = sapl.layout.to_row( |
|
|
row1 = sapl.layout.to_row( |
|
|
[('codigo', 2), |
|
|
[('codigo', 2), |
|
|
('nome', 5), |
|
|
('nome', 5), |
|
|
('sigla', 5)]) |
|
|
('sigla', 5)]) |
|
|
|
|
|
|
|
|
row2 = sapl.layout.to_row( |
|
|
row2 = sapl.layout.to_row( |
|
|
[('endereco', 8), |
|
|
[('endereco', 8), |
|
@ -113,7 +127,7 @@ class CasaLegislativaTabelaAuxForm(ModelForm): |
|
|
self.helper = FormHelper() |
|
|
self.helper = FormHelper() |
|
|
self.helper.layout = Layout( |
|
|
self.helper.layout = Layout( |
|
|
Fieldset( |
|
|
Fieldset( |
|
|
'Dados Básicos', |
|
|
'Dados Básicos', |
|
|
row1, |
|
|
row1, |
|
|
row2, |
|
|
row2, |
|
|
row3, |
|
|
row3, |
|
@ -130,6 +144,7 @@ class CasaLegislativaTabelaAuxForm(ModelForm): |
|
|
) |
|
|
) |
|
|
super(CasaLegislativaTabelaAuxForm, self).__init__(*args, **kwargs) |
|
|
super(CasaLegislativaTabelaAuxForm, self).__init__(*args, **kwargs) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CasaLegislativaTableAuxView(FormMixin, GenericView): |
|
|
class CasaLegislativaTableAuxView(FormMixin, GenericView): |
|
|
|
|
|
|
|
|
template_name = "base/casa_leg_table_aux.html" |
|
|
template_name = "base/casa_leg_table_aux.html" |
|
@ -153,7 +168,8 @@ class CasaLegislativaTableAuxView(FormMixin, GenericView): |
|
|
except ObjectDoesNotExist: |
|
|
except ObjectDoesNotExist: |
|
|
casa_save = form.save(commit=False) |
|
|
casa_save = form.save(commit=False) |
|
|
else: |
|
|
else: |
|
|
casa_save = CasaLegislativaTabelaAuxForm(request.POST, instance = casa) |
|
|
casa_save = CasaLegislativaTabelaAuxForm( |
|
|
|
|
|
request.POST, instance=casa) |
|
|
|
|
|
|
|
|
if 'logotipo' in request.FILES: |
|
|
if 'logotipo' in request.FILES: |
|
|
casa_save.logotipo = request.FILES['logotipo'] |
|
|
casa_save.logotipo = request.FILES['logotipo'] |
|
|