Browse Source

Add yes/no choices for fields as an util constant

pull/6/head
Marcio Mazza 10 years ago
parent
commit
c3a8f66901
  1. 9
      comissoes/models.py
  2. 5
      parlamentares/models.py
  3. 3
      sapl/utils.py

9
comissoes/models.py

@ -2,7 +2,7 @@ from django.db import models
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from parlamentares.models import Parlamentar from parlamentares.models import Parlamentar
from sapl.utils import make_choices from sapl.utils import YES_NO_CHOICES, make_choices
class TipoComissao(models.Model): class TipoComissao(models.Model):
@ -29,11 +29,6 @@ class TipoComissao(models.Model):
class Comissao(models.Model): class Comissao(models.Model):
UNIDADE_DELIBERATIVA_CHOICES, SIM, NAO = make_choices(
True, _('Sim'),
False, _('Não'),
)
tipo = models.ForeignKey(TipoComissao, verbose_name=_('Tipo')) tipo = models.ForeignKey(TipoComissao, verbose_name=_('Tipo'))
nome = models.CharField(max_length=60, verbose_name=_('Nome')) nome = models.CharField(max_length=60, verbose_name=_('Nome'))
sigla = models.CharField(max_length=10, verbose_name=_('Sigla')) sigla = models.CharField(max_length=10, verbose_name=_('Sigla'))
@ -81,7 +76,7 @@ class Comissao(models.Model):
email = models.CharField( email = models.CharField(
max_length=100, blank=True, null=True, verbose_name=_('E-mail')) max_length=100, blank=True, null=True, verbose_name=_('E-mail'))
unidade_deliberativa = models.BooleanField( unidade_deliberativa = models.BooleanField(
choices=UNIDADE_DELIBERATIVA_CHOICES, choices=YES_NO_CHOICES,
verbose_name=_('Unidade Deliberativa')) verbose_name=_('Unidade Deliberativa'))
class Meta: class Meta:

5
parlamentares/models.py

@ -1,7 +1,7 @@
from django.db import models from django.db import models
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from sapl.utils import make_choices from sapl.utils import YES_NO_CHOICES, make_choices
class Legislatura(models.Model): class Legislatura(models.Model):
@ -371,7 +371,8 @@ class CargoMesa(models.Model):
# TODO M2M ???? # TODO M2M ????
descricao = models.CharField( descricao = models.CharField(
max_length=50, verbose_name=_('Cargo na Mesa')) max_length=50, verbose_name=_('Cargo na Mesa'))
unico = models.BooleanField(verbose_name=_('Cargo Único')) unico = models.BooleanField(
choices=YES_NO_CHOICES, verbose_name=_('Cargo Único'))
class Meta: class Meta:
verbose_name = _('Cargo na Mesa') verbose_name = _('Cargo na Mesa')

3
sapl/utils.py

@ -1,5 +1,6 @@
from django.apps import apps from django.apps import apps
from django.contrib import admin from django.contrib import admin
from django.utils.translation import ugettext_lazy as _
# SAPL business apps # SAPL business apps
# This is a dependency order: each entry depends only on previous ones # This is a dependency order: each entry depends only on previous ones
@ -33,3 +34,5 @@ def make_choices(*choice_pairs):
yield choices yield choices
for key, value in choices: for key, value in choices:
yield key yield key
YES_NO_CHOICES = [(True, _('Sim')), (False, _('Não'))]

Loading…
Cancel
Save