Browse Source
Update sapl/materia/models.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
pull/3822/head
LeandroJataí
1 week ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
11 additions and
3 deletions
-
sapl/materia/models.py
|
|
|
@ -441,12 +441,20 @@ class MateriaLegislativa(models.Model): |
|
|
|
else: |
|
|
|
numero = {'numero__max': 0} |
|
|
|
|
|
|
|
# Converte o número preferido para inteiro, se possível |
|
|
|
numero_preferido_int = None |
|
|
|
if numero_preferido: |
|
|
|
try: |
|
|
|
numero_preferido_int = int(numero_preferido) |
|
|
|
except (TypeError, ValueError): |
|
|
|
numero_preferido_int = None |
|
|
|
|
|
|
|
# Verifica se o número preferido está disponível |
|
|
|
if numero_preferido and not MateriaLegislativa.objects.filter( |
|
|
|
if numero_preferido_int is not None and not MateriaLegislativa.objects.filter( |
|
|
|
tipo=tipo, |
|
|
|
ano=ano, |
|
|
|
numero=numero_preferido).exists(): |
|
|
|
return int(numero_preferido), ano |
|
|
|
numero=numero_preferido_int).exists(): |
|
|
|
return numero_preferido_int, ano |
|
|
|
|
|
|
|
# Retorna o próximo número sequencial |
|
|
|
max_numero = numero['numero__max'] |
|
|
|
|