-
Notifications
You must be signed in to change notification settings - Fork 95
#3821 centralizar geração próximo número para create de matérias legislativas #3822
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
base: 3.1.x
Are you sure you want to change the base?
#3821 centralizar geração próximo número para create de matérias legislativas #3822
Conversation
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.
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>
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.