Browse Source

Replace use of url.split('/') by kwargs

pull/98/head
Edward Ribeiro 9 years ago
parent
commit
f88ecba77d
  1. 29
      sessao/views.py

29
sessao/views.py

@ -1333,14 +1333,13 @@ class ExplicacaoDelete(FormMixin, sessao_crud.CrudDetailView):
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
self.object = self.get_object() self.object = self.get_object()
current_url = request.get_full_path() oid = kwargs['oid']
words = current_url.split('/')
form = OradorDeleteForm(request.POST) form = OradorDeleteForm(request.POST)
if form.is_valid(): if form.is_valid():
orador = Orador.objects.get( orador = Orador.objects.get(
sessao_plenaria_id=self.object.id, sessao_plenaria_id=self.object.id,
parlamentar_id=words[-1]) parlamentar_id=oid)
orador.delete() orador.delete()
return self.form_valid(form) return self.form_valid(form)
else: else:
@ -1359,20 +1358,20 @@ class ExplicacaoEdit(FormMixin, sessao_crud.CrudDetailView):
self.object = self.get_object() self.object = self.get_object()
form = OradorForm(request.POST) form = OradorForm(request.POST)
if form.is_valid(): pk = kwargs['pk']
current_url = request.get_full_path() oid = kwargs['oid']
words = current_url.split('/')
if form.is_valid():
orador = Orador.objects.get( orador = Orador.objects.get(
sessao_plenaria_id=self.object.id, sessao_plenaria_id=pk,
parlamentar_id=words[-1]) parlamentar_id=oid)
orador.delete() orador.delete()
orador = Orador() orador = Orador()
orador.sessao_plenaria_id = self.object.id orador.sessao_plenaria_id = pk
orador.numero_ordem = request.POST['numero_ordem'] orador.numero_ordem = request.POST['numero_ordem']
orador.parlamentar = Parlamentar.objects.get( orador.parlamentar = Parlamentar.objects.get(
id=words[-1]) id=oid)
orador.url_discurso = request.POST['url_discurso'] orador.url_discurso = request.POST['url_discurso']
orador.save() orador.save()
@ -1380,10 +1379,7 @@ class ExplicacaoEdit(FormMixin, sessao_crud.CrudDetailView):
else: else:
context = self.get_context_data(object=self.object) context = self.get_context_data(object=self.object)
current_url = self.request.get_full_path() parlamentar = Parlamentar.objects.get(id=oid)
words = current_url.split('/')
parlamentar = Parlamentar.objects.get(id=words[-1])
orador = Orador.objects.get( orador = Orador.objects.get(
sessao_plenaria=self.object, parlamentar=parlamentar) sessao_plenaria=self.object, parlamentar=parlamentar)
@ -1397,10 +1393,9 @@ class ExplicacaoEdit(FormMixin, sessao_crud.CrudDetailView):
self.object = self.get_object() self.object = self.get_object()
context = self.get_context_data(object=self.object) context = self.get_context_data(object=self.object)
current_url = self.request.get_full_path() oid = kwargs['oid']
words = current_url.split('/')
parlamentar = Parlamentar.objects.get(id=words[-1]) parlamentar = Parlamentar.objects.get(id=oid)
orador = Orador.objects.get( orador = Orador.objects.get(
sessao_plenaria=self.object, parlamentar=parlamentar) sessao_plenaria=self.object, parlamentar=parlamentar)

Loading…
Cancel
Save