#3821 centralizar geração próximo número para create de matérias legislativas#3822
Open
LeandroJatai wants to merge 9 commits intointerlegis:3.1.xfrom
Open
#3821 centralizar geração próximo número para create de matérias legislativas#3822LeandroJatai wants to merge 9 commits intointerlegis:3.1.xfrom
LeandroJatai wants to merge 9 commits intointerlegis:3.1.xfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR centralizes the logic for generating the next sequential number for legislative matters (MateriaLegislativa) into a single static method get_proximo_numero() in the MateriaLegislativa model. Previously, this logic was duplicated in ConfirmarProposicaoForm.save() and recuperar_materia() view function. The refactoring removes code duplication and adds support for the same numbering logic in the API's create endpoint.
Changes:
- Added static method
get_proximo_numero()to MateriaLegislativa model to centralize number generation logic - Refactored
recuperar_materia()view andConfirmarProposicaoForm.save()to use the new centralized method - Implemented custom
create()method in the API viewset to apply automatic numbering to API-created matters
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| sapl/materia/models.py | Added centralized get_proximo_numero() static method that handles all numbering sequence types (A, L, U) and supports preferred numbers |
| sapl/materia/views.py | Refactored recuperar_materia() to use the new centralized method, removing ~40 lines of duplicated logic |
| sapl/materia/forms.py | Refactored ConfirmarProposicaoForm.save() to use the new centralized method, removing ~35 lines of duplicated logic |
| sapl/api/views_materia.py | Added custom create() method to apply automatic numbering when creating MateriaLegislativa via API |
| sapl/api/serializers.py | Added import for MateriaLegislativa model to support API changes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Atualmente a geração de próximo número para matérias é um código replicado em dois pontos:
Um terceiro local se faz necessário, no create da API, em
_MateriaLegislativaViewSet, além de outros que possam surgir no futuro.Este PR centraliza a geração de próximo número em um método estático no model
MateriaLegislativa, refatoraConfirmarProposicaoFormerecuperar_materia, além de criar o método create na viewset para que em POSTs seja aplicada a mesma lógica de numeração configurada em Configurações da Aplicação e na sequencia de numeração do tipo de matéria.Descrição
Issue Relacionada
#3821
Motivação e Contexto
Centraliza a geração de próximo número para matéria legislativa e remove duplicidade de código.