Browse Source

HOT-FIX: Mais bugs em Bancada/Bloco

pull/3369/head
eribeiro 4 years ago
parent
commit
daae2470ad
  1. 16
      sapl/parlamentares/forms.py
  2. 6
      sapl/parlamentares/views.py
  3. 7
      sapl/sessao/forms.py
  4. 6
      sapl/sessao/views.py

16
sapl/parlamentares/forms.py

@ -324,8 +324,11 @@ class ParlamentarCreateForm(ParlamentarForm):
return cleaned_data
@transaction.atomic
def save(self, commit=True):
def save(self, commit=False):
parlamentar = super(ParlamentarCreateForm, self).save(commit)
if not self.instance.pk:
parlamentar.save()
content_type = ContentType.objects.get_for_model(Parlamentar)
object_id = parlamentar.pk
tipo = TipoAutor.objects.get(content_type=content_type)
@ -335,6 +338,8 @@ class ParlamentarCreateForm(ParlamentarForm):
tipo=tipo,
nome=parlamentar.nome_parlamentar
)
else:
parlamentar.save()
return parlamentar
@ -495,11 +500,11 @@ class FrenteForm(ModelForm):
return cd
@transaction.atomic
def save(self, commit=True):
def save(self, commit=False):
frente = super(FrenteForm, self).save(commit)
if not self.instance.pk:
frente = super(FrenteForm, self).save(commit)
frente.save()
content_type = ContentType.objects.get_for_model(Frente)
object_id = frente.pk
tipo = TipoAutor.objects.get(descricao__icontains='Frente')
@ -509,6 +514,8 @@ class FrenteForm(ModelForm):
tipo=tipo,
nome=frente.nome
)
else:
frente.save()
return frente
@ -693,6 +700,7 @@ class BlocoForm(ModelForm):
@transaction.atomic
def save(self, commit=False):
bloco = super(BlocoForm, self).save(commit)
if not self.instance.pk:
bloco.save()
content_type = ContentType.objects.get_for_model(Bloco)
object_id = bloco.pk
@ -703,6 +711,8 @@ class BlocoForm(ModelForm):
tipo=tipo,
nome=bloco.nome
)
else:
bloco.save()
return bloco

6
sapl/parlamentares/views.py

@ -1282,6 +1282,12 @@ class BlocoCrud(CrudAux):
def get_success_url(self):
return reverse('sapl.parlamentares:bloco_list')
class UpdateView(CrudAux.UpdateView):
form_class = BlocoForm
def get_success_url(self):
return reverse('sapl.parlamentares:bloco_list')
class BlocoMembroCrud(MasterDetailCrud):
model = BlocoMembro

7
sapl/sessao/forms.py

@ -266,8 +266,11 @@ class BancadaForm(ModelForm):
return self.cleaned_data
@transaction.atomic
def save(self, commit=True):
def save(self, commit=False):
bancada = super(BancadaForm, self).save(commit)
if not self.instance.pk:
bancada.save()
content_type = ContentType.objects.get_for_model(Bancada)
object_id = bancada.pk
tipo = TipoAutor.objects.get(content_type=content_type)
@ -277,6 +280,8 @@ class BancadaForm(ModelForm):
tipo=tipo,
nome=bancada.nome
)
else:
bancada.save()
return bancada

6
sapl/sessao/views.py

@ -1113,6 +1113,12 @@ class BancadaCrud(CrudAux):
def get_success_url(self):
return reverse('sapl.sessao:bancada_list')
class UpdateView(CrudAux.UpdateView):
form_class = BancadaForm
def get_success_url(self):
return reverse('sapl.sessao:bancada_list')
def recuperar_numero_sessao_view(request):
try:

Loading…
Cancel
Save