Browse Source

HOT-FIX

pull/2091/head
VictorFabreF 8 years ago
parent
commit
4285644b64
  1. 7
      sapl/norma/views.py

7
sapl/norma/views.py

@ -1,4 +1,5 @@
import re
import weasyprint import weasyprint
from django.contrib.auth.mixins import PermissionRequiredMixin from django.contrib.auth.mixins import PermissionRequiredMixin
from django.core.exceptions import ObjectDoesNotExist from django.core.exceptions import ObjectDoesNotExist
@ -206,11 +207,7 @@ def recuperar_numero_norma(request):
norma = NormaJuridica.objects.filter(**param).order_by( norma = NormaJuridica.objects.filter(**param).order_by(
'tipo', 'ano').values_list('numero', 'ano').last() 'tipo', 'ano').values_list('numero', 'ano').last()
if norma: if norma:
try: response = JsonResponse({'numero': int(re.sub("[^0-9].*", '', norma[0])) + 1,
response = JsonResponse({'numero': int(norma[0]) + 1,
'ano': norma[1]})
except ValueError:
response = JsonResponse({'numero': int(norma[0][0:-1]) + 1,
'ano': norma[1]}) 'ano': norma[1]})
else: else:
response = JsonResponse( response = JsonResponse(

Loading…
Cancel
Save