diff --git a/sigi/apps/casas/admin.py b/sigi/apps/casas/admin.py index 64be138..4638633 100644 --- a/sigi/apps/casas/admin.py +++ b/sigi/apps/casas/admin.py @@ -1,8 +1,10 @@ # -*- coding: utf-8 -*- from django.contrib import admin +from sigi.apps.casas.forms import CasaLegislativaForm from sigi.apps.casas.models import CasaLegislativa class CasaLegislativaAdmin(admin.ModelAdmin): + form = CasaLegislativaForm list_display = ('nome', 'email', 'pagina_web') list_display_links = ('nome',) diff --git a/sigi/apps/casas/forms.py b/sigi/apps/casas/forms.py new file mode 100644 index 0000000..1d77b0d --- /dev/null +++ b/sigi/apps/casas/forms.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +from django import forms +from django.contrib.localflavor.br.forms import BRCNPJField, BRZipCodeField +from sigi.apps.casas.models import CasaLegislativa + +class CasaLegislativaForm(forms.ModelForm): + cnpj = BRCNPJField( + label='CNPJ', + help_text='Utilize o formato XX.XXX.XXX/XXXX-XX ou ' + 'insira apenas os dígitos.' + ) + cep = BRZipCodeField(label='CEP', help_text='Formato: XXXXX-XXX.') + + class Meta: + model = CasaLegislativa diff --git a/sigi/apps/casas/models.py b/sigi/apps/casas/models.py index 9f5719e..7190b02 100644 --- a/sigi/apps/casas/models.py +++ b/sigi/apps/casas/models.py @@ -13,19 +13,18 @@ class CasaLegislativa(models.Model): nome = models.CharField(max_length=60) sigla = models.CharField(max_length=30, blank=True) tipo = models.CharField(max_length=2, choices=CASA_CHOICES) - cnpj = models.CharField( - 'CNPJ', - max_length=18, - help_text="Formato: ." - ) + cnpj = models.CharField('CNPJ', max_length=18) - logradouro = models.CharField(max_length=100) + logradouro = models.CharField( + max_length=100, + help_text='Avenida, rua, praça, jardim, parque...' + ) bairro = models.CharField(max_length=40) - cidade = models.ForeignKey('contatos.Municipio') - cep = models.CharField( - max_length=9, - help_text="Formato: XXXXX-XXX." + municipio = models.ForeignKey( + 'contatos.Municipio', + verbose_name='município' ) + cep = models.CharField(max_length=9) email = models.EmailField('e-mail', blank=True) pagina_web = models.URLField(u'página web', blank=True) telefones = generic.GenericRelation('contatos.Telefone')