From b8c352df54df62470058eb18294252a03d5ee472 Mon Sep 17 00:00:00 2001 From: Guilherme Gondim Date: Tue, 19 Aug 2008 19:59:10 +0000 Subject: [PATCH] =?UTF-8?q?Adicionado=20formul=C3=A1rio=20personalizado=20?= =?UTF-8?q?para=20admin=20na=20app=20casas.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sigi/apps/casas/admin.py | 2 ++ sigi/apps/casas/forms.py | 15 +++++++++++++++ sigi/apps/casas/models.py | 19 +++++++++---------- 3 files changed, 26 insertions(+), 10 deletions(-) create mode 100644 sigi/apps/casas/forms.py 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')