|
@ -3,6 +3,7 @@ from django.contrib import messages |
|
|
from django.core.urlresolvers import reverse, reverse_lazy |
|
|
from django.core.urlresolvers import reverse, reverse_lazy |
|
|
from django.utils.translation import ugettext_lazy as _ |
|
|
from django.utils.translation import ugettext_lazy as _ |
|
|
from django.views.generic import FormView |
|
|
from django.views.generic import FormView |
|
|
|
|
|
from django.views.generic.edit import ModelFormMixin |
|
|
|
|
|
|
|
|
from sapl.comissoes.models import Participacao |
|
|
from sapl.comissoes.models import Participacao |
|
|
from sapl.crud.base import (RP_CHANGE, RP_DETAIL, RP_LIST, Crud, CrudAux, |
|
|
from sapl.crud.base import (RP_CHANGE, RP_DETAIL, RP_LIST, Crud, CrudAux, |
|
@ -160,6 +161,15 @@ class LegislaturaCrud(CrudAux): |
|
|
numero = 1 |
|
|
numero = 1 |
|
|
return {'numero': numero} |
|
|
return {'numero': numero} |
|
|
|
|
|
|
|
|
|
|
|
def form_valid(self, form): |
|
|
|
|
|
self.object = form.save() |
|
|
|
|
|
queryset = Legislatura.objects.all().order_by('data_inicio') |
|
|
|
|
|
for i, obj in enumerate(queryset): |
|
|
|
|
|
obj.numero = i + 1 |
|
|
|
|
|
obj.save() |
|
|
|
|
|
|
|
|
|
|
|
return super(ModelFormMixin, self).form_valid(form) |
|
|
|
|
|
|
|
|
class UpdateView(CrudAux.UpdateView): |
|
|
class UpdateView(CrudAux.UpdateView): |
|
|
form_class = LegislaturaForm |
|
|
form_class = LegislaturaForm |
|
|
|
|
|
|
|
|