Browse Source

Fix #1247 Ajusta valor inicial de numero_ordem em MateriaOrdemDiaCrud (#1252)

.CreateView.get_initial para a (ultimo numero_ordem +1).

Signed-off-by: Eliseu Egewarth <eliseuegewarth@gmail.com>
pull/1255/head
Eliseu Egewarth 8 years ago
committed by Edward
parent
commit
ecbfe93e0a
  1. 5
      sapl/sessao/views.py

5
sapl/sessao/views.py

@ -6,7 +6,7 @@ from django.contrib.auth.decorators import permission_required
from django.contrib.auth.mixins import PermissionRequiredMixin from django.contrib.auth.mixins import PermissionRequiredMixin
from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.db.models import Q from django.db.models import Max, Q
from django.forms.utils import ErrorList from django.forms.utils import ErrorList
from django.http import JsonResponse from django.http import JsonResponse
from django.http.response import Http404, HttpResponseRedirect from django.http.response import Http404, HttpResponseRedirect
@ -162,6 +162,9 @@ class MateriaOrdemDiaCrud(MasterDetailCrud):
def get_initial(self): def get_initial(self):
self.initial['data_ordem'] = SessaoPlenaria.objects.get( self.initial['data_ordem'] = SessaoPlenaria.objects.get(
pk=self.kwargs['pk']).data_inicio.strftime('%d/%m/%Y') pk=self.kwargs['pk']).data_inicio.strftime('%d/%m/%Y')
max_numero_ordem = OrdemDia.objects.filter(
sessao_plenaria=self.kwargs['pk']).aggregate(Max('numero_ordem'))['numero_ordem__max']
self.initial['numero_ordem'] = (max_numero_ordem if max_numero_ordem else 0) + 1
return self.initial return self.initial
def get_success_url(self): def get_success_url(self):

Loading…
Cancel
Save