Skip to content

Commit

Permalink
HOT-FIX: Mais bugs em Bancada/Bloco
Browse files Browse the repository at this point in the history
  • Loading branch information
eribeiro committed Mar 3, 2021
1 parent 664576b commit daae247
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 32 deletions.
54 changes: 32 additions & 22 deletions sapl/parlamentares/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,17 +324,22 @@ def clean(self):
return cleaned_data

@transaction.atomic
def save(self, commit=True):
def save(self, commit=False):
parlamentar = super(ParlamentarCreateForm, self).save(commit)
content_type = ContentType.objects.get_for_model(Parlamentar)
object_id = parlamentar.pk
tipo = TipoAutor.objects.get(content_type=content_type)
Autor.objects.create(
content_type=content_type,
object_id=object_id,
tipo=tipo,
nome=parlamentar.nome_parlamentar
)

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)
Autor.objects.create(
content_type=content_type,
object_id=object_id,
tipo=tipo,
nome=parlamentar.nome_parlamentar
)
else:
parlamentar.save()
return parlamentar


Expand Down Expand Up @@ -495,11 +500,11 @@ def clean(self):
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')
Expand All @@ -509,6 +514,8 @@ def save(self, commit=True):
tipo=tipo,
nome=frente.nome
)
else:
frente.save()
return frente


Expand Down Expand Up @@ -693,16 +700,19 @@ def clean(self):
@transaction.atomic
def save(self, commit=False):
bloco = super(BlocoForm, self).save(commit)
bloco.save()
content_type = ContentType.objects.get_for_model(Bloco)
object_id = bloco.pk
tipo = TipoAutor.objects.get(content_type=content_type)
Autor.objects.create(
content_type=content_type,
object_id=object_id,
tipo=tipo,
nome=bloco.nome
)
if not self.instance.pk:
bloco.save()
content_type = ContentType.objects.get_for_model(Bloco)
object_id = bloco.pk
tipo = TipoAutor.objects.get(content_type=content_type)
Autor.objects.create(
content_type=content_type,
object_id=object_id,
tipo=tipo,
nome=bloco.nome
)
else:
bloco.save()
return bloco


Expand Down
6 changes: 6 additions & 0 deletions sapl/parlamentares/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1282,6 +1282,12 @@ class CreateView(CrudAux.CreateView):
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
Expand Down
25 changes: 15 additions & 10 deletions sapl/sessao/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,17 +266,22 @@ def clean(self):
return self.cleaned_data

@transaction.atomic
def save(self, commit=True):
def save(self, commit=False):
bancada = super(BancadaForm, self).save(commit)
content_type = ContentType.objects.get_for_model(Bancada)
object_id = bancada.pk
tipo = TipoAutor.objects.get(content_type=content_type)
Autor.objects.create(
content_type=content_type,
object_id=object_id,
tipo=tipo,
nome=bancada.nome
)

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)
Autor.objects.create(
content_type=content_type,
object_id=object_id,
tipo=tipo,
nome=bancada.nome
)
else:
bancada.save()
return bancada


Expand Down
6 changes: 6 additions & 0 deletions sapl/sessao/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,12 @@ class CreateView(CrudAux.CreateView):
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:
Expand Down

0 comments on commit daae247

Please sign in to comment.