-
Notifications
You must be signed in to change notification settings - Fork 100
Issue#3828 Refatorar Mesa Diretora #3829
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
LeandroJatai
wants to merge
38
commits into
3.1.x
Choose a base branch
from
3828_refatorar_mesa_diretora
base: 3.1.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
8ec36ad
feat: cria MesaDiretoraCrud e ComposicaoMesaCrud sem forms e regras d…
LeandroJatai ef96f77
feat: cria filterset para seleção de legislatura
LeandroJatai 3cb9bdf
feat: add field titulo
LeandroJatai 745a59e
feat: impl tabs na listagem de mesa diretora perfil público
LeandroJatai 86913cd
ajustes no layout publico de mesa
LeandroJatai 9318943
ajustes de scss para telas mobiles
LeandroJatai 8ae8641
altera link para button nas tabs de mesa diretora
LeandroJatai 0c64cad
add forms com regras de negócio
LeandroJatai 586e3df
add testes para mesa e composição
LeandroJatai f6582f8
ajustes nos testes e no form mesa diretora
LeandroJatai 0ec9585
remove código substituído
LeandroJatai b89a64f
fix: https://github.com/interlegis/sapl/pull/3829#discussion_r3083470632
LeandroJatai 8128831
fix: https://github.com/interlegis/sapl/pull/3829#discussion_r3083471759
LeandroJatai 5d3b742
fix: https://github.com/interlegis/sapl/pull/3829#discussion_r3083757964
LeandroJatai ef36793
fix: https://github.com/interlegis/sapl/pull/3829#discussion_r3093425814
LeandroJatai c228b04
fix: https://github.com/interlegis/sapl/pull/3829#discussion_r3083452572
LeandroJatai 4161598
fix: https://github.com/interlegis/sapl/pull/3829/changes/BASE..958e8…
LeandroJatai 962fb4f
fix: reviews
LeandroJatai fd734b2
fix: ajuste em subnav_mesa.yaml
LeandroJatai 04facfb
fix: https://github.com/interlegis/sapl/pull/3829#discussion_r3093455410
LeandroJatai 286b2f6
fix: https://github.com/interlegis/sapl/pull/3829#discussion_r3093434428
LeandroJatai 024a756
fix: https://github.com/interlegis/sapl/pull/3829#discussion_r3093327707
LeandroJatai 7b5ac2d
fix: https://github.com/interlegis/sapl/pull/3829#discussion_r3093438428
LeandroJatai d1c572e
fix: https://github.com/interlegis/sapl/pull/3829#discussion_r3093737607
LeandroJatai 4f0dc4e
fix: https://github.com/interlegis/sapl/pull/3829#discussion_r3093543652
LeandroJatai 5af98ee
fix: ajuste de related_name
LeandroJatai 38fa86a
fix: https://github.com/interlegis/sapl/pull/3829#discussion_r3182291955
LeandroJatai 95df206
Merge branch '3.1.x' into 3828_refatorar_mesa_diretora
joaohortsenado dc2c46e
fix: https://github.com/interlegis/sapl/pull/3829#discussion_r3182291971
LeandroJatai 3eee457
fix: https://github.com/interlegis/sapl/pull/3829#discussion_r3182291977
LeandroJatai 5edbc36
fix: https://github.com/interlegis/sapl/pull/3829#discussion_r3182291982
LeandroJatai 08c3a69
fix: https://github.com/interlegis/sapl/pull/3829#discussion_r3182291993
LeandroJatai f37706f
fix: https://github.com/interlegis/sapl/pull/3829#discussion_r3182291998
LeandroJatai ed9933f
fix: https://github.com/interlegis/sapl/pull/3829#discussion_r3182292004
LeandroJatai f915e58
fix: https://github.com/interlegis/sapl/pull/3829#discussion_r3182292011
LeandroJatai 4e70102
fix: https://github.com/interlegis/sapl/pull/3829#discussion_r3182292018
LeandroJatai 31e1a17
Fix: https://github.com/interlegis/sapl/pull/3829#discussion_r3715887423
LeandroJatai 426a5dc
Fix: https://github.com/interlegis/sapl/pull/3829#discussion_r3715887447
LeandroJatai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -183,6 +183,7 @@ small { | |
| hyphens: auto;*/ | ||
| } | ||
|
|
||
|
|
||
| @media print { | ||
| a[href]:after { | ||
| content: none !important; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| @import "~bootstrap/scss/variables"; | ||
|
|
||
| // Estilização do tab-content conectado ao nav-tabs (substitui inline style) | ||
| .nav-tabs + .tab-content { | ||
| border: 1px solid $nav-tabs-border-color; | ||
| border-top: 0; | ||
| border-radius: 0 0 $border-radius $border-radius; | ||
| } | ||
|
|
||
| @media (max-width: 992px) { | ||
| .nav-tabs { | ||
| position: relative; | ||
| flex-direction: column; | ||
| border: 1px solid $nav-tabs-border-color; | ||
| border-radius: $border-radius; // Totalmente arredondado — parece um botão/select | ||
| background-color: $white; | ||
| overflow: hidden; // Recorta filhos nas bordas arredondadas | ||
|
|
||
| // Seta indicando dropdown | ||
| &::after { | ||
| content: "▾"; | ||
| position: absolute; | ||
| right: 0.75rem; | ||
| top: 0.6rem; | ||
| font-size: 1rem; | ||
| color: $secondary; | ||
| pointer-events: none; | ||
| transition: transform 0.2s ease; | ||
| } | ||
|
|
||
| // Oculta todos os itens por padrão | ||
| .nav-item { | ||
| display: none; | ||
| width: 100%; | ||
|
|
||
| .nav-link { | ||
| border: none; | ||
| border-bottom: 1px solid $nav-tabs-border-color; | ||
| border-radius: 0; | ||
| width: 100%; | ||
| text-align: left; | ||
| padding-right: 2rem; | ||
| margin-bottom: 0; | ||
|
|
||
| &.active { | ||
| background-color: $nav-tabs-link-active-bg; | ||
| color: $nav-tabs-link-active-color; | ||
| border-color: transparent; | ||
| } | ||
|
|
||
| &:hover:not(.active) { | ||
| background-color: $light; | ||
| } | ||
| } | ||
|
|
||
| &:last-child .nav-link { | ||
| border-bottom: none; | ||
| } | ||
| } | ||
|
|
||
| // CSS nativo: exibe somente o item ativo (browsers com suporte a :has) | ||
| .nav-item:has(.nav-link.active) { | ||
| display: block; | ||
| } | ||
|
|
||
| // Estado expandido: via :focus-within (nativo) ou .nav-tabs--open (fallback JS) | ||
| &:focus-within, | ||
| &.nav-tabs--open { | ||
| border-radius: $border-radius $border-radius 0 0; // Arredonda apenas topo quando aberto | ||
| overflow: visible; | ||
| z-index: $zindex-dropdown; | ||
|
|
||
| &::after { | ||
| transform: rotate(180deg); | ||
| } | ||
|
|
||
| .nav-item { | ||
| display: block; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Em mobile, tab-content é visualmente independente do nav-tabs (que vira um select) | ||
| .nav-tabs + .tab-content { | ||
| border-top: 1px solid $nav-tabs-border-color; | ||
| border-radius: $border-radius; // Rounding completo — desconectado do nav-tabs | ||
| margin-top: 0.5rem; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| @import "./bootstrap/nav_navbar"; | ||
| @import "./bootstrap/nav_tabs"; | ||
| @import "./bootstrap/table"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
sapl/parlamentares/migrations/0046_mesadiretora_legislatura.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| # Generated by Django 2.2.28 on 2026-04-13 01:48 | ||
|
|
||
| from django.db import migrations, models | ||
| import django.db.models.deletion | ||
| from datetime import date | ||
|
|
||
| def add_legislatura_to_mesa_diretora(apps, schema_editor): | ||
| schema_editor.execute(""" | ||
| UPDATE parlamentares_mesadiretora md | ||
| SET | ||
| legislatura_id = sl.legislatura_id, | ||
| data_inicio = sl.data_inicio, | ||
| data_fim = sl.data_fim | ||
| FROM | ||
| parlamentares_sessaolegislativa sl | ||
| WHERE | ||
| sl.id = md.sessao_legislativa_id | ||
| """) | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('parlamentares', '0045_auto_20251201_1531'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AddField( | ||
| model_name='mesadiretora', | ||
| name='legislatura', | ||
| field=models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.PROTECT, to='parlamentares.Legislatura', verbose_name='Legislatura'), | ||
| ), | ||
| migrations.RunPython(add_legislatura_to_mesa_diretora), | ||
| ] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # Generated by Django 2.2.28 on 2026-04-13 01:56 | ||
|
|
||
| from django.db import migrations, models | ||
| import django.db.models.deletion | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('parlamentares', '0046_mesadiretora_legislatura'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AlterField( | ||
| model_name='mesadiretora', | ||
| name='legislatura', | ||
| field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='parlamentares.Legislatura', verbose_name='Legislatura'), | ||
| ), | ||
| migrations.RemoveField( | ||
| model_name='mesadiretora', | ||
| name='sessao_legislativa', | ||
| ), | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| # Generated by Django 2.2.28 on 2026-04-13 13:49 | ||
|
|
||
| from django.db import migrations, models | ||
| import django.db.models.deletion | ||
|
|
||
| def preencher_titulo_mesa_diretora(apps, schema_editor): | ||
| schema_editor.execute(""" | ||
| UPDATE parlamentares_mesadiretora | ||
| SET titulo = 'Mesa Diretora' || | ||
| CASE WHEN data_fim - data_inicio > 400 | ||
| THEN ' Biênio' | ||
| ELSE '' | ||
| END || ' ' || | ||
| EXTRACT(YEAR FROM data_inicio)::integer::text || '/' || | ||
| EXTRACT(YEAR FROM data_fim)::integer::text | ||
| WHERE data_inicio IS NOT NULL AND data_fim IS NOT NULL | ||
| """) | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('parlamentares', '0047_auto_20260412_2256'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AlterModelOptions( | ||
| name='mesadiretora', | ||
| options={'ordering': ('-legislatura', '-data_inicio'), 'verbose_name': 'Mesa Diretora', 'verbose_name_plural': 'Mesas Diretoras'}, | ||
| ), | ||
| migrations.AddField( | ||
| model_name='mesadiretora', | ||
| name='titulo', | ||
| field=models.CharField(default='', max_length=100, verbose_name='Título da Mesa Diretora'), | ||
| ), | ||
| migrations.AlterField( | ||
| model_name='composicaomesa', | ||
| name='mesa_diretora', | ||
| field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, related_name='composicaomesa_set', to='parlamentares.MesaDiretora'), | ||
| ), | ||
| migrations.RunPython(preencher_titulo_mesa_diretora), | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| # Generated by Django 2.2.28 on 2026-04-17 22:17 | ||
|
|
||
| from django.db import migrations, models | ||
| import django.db.models.deletion | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('parlamentares', '0048_auto_20260413_1049'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AlterField( | ||
| model_name='composicaomesa', | ||
| name='cargo', | ||
| field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='parlamentares.CargoMesa', verbose_name='Cargo'), | ||
| ), | ||
| migrations.AlterField( | ||
| model_name='composicaomesa', | ||
| name='mesa_diretora', | ||
| field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='composicaomesa_set', to='parlamentares.MesaDiretora', verbose_name='Mesa Diretora'), | ||
| ), | ||
| migrations.AlterField( | ||
| model_name='composicaomesa', | ||
| name='parlamentar', | ||
| field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='parlamentares.Parlamentar', verbose_name='Parlamentar'), | ||
| ), | ||
| migrations.AlterField( | ||
| model_name='mesadiretora', | ||
| name='data_fim', | ||
| field=models.DateField(verbose_name='Data Fim'), | ||
| ), | ||
| migrations.AlterField( | ||
| model_name='mesadiretora', | ||
| name='data_inicio', | ||
| field=models.DateField(verbose_name='Data Início'), | ||
|
joaohortsenado marked this conversation as resolved.
|
||
| ), | ||
| ] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # Generated by Django 2.2.28 on 2026-04-18 01:35 | ||
|
|
||
| from django.db import migrations, models | ||
| import django.db.models.deletion | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('parlamentares', '0049_auto_20260417_1917'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AlterField( | ||
| model_name='mesadiretora', | ||
| name='legislatura', | ||
| field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='mesadiretora_set', to='parlamentares.Legislatura', verbose_name='Legislatura'), | ||
| ), | ||
| ] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A migração pode gravar mesas fora do período da própria legislatura
O SQL está correto e rápido (as 59 migrations rodaram em 12,8s numa base real — o ponto do @edwardoliveira em
r3093425814ficou bem resolvido). O problema é que aSessaoLegislativade origem nem sempre respeita o intervalo daLegislatura, e a nova regra de contenção introduzida noclean()passa a rejeitar o resultado.Testando contra um dump de produção real, 2 das 64 mesas ficaram assim:
Somadas às 2 de borda coincidente que comentei em
models.py, são 4 de 64 mesas (6%) inválidas logo após o upgrade. A migração em si não quebra — o efeito aparece depois, quando alguém tenta editar.Não acho que a migration deva "consertar" datas silenciosamente: essa informação foi perdida pela modelagem anterior e qualquer chute pode piorar. Duas alternativas que me parecem melhores:
./manage.py verifica_mesas_diretoras) que lista os registros que não passam nofull_clean(), para a casa ajustar manualmente — junto de uma nota na documentação de upgrade.RunPythonadicional que apenas registra em log quais mesas ficaram inconsistentes, para não ser uma descoberta silenciosa em produção.(Registrando também que a preocupação que eu tinha levantado sobre
IntegrityErrorna0049não se confirmou:sessao_legislativaera FKNOT NULLe as datas da sessão também, então oUPDATEsempre popula. Já resolvi aquela thread.)