From fa0d527709a6eb5f00dc1cd8bed2ab5b7c3a6f61 Mon Sep 17 00:00:00 2001 From: Edward Ribeiro Date: Fri, 11 Sep 2015 19:15:43 -0300 Subject: [PATCH 1/4] Switch to use kwargs --- sessao/views.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sessao/views.py b/sessao/views.py index 025f3687f..9e11e17aa 100644 --- a/sessao/views.py +++ b/sessao/views.py @@ -231,14 +231,12 @@ class OradorExpedienteDelete(FormMixin, sessao_crud.CrudDetailView): def post(self, request, *args, **kwargs): self.object = self.get_object() - current_url = request.get_full_path() - words = current_url.split('/') form = OradorDeleteForm(request.POST) if form.is_valid(): orador = OradorExpediente.objects.get( sessao_plenaria_id=self.object.id, - parlamentar_id=words[-1]) + parlamentar_id=kwargs['oid']) orador.delete() return self.form_valid(form) else: From 283465594f82d7d9f64cda75c784bb8e17025356 Mon Sep 17 00:00:00 2001 From: Edward Ribeiro Date: Fri, 11 Sep 2015 19:35:44 -0300 Subject: [PATCH 2/4] Fix jquery-runner url --- templates/base.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/base.html b/templates/base.html index 6c1742631..f2a6d2989 100644 --- a/templates/base.html +++ b/templates/base.html @@ -27,7 +27,7 @@ - + {% endblock %} From f8a2fd7cf2e4f772b5d6a319e06fda8cb6f002bd Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Thu, 3 Sep 2015 15:08:36 -0300 Subject: [PATCH 3/4] Arquivos ordem dia temporarios --- sessao/urls.py | 1 + templates/sessao/OrdemDia.html | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 templates/sessao/OrdemDia.html diff --git a/sessao/urls.py b/sessao/urls.py index ce5f391c4..921c7c40e 100644 --- a/sessao/urls.py +++ b/sessao/urls.py @@ -1,4 +1,5 @@ from django.conf.urls import include, url + from sessao.views import (ExpedienteView, OradorExpedienteDelete, OradorExpedienteView, PainelView, PresencaOrdemDiaView, PresencaView, sessao_crud, diff --git a/templates/sessao/OrdemDia.html b/templates/sessao/OrdemDia.html new file mode 100644 index 000000000..5b2fcb4e5 --- /dev/null +++ b/templates/sessao/OrdemDia.html @@ -0,0 +1,12 @@ +{% extends "sessao/sessaoplenaria_detail.html" %} +{% load i18n %} +{% load crispy_forms_tags %} + +{% block detail_content %} +
+ {% csrf_token %} + {{formset}} +
+ +
+{% endblock detail_content %} \ No newline at end of file From b2a675e2a94a1bdf6733e89188e8ed54ec848969 Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Mon, 14 Sep 2015 11:35:02 -0300 Subject: [PATCH 4/4] Add edit form for Orador --- sessao/urls.py | 10 +++-- sessao/views.py | 57 ++++++++++++++++++++++++-- templates/sessao/edit_orador.html | 26 ++++++++++++ templates/sessao/oradorExpediente.html | 18 ++++---- 4 files changed, 93 insertions(+), 18 deletions(-) create mode 100644 templates/sessao/edit_orador.html diff --git a/sessao/urls.py b/sessao/urls.py index 921c7c40e..531571a86 100644 --- a/sessao/urls.py +++ b/sessao/urls.py @@ -1,10 +1,10 @@ from django.conf.urls import include, url from sessao.views import (ExpedienteView, OradorExpedienteDelete, - OradorExpedienteView, PainelView, - PresencaOrdemDiaView, PresencaView, sessao_crud, - tipo_expediente_crud, tipo_resultado_votacao_crud, - tipo_sessao_crud) + OradorExpedienteEdit, OradorExpedienteView, + PainelView, PresencaOrdemDiaView, PresencaView, + sessao_crud, tipo_expediente_crud, + tipo_resultado_votacao_crud, tipo_sessao_crud) urlpatterns_sessao = sessao_crud.urlpatterns + [ url(r'^(?P\d+)/expediente$', @@ -20,6 +20,8 @@ urlpatterns_sessao = sessao_crud.urlpatterns + [ OradorExpedienteView.as_view(), name='oradorexpediente'), url(r'^(?P\d+)/oradorexpediente/excluir/(?P\d+)$', OradorExpedienteDelete.as_view(), name='oradorexcluir'), + url(r'^(?P\d+)/oradorexpediente/editar/(?P\d+)$', + OradorExpedienteEdit.as_view(), name='oradoreditar'), ] sessao_urls = urlpatterns_sessao, sessao_crud.namespace, sessao_crud.namespace diff --git a/sessao/views.py b/sessao/views.py index 9e11e17aa..6496a20cf 100644 --- a/sessao/views.py +++ b/sessao/views.py @@ -217,7 +217,7 @@ class PresencaOrdemDiaView(FormMixin, sessao_crud.CrudDetailView): class OradorForm(forms.Form): numero_ordem = forms.IntegerField(required=True) - parlamentar = forms.CharField(required=True, max_length=20) + parlamentar = forms.CharField(required=False, max_length=20) url_discurso = forms.CharField(required=False, max_length=100) @@ -231,12 +231,14 @@ class OradorExpedienteDelete(FormMixin, sessao_crud.CrudDetailView): def post(self, request, *args, **kwargs): self.object = self.get_object() + current_url = request.get_full_path() + words = current_url.split('/') form = OradorDeleteForm(request.POST) if form.is_valid(): orador = OradorExpediente.objects.get( sessao_plenaria_id=self.object.id, - parlamentar_id=kwargs['oid']) + parlamentar_id=words[-1]) orador.delete() return self.form_valid(form) else: @@ -246,6 +248,56 @@ class OradorExpedienteDelete(FormMixin, sessao_crud.CrudDetailView): return self.detail_url +class OradorExpedienteEdit(FormMixin, sessao_crud.CrudDetailView): + template_name = 'sessao/edit_orador.html' + form_class = OradorForm + + def get_success_url(self): + return self.detail_url + + def post(self, request, *args, **kwargs): + self.object = self.get_object() + form = OradorForm(request.POST) + + if form.is_valid(): + current_url = request.get_full_path() + words = current_url.split('/') + + orador = OradorExpediente.objects.get( + sessao_plenaria_id=self.object.id, + parlamentar_id=words[-1]) + orador.delete() + + orador = OradorExpediente() + orador.sessao_plenaria_id = self.object.id + orador.numero_ordem = request.POST['numero_ordem'] + orador.parlamentar = Parlamentar.objects.get( + id=words[-1]) + orador.url_discurso = request.POST['url_discurso'] + orador.save() + + return self.form_valid(form) + else: + return self.form_invalid(form) + + def get(self, request, *args, **kwargs): + self.object = self.get_object() + context = self.get_context_data(object=self.object) + + current_url = self.request.get_full_path() + words = current_url.split('/') + + parlamentar = Parlamentar.objects.get(id=words[-1]) + orador = OradorExpediente.objects.get( + sessao_plenaria=self.object, parlamentar=parlamentar) + + orador = {'parlamentar': parlamentar, 'numero_ordem': + orador.numero_ordem, 'url_discurso': orador.url_discurso} + context.update({'orador': orador}) + + return self.render_to_response(context) + + class OradorExpedienteView(FormMixin, sessao_crud.CrudDetailView): template_name = 'sessao/oradorExpediente.html' form_class = OradorForm @@ -287,7 +339,6 @@ class OradorExpedienteView(FormMixin, sessao_crud.CrudDetailView): def post(self, request, *args, **kwargs): self.object = self.get_object() - print(request.POST['numero_ordem'], request.POST['parlamentar']) form = OradorForm(request.POST) if form.is_valid(): diff --git a/templates/sessao/edit_orador.html b/templates/sessao/edit_orador.html new file mode 100644 index 000000000..b2b42ae83 --- /dev/null +++ b/templates/sessao/edit_orador.html @@ -0,0 +1,26 @@ +{% extends "sessao/sessaoplenaria_detail.html" %} +{% load i18n %} +{% load crispy_forms_tags %} + +{% block detail_content %} + +
+ Editar Orador +
+ {% csrf_token %} + +
    +
  • Ordem de pronunciamento
  • +
  • Parlamentar
  • +
  • URL Discurso
  • +
+
    +
  • +
  • +
  • +
+ +
+
+ +{% endblock detail_content %} diff --git a/templates/sessao/oradorExpediente.html b/templates/sessao/oradorExpediente.html index b206847dc..e604809f9 100644 --- a/templates/sessao/oradorExpediente.html +++ b/templates/sessao/oradorExpediente.html @@ -10,28 +10,24 @@
  • Ordem de pronunciamento
  • Parlamentar
  • URL Discurso
  • -
  • Excluir
  • +
  • Editar/Excluir
  • - -
    - {% csrf_token %} {% for numero_ordem, url_discurso, parlamentar in view.get_oradores %}
      -
    • +
    • {{numero_ordem}}
    • {{parlamentar.nome_parlamentar }}
    • {% if not url_discurso %}Orador sem discurso cadastrado{% else %}{{url_discurso}}{% endif %}
    • -
    • Excluir
    • +
    • + Editar + / Excluir +
    {% endfor %} - -
    - -
    Adicionar Orador -
    + {% csrf_token %}