From 4123a7be3968e77932505d9ca5175f016e591251 Mon Sep 17 00:00:00 2001 From: Marcio Mazza Date: Thu, 16 Jul 2015 21:42:23 -0300 Subject: [PATCH] Add all scraped crispy forms --- comissoes/forms.py | 1 - legacy/scripts/old_names_adjustments.yaml | 8 +- legacy/scripts/scrap_original_forms.py | 37 ++- materia/forms.py | 332 ++++++++++++++++++++++ norma/forms.py | 99 +++++++ parlamentares/forms.py | 181 ++++++++++++ protocoloadm/forms.py | 170 +++++++++++ sessao/forms.py | 151 ++++++++++ 8 files changed, 964 insertions(+), 15 deletions(-) create mode 100644 materia/forms.py create mode 100644 norma/forms.py create mode 100644 parlamentares/forms.py create mode 100644 protocoloadm/forms.py create mode 100644 sessao/forms.py diff --git a/comissoes/forms.py b/comissoes/forms.py index bdb2775af..3a55ea14d 100644 --- a/comissoes/forms.py +++ b/comissoes/forms.py @@ -25,7 +25,6 @@ class TipoComissaoForm(forms.ModelForm): ('natureza', 2)], [('nome', 6), ('sigla', 6)], [('dispositivo_regimental', 6), ('natureza', 6)]], - ) diff --git a/legacy/scripts/old_names_adjustments.yaml b/legacy/scripts/old_names_adjustments.yaml index 38126d044..75c6b8a68 100644 --- a/legacy/scripts/old_names_adjustments.yaml +++ b/legacy/scripts/old_names_adjustments.yaml @@ -1,2 +1,8 @@ Comissao: - ind_unidade_deliberativa: ind_unid_deliberativa + ind_unidade_deliberativa: unidade_deliberativa + +Legislatura: + num_legislatura: id + +Parlamentar: + municipio: municipio_residencia diff --git a/legacy/scripts/scrap_original_forms.py b/legacy/scripts/scrap_original_forms.py index b7d96211d..ed059587c 100644 --- a/legacy/scripts/scrap_original_forms.py +++ b/legacy/scripts/scrap_original_forms.py @@ -8,6 +8,8 @@ import yaml from bs4 import BeautifulSoup from bs4.element import NavigableString, Tag +from django.apps.config import AppConfig + from legacy.migration import appconfs, get_renames from legacy.scripts.utils import listify, getsourcelines @@ -219,15 +221,20 @@ def extract_fieldsets_for_current(model): if not fieldsets: return - reverse_field_renames = {v: k for k, v in field_renames[model].items()} - adjustments = old_names_adjustments.get(model.__name__) - if adjustments: - for adjusted_key, key in adjustments.items(): - reverse_field_renames[adjusted_key] = reverse_field_renames[key] + try: + reverse_field_renames = {v: k for k, v in field_renames[model].items()} + adjustments = old_names_adjustments.get(model.__name__) + if adjustments: + reverse_field_renames.update(adjustments) - for fieldset in fieldsets: - rows = [colsplit([reverse_field_renames[name] for name, __ in line]) for line in fieldset['lines']] - yield [fieldset['legend']] + rows + for fieldset in fieldsets: + rows = [colsplit([reverse_field_renames.get(name, '%s_FIXME' % name) + for name, __ in line]) + for line in fieldset['lines'] if line] + yield [fieldset['legend']] + rows + except Exception as e: + print_title_and_fieldsets(model) + raise Exception(e, model) class Under(object): @@ -243,7 +250,13 @@ GAP = 12 pretty_printer = pprint.PrettyPrinter(width=80 - GAP) -def print_crispy_form(model): +def print_crispy_form(model_or_app): + if isinstance(model_or_app, AppConfig): + for model in model_or_app.models.values(): + print_crispy_form(model) + else: + model = model_or_app + fieldsets = extract_fieldsets_for_current(model) if fieldsets: print(""" @@ -254,7 +267,7 @@ class %(name)sForm(forms.ModelForm): exclude = [] def __init__(self, *args, **kwargs): - super(ComissaoForm, self).__init__(*args, **kwargs) + super(%(name)sForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.layout = SaplFormLayout( """ % {'name': model.__name__}) @@ -264,6 +277,4 @@ class %(name)sForm(forms.ModelForm): for line in lines.splitlines(): print(' ' * GAP + line if line.strip() else '') - print(""" - ) -""".strip('\n')) + print(" )") diff --git a/materia/forms.py b/materia/forms.py new file mode 100644 index 000000000..aeabc8477 --- /dev/null +++ b/materia/forms.py @@ -0,0 +1,332 @@ +from crispy_forms.helper import FormHelper +from django import forms +from django.utils.translation import ugettext as _ + +from .models import (Origem, MateriaLegislativa, Anexada, TipoAutor, Autor, + Autoria, DocumentoAcessorio, Numeracao, Orgao, Relatoria, + TipoProposicao, Proposicao, StatusTramitacao, UnidadeTramitacao, Tramitacao, ) +from sapl.layout import SaplFormLayout + + +class OrigemForm(forms.ModelForm): + + class Meta: + model = Origem + exclude = [] + + def __init__(self, *args, **kwargs): + super(OrigemForm, self).__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.layout = SaplFormLayout( + + [_('Origem'), + [('nome', 4), ('nome', 4), ('sigla', 4)], + [('nome', 6), ('sigla', 6)]], + ) + + +class MateriaLegislativaForm(forms.ModelForm): + + class Meta: + model = MateriaLegislativa + exclude = [] + + def __init__(self, *args, **kwargs): + super(MateriaLegislativaForm, self).__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.layout = SaplFormLayout( + + [_('Identificação Básica'), + [('tipo', 4), ('numero', 4), ('ano', 4)], + [('data_apresentacao', 4), + ('num_protocolo_spdo_FIXME', 4), + ('tipo_apresentacao', 4)], + [('nom_arquivo_FIXME', 6), ('modelo_FIXME', 6)]], + + [_('Proposição Eletrônica')], + + [_('Outras Informações'), + [('apelido', 4), ('dias_prazo', 4), ('polemica', 4)], + [('objeto', 4), ('regime_tramitacao', 4), ('em_tramitacao', 4)], + [('data_fim_prazo', 3), + ('data_publicacao', 3), + ('complementar', 3), + ('txt_cep_FIXME', 3)]], + + [_('Origem Externa'), + [('tipo_origem_externa', 4), + ('numero_origem_externa', 4), + ('ano_origem_externa', 4)], + [('local_origem_externa', 6), ('data_origem_externa', 6)]], + + [_('Dados Textuais'), + [('ementa', 12)], + [('indexacao', 12)], + [('observacao', 12)]], + ) + + +class AnexadaForm(forms.ModelForm): + + class Meta: + model = Anexada + exclude = [] + + def __init__(self, *args, **kwargs): + super(AnexadaForm, self).__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.layout = SaplFormLayout( + + [_('Matéria Legislativa'), + [('tip_id_basica_FIXME', 4), + ('num_ident_basica_FIXME', 4), + ('ano_ident_basica_FIXME', 4)], + [('data_anexacao', 6), ('data_desanexacao', 6)]], + + [_('Matéria Anexada'), + [('tip_id_basica_FIXME', 4), + ('num_ident_basica_FIXME', 4), + ('ano_ident_basica_FIXME', 4)], + [('data_anexacao', 6), ('data_desanexacao', 6)]], + ) + + +class TipoAutorForm(forms.ModelForm): + + class Meta: + model = TipoAutor + exclude = [] + + def __init__(self, *args, **kwargs): + super(TipoAutorForm, self).__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.layout = SaplFormLayout( + + [_('Tipo Autor'), + [('descricao', 4), ('descricao', 4), ('descricao', 4)], + [('descricao', 6), ('descricao', 6)]], + ) + + +class AutorForm(forms.ModelForm): + + class Meta: + model = Autor + exclude = [] + + def __init__(self, *args, **kwargs): + super(AutorForm, self).__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.layout = SaplFormLayout( + + [_('Autor'), + [('tipo', 6), ('nome', 6)], + [('autor_eh_usuario_FIXME', 12)], + [('login_FIXME', 12)]], + + [_('Acesso ao SAPL'), + [('autor_eh_usuario_FIXME', 12)], + [('login_FIXME', 12)]], + ) + + +class AutoriaForm(forms.ModelForm): + + class Meta: + model = Autoria + exclude = [] + + def __init__(self, *args, **kwargs): + super(AutoriaForm, self).__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.layout = SaplFormLayout( + + [_('Autoria'), + [('tip_autor_FIXME', 4), + ('nom_autor_FIXME', 4), + ('primeiro_autor', 4)]], + ) + + +class DocumentoAcessorioForm(forms.ModelForm): + + class Meta: + model = DocumentoAcessorio + exclude = [] + + def __init__(self, *args, **kwargs): + super(DocumentoAcessorioForm, self).__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.layout = SaplFormLayout( + + [_('Documento Acessório'), + [('tipo', 6), ('nome', 6)], + [('data', 6), ('autor', 6)], + [('nom_arquivo_FIXME', 12)], + [('ementa', 12)], + [('txt_observacao_FIXME', 12)]], + ) + + +class NumeracaoForm(forms.ModelForm): + + class Meta: + model = Numeracao + exclude = [] + + def __init__(self, *args, **kwargs): + super(NumeracaoForm, self).__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.layout = SaplFormLayout( + + [_('Numeração'), + [('tipo_materia', 6), ('numero_materia', 6)], + [('ano_materia', 6), ('data_materia', 6)]], + ) + + +class OrgaoForm(forms.ModelForm): + + class Meta: + model = Orgao + exclude = [] + + def __init__(self, *args, **kwargs): + super(OrgaoForm, self).__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.layout = SaplFormLayout( + + [_('Órgão'), + [('nome', 2), + ('nome', 2), + ('sigla', 2), + ('ind_unidade_deliberativa_FIXME', 2), + ('endereco', 2), + ('telefone', 2)], + [('nome', 4), + ('sigla', 4), + ('ind_unidade_deliberativa_FIXME', 4)], + [('endereco', 6), ('telefone', 6)]], + ) + + +class RelatoriaForm(forms.ModelForm): + + class Meta: + model = Relatoria + exclude = [] + + def __init__(self, *args, **kwargs): + super(RelatoriaForm, self).__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.layout = SaplFormLayout( + + [_('Relatoria'), + [('data_designacao_relator', 12)], + [('dados_FIXME', 12)], + [('data_destituicao_relator', 6), ('tipo_fim_relatoria', 6)]], + ) + + +class TipoProposicaoForm(forms.ModelForm): + + class Meta: + model = TipoProposicao + exclude = [] + + def __init__(self, *args, **kwargs): + super(TipoProposicaoForm, self).__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.layout = SaplFormLayout( + + [_('Tipo Proposição'), + [('tipo_proposicao_FIXME', 3), + ('tipo_proposicao_FIXME', 3), + ('mat_ou_doc_FIXME', 2), + ('mat_ou_doc_FIXME', 2), + ('modelo_FIXME', 2)], + [('tipo_proposicao_FIXME', 12)], + [('mat_ou_doc_FIXME', 6), ('mat_ou_doc_FIXME', 6)], + [('modelo_FIXME', 12)]], + ) + + +class ProposicaoForm(forms.ModelForm): + + class Meta: + model = Proposicao + exclude = [] + + def __init__(self, *args, **kwargs): + super(ProposicaoForm, self).__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.layout = SaplFormLayout( + + [_(''), + [('tipo', 4), ('dat_criacao_FIXME', 4), ('data_recebimento', 4)], + [('descricao_FIXME', 12)], + [('tip_id_basica_FIXME', 4), + ('num_ident_basica_FIXME', 4), + ('ano_ident_basica_FIXME', 4)], + [('nom_arquivo_FIXME', 6), ('modelo_FIXME', 6)]], + ) + + +class StatusTramitacaoForm(forms.ModelForm): + + class Meta: + model = StatusTramitacao + exclude = [] + + def __init__(self, *args, **kwargs): + super(StatusTramitacaoForm, self).__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.layout = SaplFormLayout( + + [_('Status Tramitação'), + [('sigla', 3), + ('sigla', 3), + ('ind_tramitacao_FIXME', 3), + ('descricao', 3)], + [('sigla', 6), ('ind_tramitacao_FIXME', 6)], + [('descricao', 12)]], + ) + + +class UnidadeTramitacaoForm(forms.ModelForm): + + class Meta: + model = UnidadeTramitacao + exclude = [] + + def __init__(self, *args, **kwargs): + super(UnidadeTramitacaoForm, self).__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.layout = SaplFormLayout( + + [_('Unidade Tramitação'), + [('orgao', 6), ('cod_unid_spdo_FIXME', 6)], + [('comissao', 12)], + [('parlamentar', 12)]], + ) + + +class TramitacaoForm(forms.ModelForm): + + class Meta: + model = Tramitacao + exclude = [] + + def __init__(self, *args, **kwargs): + super(TramitacaoForm, self).__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.layout = SaplFormLayout( + + [_('Tramitação'), + [('cod_ult_tram_dest_FIXME', 6), ('unidade_tramitacao_local', 6)], + [('status', 4), ('turno', 4), ('urgente', 4)], + [('unidade_tramitacao_destino', 4), + ('data_encaminhamento', 4), + ('data_fim_prazo', 4)], + [('texto', 12)]], + ) diff --git a/norma/forms.py b/norma/forms.py new file mode 100644 index 000000000..53fea89b3 --- /dev/null +++ b/norma/forms.py @@ -0,0 +1,99 @@ +from crispy_forms.helper import FormHelper +from django import forms +from django.utils.translation import ugettext as _ + +from .models import (AssuntoNorma, TipoNormaJuridica, NormaJuridica, + LegislacaoCitada) +from sapl.layout import SaplFormLayout + + +class AssuntoNormaForm(forms.ModelForm): + + class Meta: + model = AssuntoNorma + exclude = [] + + def __init__(self, *args, **kwargs): + super(AssuntoNormaForm, self).__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.layout = SaplFormLayout( + + [_('Assunto Norma Jurídica'), + [('assunto', 4), ('assunto', 4), ('descricao', 4)], + [('assunto', 12)], + [('descricao', 12)]], + ) + + +class TipoNormaJuridicaForm(forms.ModelForm): + + class Meta: + model = TipoNormaJuridica + exclude = [] + + def __init__(self, *args, **kwargs): + super(TipoNormaJuridicaForm, self).__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.layout = SaplFormLayout( + + [_('Tipo Norma Jurídica'), + [('descricao', 3), + ('descricao', 3), + ('sigla', 3), + ('equivalente_lexml', 3)], + [('descricao', 4), ('sigla', 4), ('equivalente_lexml', 4)]], + ) + + +class NormaJuridicaForm(forms.ModelForm): + + class Meta: + model = NormaJuridica + exclude = [] + + def __init__(self, *args, **kwargs): + super(NormaJuridicaForm, self).__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.layout = SaplFormLayout( + + [_('Identificação Básica'), + [('tipo', 4), ('numero', 4), ('ano', 4)], + [('data', 4), ('esfera_federacao', 4), ('complemento', 4)], + [('tip_id_basica_FIXME', 4), + ('num_ident_basica_FIXME', 4), + ('ano_ident_basica_FIXME', 4)], + [('data_publicacao', 3), + ('veiculo_publicacao', 3), + ('pagina_inicio_publicacao', 3), + ('pagina_fim_publicacao', 3)], + [('file_FIXME', 6), ('tip_situacao_norma_FIXME', 6)], + [('ementa', 12)], + [('indexacao', 12)], + [('observacao', 12)]], + + [_('Assuntos (Classificação) [+] '), + [('assunto_norma_FIXME', 12)], + [('assunto_norma_FIXME', 12)], + [('assunto_norma_FIXME', 12)]], + ) + + +class LegislacaoCitadaForm(forms.ModelForm): + + class Meta: + model = LegislacaoCitada + exclude = [] + + def __init__(self, *args, **kwargs): + super(LegislacaoCitadaForm, self).__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.layout = SaplFormLayout( + + [_('Legislação Citada'), + [('tip_norma_FIXME', 4), + ('num_norma_FIXME', 4), + ('ano_norma_FIXME', 4)], + [('disposicoes', 3), ('parte', 3), ('livro', 3), ('titulo', 3)], + [('capitulo', 3), ('secao', 3), ('subsecao', 3), ('artigo', 3)], + [('paragrafo', 3), ('inciso', 3), ('alinea', 3), ('item', 3)]], + ) diff --git a/parlamentares/forms.py b/parlamentares/forms.py new file mode 100644 index 000000000..ad752b417 --- /dev/null +++ b/parlamentares/forms.py @@ -0,0 +1,181 @@ +from crispy_forms.helper import FormHelper +from django import forms +from django.utils.translation import ugettext as _ + +from .models import (Legislatura, SessaoLegislativa, Coligacao, Partido, + Parlamentar, Dependente, Filiacao, Mandato) +from sapl.layout import SaplFormLayout + + +class LegislaturaForm(forms.ModelForm): + + class Meta: + model = Legislatura + exclude = [] + + def __init__(self, *args, **kwargs): + super(LegislaturaForm, self).__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.layout = SaplFormLayout( + + [_('Legislatura'), + [('id', 3), + ('id', 3), + ('data_inicio', 2), + ('data_fim', 2), + ('data_eleicao', 2)], + [('id', 12)], + [('data_inicio', 4), ('data_fim', 4), ('data_eleicao', 4)]], + ) + + +class SessaoLegislativaForm(forms.ModelForm): + + class Meta: + model = SessaoLegislativa + exclude = [] + + def __init__(self, *args, **kwargs): + super(SessaoLegislativaForm, self).__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.layout = SaplFormLayout( + + [_('Sessão Legislativa'), + [('numero', 2), + ('numero', 2), + ('tipo', 2), + ('data_inicio', 2), + ('data_fim', 2), + ('data_inicio_intervalo', 1), + ('data_fim_intervalo', 1)], + [('numero', 3), ('tipo', 3), ('data_inicio', 3), ('data_fim', 3)], + [('data_inicio_intervalo', 6), ('data_fim_intervalo', 6)]], + ) + + +class ColigacaoForm(forms.ModelForm): + + class Meta: + model = Coligacao + exclude = [] + + def __init__(self, *args, **kwargs): + super(ColigacaoForm, self).__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.layout = SaplFormLayout( + + [_('Coligação'), + [('nome', 3), + ('nome', 3), + ('legislatura', 3), + ('numero_votos', 3)], + [('nome', 4), ('legislatura', 4), ('numero_votos', 4)]], + ) + + +class PartidoForm(forms.ModelForm): + + class Meta: + model = Partido + exclude = [] + + def __init__(self, *args, **kwargs): + super(PartidoForm, self).__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.layout = SaplFormLayout( + + [_('Partido Político'), + [('nome', 3), + ('nome', 3), + ('sigla', 2), + ('data_criacao', 2), + ('data_extincao', 2)], + [('nome', 6), ('sigla', 6)], + [('data_criacao', 6), ('data_extincao', 6)]], + ) + + +class ParlamentarForm(forms.ModelForm): + + class Meta: + model = Parlamentar + exclude = [] + + def __init__(self, *args, **kwargs): + super(ParlamentarForm, self).__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.layout = SaplFormLayout( + + [_('Cadastro do Parlamentar'), + [('nome_parlamentar', 4), ('login_FIXME', 4), ('ativo', 4)], + [('nome_completo', 12)], + [('nivel_instrucao', 4), ('sexo', 4), ('data_nascimento', 4)], + [('cpf', 4), ('rg', 4), ('titulo_eleitor', 4)], + [('situacao_militar', 6), ('profissao', 6)], + [('endereco_web', 12)], + [('email', 12)], + [('numero_gab_parlamentar', 4), ('telefone', 4), ('fax', 4)], + [('endereco_residencia', 6), ('cep_residencia', 6)], + [('municipio_residencia', 6), ('uf_FIXME', 6)], + [('telefone_residencia', 6), ('fax_residencia', 6)], + [('locais_atuacao', 12)], + [('file_FIXME', 12)], + [('biografia', 12)], + [('observacao_FIXME', 12)], + [('parlamentar_salvar_FIXME', 12)]], + ) + + +class DependenteForm(forms.ModelForm): + + class Meta: + model = Dependente + exclude = [] + + def __init__(self, *args, **kwargs): + super(DependenteForm, self).__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.layout = SaplFormLayout( + + [_('Dependentes'), + [('nome', 12)], + [('tipo', 4), ('sexo', 4), ('data_nascimento', 4)], + [('cpf', 4), ('rg', 4), ('titulo_eleitor', 4)]], + ) + + +class FiliacaoForm(forms.ModelForm): + + class Meta: + model = Filiacao + exclude = [] + + def __init__(self, *args, **kwargs): + super(FiliacaoForm, self).__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.layout = SaplFormLayout( + + [_('Filiações Partidárias '), + [('partido', 4), ('data', 4), ('data_desfiliacao', 4)]], + ) + + +class MandatoForm(forms.ModelForm): + + class Meta: + model = Mandato + exclude = [] + + def __init__(self, *args, **kwargs): + super(MandatoForm, self).__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.layout = SaplFormLayout( + + [_('Mandato'), + [('legislatura', 4), ('coligacao', 4), ('votos_recebidos', 4)], + [('ind_titular_FIXME', 3), + ('dat_inicio_mandato_FIXME', 3), + ('data_fim_mandato', 3), + ('data_expedicao_diploma', 3)], + [('observacao', 12)]], + ) diff --git a/protocoloadm/forms.py b/protocoloadm/forms.py new file mode 100644 index 000000000..a87f8adf4 --- /dev/null +++ b/protocoloadm/forms.py @@ -0,0 +1,170 @@ +from crispy_forms.helper import FormHelper +from django import forms +from django.utils.translation import ugettext as _ + +from .models import (TipoDocumentoAdministrativo, DocumentoAdministrativo, + DocumentoAcessorioAdministrativo, Protocolo, + StatusTramitacaoAdministrativo, TramitacaoAdministrativo) +from sapl.layout import SaplFormLayout + + +class TipoDocumentoAdministrativoForm(forms.ModelForm): + + class Meta: + model = TipoDocumentoAdministrativo + exclude = [] + + def __init__(self, *args, **kwargs): + super(TipoDocumentoAdministrativoForm, self).__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.layout = SaplFormLayout( + + [_('Tipo Documento Administrativo'), + [('sigla', 4), ('sigla', 4), ('descricao', 4)], + [('sigla', 6), ('descricao', 6)]], + ) + + +class DocumentoAdministrativoForm(forms.ModelForm): + + class Meta: + model = DocumentoAdministrativo + exclude = [] + + def __init__(self, *args, **kwargs): + super(DocumentoAdministrativoForm, self).__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.layout = SaplFormLayout( + + [_('Formulário de Cadastro'), + [('tipo', 4), ('numero', 4), ('ano', 4)], + [('data', 6), ('numero_protocolo', 6)], + [('assunto', 12)], + [('interessado', 6), ('tramitacao', 6)], + [('nom_arquivo_FIXME', 12)], + [('dias_prazo', 4), ('data_fim_prazo', 4), ('observacao', 4)], + [('observacao', 12)]], + + [_('Indentificação Básica'), + [('tipo', 4), ('numero', 4), ('ano', 4)], + [('data', 6), ('numero_protocolo', 6)], + [('assunto', 12)], + [('interessado', 6), ('tramitacao', 6)], + [('nom_arquivo_FIXME', 12)]], + + [_('Outras Informações'), + [('dias_prazo', 4), ('data_fim_prazo', 4), ('observacao', 4)], + [('observacao', 12)]], + ) + + +class DocumentoAcessorioAdministrativoForm(forms.ModelForm): + + class Meta: + model = DocumentoAcessorioAdministrativo + exclude = [] + + def __init__(self, *args, **kwargs): + super(DocumentoAcessorioAdministrativoForm, self).__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.layout = SaplFormLayout( + + [_('Documento Administrativo'), + [('tipo', 4), ('nome', 4), ('data', 4)], + [('autor', 12)], + [('arquivo', 12)], + [('assunto', 12)]], + + [_('Documento Acessório'), + [('tipo', 4), ('nome', 4), ('data', 4)], + [('autor', 12)], + [('arquivo', 12)], + [('assunto', 12)]], + ) + + +class ProtocoloForm(forms.ModelForm): + + class Meta: + model = Protocolo + exclude = [] + + def __init__(self, *args, **kwargs): + super(ProtocoloForm, self).__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.layout = SaplFormLayout( + + [_('Formulário de Cadastro'), + [('tipo_documento', 4), + ('num_documento_FIXME', 4), + ('ano_documento_FIXME', 4)], + [('dat_documento_FIXME', 6), ('numero', 6)], + [('txt_assunto_FIXME', 12)], + [('interessado', 6), ('ind_tramitacao_FIXME', 6)], + [('nom_arquivo_FIXME', 12)], + [('num_dias_prazo_FIXME', 4), + ('dat_fim_prazo_FIXME', 4), + ('observacao', 4)], + [('observacao', 12)]], + + [_('Indentificação Básica'), + [('tipo_documento', 4), + ('num_documento_FIXME', 4), + ('ano_documento_FIXME', 4)], + [('dat_documento_FIXME', 6), ('numero', 6)], + [('txt_assunto_FIXME', 12)], + [('interessado', 6), ('ind_tramitacao_FIXME', 6)], + [('nom_arquivo_FIXME', 12)]], + + [_('Outras Informações'), + [('num_dias_prazo_FIXME', 4), + ('dat_fim_prazo_FIXME', 4), + ('observacao', 4)], + [('observacao', 12)]], + ) + + +class StatusTramitacaoAdministrativoForm(forms.ModelForm): + + class Meta: + model = StatusTramitacaoAdministrativo + exclude = [] + + def __init__(self, *args, **kwargs): + super(StatusTramitacaoAdministrativoForm, self).__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.layout = SaplFormLayout( + + [_('Status Tramitação Administrativo'), + [('sigla', 3), + ('sigla', 3), + ('ind_tramitacao_FIXME', 3), + ('descricao', 3)], + [('sigla', 6), ('ind_tramitacao_FIXME', 6)], + [('descricao', 12)]], + ) + + +class TramitacaoAdministrativoForm(forms.ModelForm): + + class Meta: + model = TramitacaoAdministrativo + exclude = [] + + def __init__(self, *args, **kwargs): + super(TramitacaoAdministrativoForm, self).__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.layout = SaplFormLayout( + + [_('Documento Administrativo'), + [('cod_ult_tram_dest_FIXME', 6), ('unidade_tramitacao_local', 6)], + [('status', 6), ('unidade_tramitacao_destino', 6)], + [('data_encaminhamento', 6), ('data_fim_prazo', 6)], + [('texto', 12)]], + + [_('Tramitação'), + [('cod_ult_tram_dest_FIXME', 6), ('unidade_tramitacao_local', 6)], + [('status', 6), ('unidade_tramitacao_destino', 6)], + [('data_encaminhamento', 6), ('data_fim_prazo', 6)], + [('texto', 12)]], + ) diff --git a/sessao/forms.py b/sessao/forms.py new file mode 100644 index 000000000..1de73c54f --- /dev/null +++ b/sessao/forms.py @@ -0,0 +1,151 @@ +from crispy_forms.helper import FormHelper +from django import forms +from django.utils.translation import ugettext as _ + +from .models import (TipoSessaoPlenaria, SessaoPlenaria, ExpedienteMateria, + TipoExpediente, OrdemDia, TipoResultadoVotacao, + RegistroVotacao) +from sapl.layout import SaplFormLayout + + +class TipoSessaoPlenariaForm(forms.ModelForm): + + class Meta: + model = TipoSessaoPlenaria + exclude = [] + + def __init__(self, *args, **kwargs): + super(TipoSessaoPlenariaForm, self).__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.layout = SaplFormLayout( + + [_('Tipo de Sessão Plenária'), + [('nome', 6), ('quorum_minimo', 6)], + [('tipo_sessao_plenaria_salvar_FIXME', 12)]], + ) + + +class SessaoPlenariaForm(forms.ModelForm): + + class Meta: + model = SessaoPlenaria + exclude = [] + + def __init__(self, *args, **kwargs): + super(SessaoPlenariaForm, self).__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.layout = SaplFormLayout( + + [_('Dados Básicos'), + [('numero', 3), + ('tip_sessao_plen_FIXME', 3), + ('legislatura', 3), + ('sessao_leg_FIXME', 3)], + [('data_inicio', 12)], + [('data_fim', 12)], + [('file_pauta_FIXME', 3), + ('file_ata_FIXME', 3), + ('url_audio', 3), + ('url_video', 3)], + [('url_audio', 6), ('url_video', 6)], + [('url_audio', 6), ('url_video', 6)]], + ) + + +class ExpedienteMateriaForm(forms.ModelForm): + + class Meta: + model = ExpedienteMateria + exclude = [] + + def __init__(self, *args, **kwargs): + super(ExpedienteMateriaForm, self).__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.layout = SaplFormLayout( + + [_('Cadastro de Matérias do Expediente'), + [('data_ordem', 4), ('tip_sessao_FIXME', 4), ('numero_ordem', 4)], + [('tip_id_basica_FIXME', 4), + ('num_ident_basica_FIXME', 4), + ('ano_ident_basica_FIXME', 4)], + [('tipo_votacao', 12)], + [('observacao', 12)]], + ) + + +class TipoExpedienteForm(forms.ModelForm): + + class Meta: + model = TipoExpediente + exclude = [] + + def __init__(self, *args, **kwargs): + super(TipoExpedienteForm, self).__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.layout = SaplFormLayout( + + [_('Tipo de Expediente'), + [('nome', 12)], + [('tipo_expediente_salvar_FIXME', 12)]], + ) + + +class OrdemDiaForm(forms.ModelForm): + + class Meta: + model = OrdemDia + exclude = [] + + def __init__(self, *args, **kwargs): + super(OrdemDiaForm, self).__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.layout = SaplFormLayout( + + [_('Cadastro de Matérias da Ordem do Dia'), + [('data_ordem', 4), ('tip_sessao_FIXME', 4), ('numero_ordem', 4)], + [('tip_id_basica_FIXME', 4), + ('num_ident_basica_FIXME', 4), + ('ano_ident_basica_FIXME', 4)], + [('tipo_votacao', 12)], + [('observacao', 12)]], + ) + + +class TipoResultadoVotacaoForm(forms.ModelForm): + + class Meta: + model = TipoResultadoVotacao + exclude = [] + + def __init__(self, *args, **kwargs): + super(TipoResultadoVotacaoForm, self).__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.layout = SaplFormLayout( + + [_('Tipo de Resultado da Votação'), + [('nome', 12)], + [('tipo_resultado_votacao_salvar_FIXME', 12)]], + ) + + +class RegistroVotacaoForm(forms.ModelForm): + + class Meta: + model = RegistroVotacao + exclude = [] + + def __init__(self, *args, **kwargs): + super(RegistroVotacaoForm, self).__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.layout = SaplFormLayout( + + [_('Votação Simbólica'), + [('numero_votos_sim', 3), + ('numero_votos_nao', 3), + ('numero_abstencoes', 3), + ('nao_votou_FIXME', 3)], + [('votacao_branco_FIXME', 6), + ('ind_votacao_presidente_FIXME', 6)], + [('tipo_resultado_votacao', 12)], + [('observacao', 12)]], + )