Browse Source

Hack a way of delete orador expediente

pull/7/head
Edward Ribeiro 9 years ago
parent
commit
8f2ae0701b
  1. 1
      painel/models.py
  2. 1
      painel/views.py
  3. 10
      sessao/urls.py
  4. 32
      sessao/views.py
  5. 10
      templates/sessao/oradorExpediente.html

1
painel/models.py

@ -33,7 +33,6 @@ class Cronometro(models.Model):
verbose_name='Status do cronômetro', verbose_name='Status do cronômetro',
choices=CRONOMETRO_STATUS, choices=CRONOMETRO_STATUS,
default='S') default='S')
#time = models.FloatField(verbose_name='Start time', default=0)
data_cronometro = models.DateField(verbose_name='Data do cronômetro') data_cronometro = models.DateField(verbose_name='Data do cronômetro')
tipo = models.CharField( tipo = models.CharField(
max_length=1, choices=CRONOMETRO_TYPES, verbose_name='Tipo Cronômetro') max_length=1, choices=CRONOMETRO_TYPES, verbose_name='Tipo Cronômetro')

1
painel/views.py

@ -4,6 +4,7 @@ from django.core import serializers
from django.http import HttpResponse, JsonResponse from django.http import HttpResponse, JsonResponse
from django.shortcuts import render from django.shortcuts import render
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from painel.models import Painel from painel.models import Painel
from parlamentares.models import Filiacao from parlamentares.models import Filiacao
from sapl.crud import build_crud from sapl.crud import build_crud

10
sessao/urls.py

@ -1,8 +1,9 @@
from django.conf.urls import include, url from django.conf.urls import include, url
from sessao.views import (ExpedienteView, OradorExpedienteView, PainelView, from sessao.views import (ExpedienteView, OradorExpedienteView, PainelView,
PresencaOrdemDiaView, PresencaView, sessao_crud, PresencaOrdemDiaView, PresencaView, orador_delete,
tipo_expediente_crud, tipo_resultado_votacao_crud, sessao_crud, tipo_expediente_crud,
tipo_sessao_crud) tipo_resultado_votacao_crud, tipo_sessao_crud)
urlpatterns_sessao = sessao_crud.urlpatterns + [ urlpatterns_sessao = sessao_crud.urlpatterns + [
url(r'^(?P<pk>\d+)/expediente$', url(r'^(?P<pk>\d+)/expediente$',
@ -16,6 +17,9 @@ urlpatterns_sessao = sessao_crud.urlpatterns + [
name='presencaordemdia'), name='presencaordemdia'),
url(r'^(?P<pk>\d+)/oradorexpediente$', url(r'^(?P<pk>\d+)/oradorexpediente$',
OradorExpedienteView.as_view(), name='oradorexpediente'), OradorExpedienteView.as_view(), name='oradorexpediente'),
url(r'^(?P<pk>\d+)/oradorexpediente/excluir/(?P<oid>\d+)$',
orador_delete, name='oradorexcluir'),
] ]
sessao_urls = urlpatterns_sessao, sessao_crud.namespace, sessao_crud.namespace sessao_urls = urlpatterns_sessao, sessao_crud.namespace, sessao_crud.namespace

32
sessao/views.py

@ -1,9 +1,14 @@
from django import forms from django import forms
from django.core.urlresolvers import reverse_lazy
from django.shortcuts import redirect
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.views.generic.detail import DetailView
from django.views.generic.edit import FormMixin from django.views.generic.edit import FormMixin
from extra_views import InlineFormSetView from extra_views import InlineFormSetView
from parlamentares.models import Parlamentar from parlamentares.models import Parlamentar
from sapl.crud import build_crud from sapl.crud import build_crud
from .models import (ExpedienteMateria, ExpedienteSessao, OradorExpediente, from .models import (ExpedienteMateria, ExpedienteSessao, OradorExpediente,
OrdemDia, PresencaOrdemDia, RegistroVotacao, OrdemDia, PresencaOrdemDia, RegistroVotacao,
SessaoPlenaria, SessaoPlenariaPresenca, TipoExpediente, SessaoPlenaria, SessaoPlenariaPresenca, TipoExpediente,
@ -219,12 +224,35 @@ class OradorForm(forms.Form):
url_discurso = forms.CharField(required=False, max_length=100) url_discurso = forms.CharField(required=False, max_length=100)
def orador_delete(request, pk, oid):
orador = OradorExpediente.objects.get(
sessao_plenaria_id=pk, parlamentar_id=oid)
orador.delete()
# return HttpResponseRedirect(
# reverse_lazy('oradorexpediente', kwargs={'pk': int(pk)}))
# return redirect(request, reverse('sessao:oradorexpediente',
# kwargs={'pk': pk}), context)
return redirect('/sessao/' + pk + '/oradorexpediente')
class OradorExpedienteDelete(DetailView):
model = OradorExpediente
success_url = reverse_lazy('sessao:oradorexpediente')
def get(self, request, *args, **kwargs):
self.object = self.get_object()
context = self.get_context_data(object=self.object)
return self.render_to_response(context)
class OradorExpedienteView(FormMixin, sessao_crud.CrudDetailView): class OradorExpedienteView(FormMixin, sessao_crud.CrudDetailView):
template_name = 'sessao/oradorExpediente.html' template_name = 'sessao/oradorExpediente.html'
form_class = OradorForm form_class = OradorForm
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
print(request.GET)
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)
return self.render_to_response(context) return self.render_to_response(context)
@ -257,7 +285,7 @@ class OradorExpedienteView(FormMixin, sessao_crud.CrudDetailView):
url_discurso = orador.url_discurso url_discurso = orador.url_discurso
parlamentar = Parlamentar.objects.get( parlamentar = Parlamentar.objects.get(
id=orador.parlamentar_id) id=orador.parlamentar_id)
yield(numero_ordem, url_discurso, parlamentar.nome_parlamentar) yield(numero_ordem, url_discurso, parlamentar)
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
self.object = self.get_object() self.object = self.get_object()

10
templates/sessao/oradorExpediente.html

@ -16,12 +16,12 @@
<form method="post" action="./oradorexpediente"> <form method="post" action="./oradorexpediente">
{% csrf_token %} {% csrf_token %}
{% for numero_ordem, url_discuro, parlamentar in view.get_oradores %} {% for numero_ordem, url_discurso, parlamentar in view.get_oradores %}
<ul class="small-block-grid-4 medium-block-grid-4 large-block-grid-4"> <ul class="small-block-grid-4 medium-block-grid-4 large-block-grid-4">
<li>{{numero_ordem}}</li> <li>{{numero_ordem}}</li>
<li>{{parlamentar}}</li> <li>{{parlamentar.nome_parlamentar }}</li>
<li>{% if url_discurso == null %}Orador sem discurso cadastrado{% else %}{{url_discurso}}{% endif %}</li> <li>{% if not url_discurso %}Orador sem discurso cadastrado{% else %}{{url_discurso}}{% endif %}</li>
<li><a href="{% url 'sessaoplenaria:oradorexpediente' object.pk %}">Excluir</a></li> <li><a id="excluir-orador" href="{% url 'sessaoplenaria:oradorexcluir' object.pk parlamentar.id %}">Excluir</a></li>
</ul> </ul>
{% endfor %} {% endfor %}
@ -52,4 +52,4 @@
<input type="submit" value="Adicionar Orador" /> <input type="submit" value="Adicionar Orador" />
</form> </form>
{% endblock detail_content %} {% endblock detail_content %}

Loading…
Cancel
Save