Browse Source

Change fields to add mask

pull/98/head
Eduardo Edson Batista Cordeiro Alves 9 years ago
parent
commit
744582853f
  1. 40
      base/views.py
  2. 2
      templates/base.html

40
base/views.py

@ -1,17 +1,16 @@
import sapl
from django.views.generic.base import TemplateView
from .models import CasaLegislativa
from django.forms import ModelForm
from crispy_forms.helper import FormHelper
from crispy_forms.layout import ButtonHolder, Fieldset, Layout, Submit
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 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):
# XXX treat non existing template as a 404!!!!
@ -54,14 +53,29 @@ class CasaLegislativaTabelaAuxForm(ModelForm):
uf = forms.ChoiceField(required=False,
label='UF',
choices=[(a,a) for a in ESTADOS],
choices=[(a, a) for a in ESTADOS],
widget=forms.Select(
attrs={'class': 'selector'}))
attrs={'class': 'selector'}))
informacao_geral = forms.CharField(widget=forms.Textarea,
label='informacao_geral',
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:
model = CasaLegislativa
@ -130,6 +144,7 @@ class CasaLegislativaTabelaAuxForm(ModelForm):
)
super(CasaLegislativaTabelaAuxForm, self).__init__(*args, **kwargs)
class CasaLegislativaTableAuxView(FormMixin, GenericView):
template_name = "base/casa_leg_table_aux.html"
@ -153,7 +168,8 @@ class CasaLegislativaTableAuxView(FormMixin, GenericView):
except ObjectDoesNotExist:
casa_save = form.save(commit=False)
else:
casa_save = CasaLegislativaTabelaAuxForm(request.POST, instance = casa)
casa_save = CasaLegislativaTabelaAuxForm(
request.POST, instance=casa)
if 'logotipo' in request.FILES:
casa_save.logotipo = request.FILES['logotipo']

2
templates/base.html

@ -225,7 +225,7 @@
<script>
$(document).ready(function(){
$('.telefone').mask("(99) 9999-9999", {placeholder:"(__)____ -____"});
$('.telefone').mask("(99) 9999-9999", {placeholder:"(__) ____ -____"});
$('.cpf').mask("000.000.000-00", {placeholder:"___.___.___-__"});
$('.cep').mask("00000-000", {placeholder:"_____-___"});
});

Loading…
Cancel
Save