Browse Source

Evita erro em migrate com BD vazio

pull/3630/head
Edward Ribeiro 2 years ago
parent
commit
cae71bcd59
  1. 32
      sapl/base/forms.py

32
sapl/base/forms.py

@ -44,13 +44,11 @@ from sapl.utils import (autor_label, autor_modal, ChoiceWithoutValidationField,
from .models import AppConfig, CasaLegislativa
ACTION_CREATE_USERS_AUTOR_CHOICE = [
('A', _('Associar um usuário existente')),
('N', _('Autor sem Usuário de Acesso ao Sapl')),
]
STATUS_USER_CHOICE = [
('R', _('Apenas retirar Perfil de Autor do Usuário que está sendo'
' desvinculado')),
@ -61,7 +59,6 @@ STATUS_USER_CHOICE = [
class UserAdminForm(ModelForm):
is_active = forms.TypedChoiceField(label=_('Usuário Ativo'),
choices=YES_NO_CHOICES,
coerce=lambda x: x == 'True')
@ -476,7 +473,6 @@ class SessaoLegislativaForm(FileFieldCheckMixin, ModelForm):
class TipoAutorForm(ModelForm):
class Meta:
model = TipoAutor
fields = ['descricao']
@ -742,11 +738,16 @@ class AutorFilterSet(django_filters.FilterSet):
def get_username():
return [(u, u) for u in get_user_model().objects.all().order_by('username').values_list('username', flat=True)]
try:
return [(u, u) for u in
get_user_model().objects.all().order_by('username').values_list('username', flat=True)]
except:
return []
def get_models():
return [(m, m) for m in AuditLog.objects.distinct('model_name').order_by('model_name').values_list('model_name', flat=True)]
return [(m, m) for m in
AuditLog.objects.distinct('model_name').order_by('model_name').values_list('model_name', flat=True)]
class AuditLogFilterSet(django_filters.FilterSet):
@ -784,13 +785,11 @@ class AuditLogFilterSet(django_filters.FilterSet):
class OperadorAutorForm(ModelForm):
class Meta:
model = OperadorAutor
fields = ['user', ]
def __init__(self, *args, **kwargs):
row = to_row([('user', 12)])
self.helper = SaplFormHelper()
@ -827,7 +826,6 @@ class RelatorioDocumentosAcessoriosFilterSet(django_filters.FilterSet):
fields = ['tipo', 'materia__tipo', 'data']
def __init__(self, *args, **kwargs):
super(
RelatorioDocumentosAcessoriosFilterSet, self
).__init__(*args, **kwargs)
@ -867,7 +865,6 @@ class RelatorioDocumentosAcessoriosFilterSet(django_filters.FilterSet):
class RelatorioAtasFilterSet(django_filters.FilterSet):
class Meta(FilterOverridesMetaMixin):
model = SessaoPlenaria
fields = ['data_inicio']
@ -918,7 +915,6 @@ def ultimo_ano_com_norma():
class RelatorioNormasMesFilterSet(django_filters.FilterSet):
ano = django_filters.ChoiceFilter(required=True,
label='Ano da Norma',
choices=choice_anos_com_normas,
@ -970,7 +966,6 @@ class RelatorioNormasMesFilterSet(django_filters.FilterSet):
class EstatisticasAcessoNormasForm(Form):
ano = forms.ChoiceField(required=True,
label='Ano de acesso',
choices=RANGE_ANOS,
@ -1034,7 +1029,6 @@ class EstatisticasAcessoNormasForm(Form):
class RelatorioNormasVigenciaFilterSet(django_filters.FilterSet):
ano = django_filters.ChoiceFilter(required=True,
label='Ano da Norma',
choices=choice_anos_com_normas,
@ -1091,7 +1085,6 @@ class RelatorioNormasVigenciaFilterSet(django_filters.FilterSet):
class RelatorioPresencaSessaoFilterSet(django_filters.FilterSet):
class Meta(FilterOverridesMetaMixin):
model = SessaoPlenaria
fields = ['data_inicio',
@ -1158,7 +1151,6 @@ class RelatorioPresencaSessaoFilterSet(django_filters.FilterSet):
class RelatorioHistoricoTramitacaoFilterSet(django_filters.FilterSet):
autoria__autor = django_filters.CharFilter(widget=forms.HiddenInput())
@property
@ -1225,7 +1217,6 @@ class RelatorioHistoricoTramitacaoFilterSet(django_filters.FilterSet):
class RelatorioDataFimPrazoTramitacaoFilterSet(django_filters.FilterSet):
ano = django_filters.ChoiceFilter(required=False,
label='Ano da Matéria',
choices=choice_anos_com_materias)
@ -1372,7 +1363,6 @@ class RelatorioAudienciaFilterSet(django_filters.FilterSet):
class RelatorioMateriasTramitacaoFilterSet(django_filters.FilterSet):
materia__ano = django_filters.ChoiceFilter(required=True,
label='Ano da Matéria',
choices=choice_anos_com_materias)
@ -1438,7 +1428,6 @@ class RelatorioMateriasTramitacaoFilterSet(django_filters.FilterSet):
class RelatorioMateriasPorAnoAutorTipoFilterSet(django_filters.FilterSet):
ano = django_filters.ChoiceFilter(required=True,
label='Ano da Matéria',
choices=choice_anos_com_materias)
@ -1478,7 +1467,6 @@ class RelatorioMateriasPorAnoAutorTipoFilterSet(django_filters.FilterSet):
class RelatorioMateriasPorAutorFilterSet(django_filters.FilterSet):
autoria__autor = django_filters.CharFilter(widget=forms.HiddenInput())
@property
@ -1535,7 +1523,6 @@ class RelatorioMateriasPorAutorFilterSet(django_filters.FilterSet):
class CasaLegislativaForm(FileFieldCheckMixin, ModelForm):
class Meta:
model = CasaLegislativa
@ -1690,18 +1677,15 @@ class ConfiguracoesAppForm(ModelForm):
class RecuperarSenhaForm(GoogleRecapthaMixin, PasswordResetForm):
logger = logging.getLogger(__name__)
def __init__(self, *args, **kwargs):
kwargs['title_label'] = _('Insira o e-mail cadastrado com a sua conta')
kwargs['action_label'] = _('Enviar')
super().__init__(*args, **kwargs)
def clean(self):
super(RecuperarSenhaForm, self).clean()
email_existente = get_user_model().objects.filter(
@ -1825,7 +1809,6 @@ class AlterarSenhaForm(Form):
class PartidoForm(FileFieldCheckMixin, ModelForm):
class Meta:
model = Partido
exclude = []
@ -1924,7 +1907,6 @@ class RelatorioHistoricoTramitacaoAdmFilterSet(django_filters.FilterSet):
class RelatorioNormasPorAutorFilterSet(django_filters.FilterSet):
autorianorma__autor = django_filters.CharFilter(widget=forms.HiddenInput())
@property

Loading…
Cancel
Save