Browse Source

Adicionado formulário personalizado para admin na app casas.

0.2
Guilherme Gondim 17 years ago
parent
commit
b8c352df54
  1. 2
      sigi/apps/casas/admin.py
  2. 15
      sigi/apps/casas/forms.py
  3. 19
      sigi/apps/casas/models.py

2
sigi/apps/casas/admin.py

@ -1,8 +1,10 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from django.contrib import admin from django.contrib import admin
from sigi.apps.casas.forms import CasaLegislativaForm
from sigi.apps.casas.models import CasaLegislativa from sigi.apps.casas.models import CasaLegislativa
class CasaLegislativaAdmin(admin.ModelAdmin): class CasaLegislativaAdmin(admin.ModelAdmin):
form = CasaLegislativaForm
list_display = ('nome', 'email', 'pagina_web') list_display = ('nome', 'email', 'pagina_web')
list_display_links = ('nome',) list_display_links = ('nome',)

15
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 <em>XX.XXX.XXX/XXXX-XX</em> ou '
'insira apenas os dígitos.'
)
cep = BRZipCodeField(label='CEP', help_text='Formato: <em>XXXXX-XXX</em>.')
class Meta:
model = CasaLegislativa

19
sigi/apps/casas/models.py

@ -13,19 +13,18 @@ class CasaLegislativa(models.Model):
nome = models.CharField(max_length=60) nome = models.CharField(max_length=60)
sigla = models.CharField(max_length=30, blank=True) sigla = models.CharField(max_length=30, blank=True)
tipo = models.CharField(max_length=2, choices=CASA_CHOICES) tipo = models.CharField(max_length=2, choices=CASA_CHOICES)
cnpj = models.CharField( cnpj = models.CharField('CNPJ', max_length=18)
'CNPJ',
max_length=18,
help_text="Formato: <em></em>."
)
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) bairro = models.CharField(max_length=40)
cidade = models.ForeignKey('contatos.Municipio') municipio = models.ForeignKey(
cep = models.CharField( 'contatos.Municipio',
max_length=9, verbose_name='município'
help_text="Formato: <em>XXXXX-XXX</em>."
) )
cep = models.CharField(max_length=9)
email = models.EmailField('e-mail', blank=True) email = models.EmailField('e-mail', blank=True)
pagina_web = models.URLField(u'página web', blank=True) pagina_web = models.URLField(u'página web', blank=True)
telefones = generic.GenericRelation('contatos.Telefone') telefones = generic.GenericRelation('contatos.Telefone')

Loading…
Cancel
Save