Browse Source

Merge branch 'master' into compilacao

pull/6/head
LeandroRoberto 9 years ago
parent
commit
95ca116a20
  1. 11
      sessao/urls.py
  2. 53
      sessao/views.py
  3. 2
      templates/base.html
  4. 12
      templates/sessao/OrdemDia.html
  5. 26
      templates/sessao/edit_orador.html
  6. 18
      templates/sessao/oradorExpediente.html

11
sessao/urls.py

@ -1,9 +1,10 @@
from django.conf.urls import include, url from django.conf.urls import include, url
from sessao.views import (ExpedienteView, OradorExpedienteDelete, from sessao.views import (ExpedienteView, OradorExpedienteDelete,
OradorExpedienteView, PainelView, OradorExpedienteEdit, OradorExpedienteView,
PresencaOrdemDiaView, PresencaView, sessao_crud, PainelView, PresencaOrdemDiaView, PresencaView,
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$',
@ -19,6 +20,8 @@ urlpatterns_sessao = sessao_crud.urlpatterns + [
OradorExpedienteView.as_view(), name='oradorexpediente'), OradorExpedienteView.as_view(), name='oradorexpediente'),
url(r'^(?P<pk>\d+)/oradorexpediente/excluir/(?P<oid>\d+)$', url(r'^(?P<pk>\d+)/oradorexpediente/excluir/(?P<oid>\d+)$',
OradorExpedienteDelete.as_view(), name='oradorexcluir'), OradorExpedienteDelete.as_view(), name='oradorexcluir'),
url(r'^(?P<pk>\d+)/oradorexpediente/editar/(?P<oid>\d+)$',
OradorExpedienteEdit.as_view(), name='oradoreditar'),
] ]
sessao_urls = urlpatterns_sessao, sessao_crud.namespace, sessao_crud.namespace sessao_urls = urlpatterns_sessao, sessao_crud.namespace, sessao_crud.namespace

53
sessao/views.py

@ -217,7 +217,7 @@ class PresencaOrdemDiaView(FormMixin, sessao_crud.CrudDetailView):
class OradorForm(forms.Form): class OradorForm(forms.Form):
numero_ordem = forms.IntegerField(required=True) 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) url_discurso = forms.CharField(required=False, max_length=100)
@ -248,6 +248,56 @@ class OradorExpedienteDelete(FormMixin, sessao_crud.CrudDetailView):
return self.detail_url 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): class OradorExpedienteView(FormMixin, sessao_crud.CrudDetailView):
template_name = 'sessao/oradorExpediente.html' template_name = 'sessao/oradorExpediente.html'
form_class = OradorForm form_class = OradorForm
@ -289,7 +339,6 @@ class OradorExpedienteView(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()
print(request.POST['numero_ordem'], request.POST['parlamentar'])
form = OradorForm(request.POST) form = OradorForm(request.POST)
if form.is_valid(): if form.is_valid():

2
templates/base.html

@ -28,7 +28,7 @@
<script type="text/javascript" src="{% static 'foundation/js/vendor/jquery.js' %}"></script> <script type="text/javascript" src="{% static 'foundation/js/vendor/jquery.js' %}"></script>
<script type="text/javascript" src="{% static 'foundation-datepicker/js/foundation-datepicker.js' %}"></script> <script type="text/javascript" src="{% static 'foundation-datepicker/js/foundation-datepicker.js' %}"></script>
<script type="text/javascript" src="{% static 'jQuery-runner/build/jquery.runner.js' %}"></script> <script type="text/javascript" src="{% static 'jquery-runner/build/jquery.runner.js' %}"></script>
{% endblock %} {% endblock %}
</head> </head>

12
templates/sessao/OrdemDia.html

@ -0,0 +1,12 @@
{% extends "sessao/sessaoplenaria_detail.html" %}
{% load i18n %}
{% load crispy_forms_tags %}
{% block detail_content %}
<form method="post">
{% csrf_token %}
{{formset}}
<br />
<input type="submit" value="Submit" />
</form>
{% endblock detail_content %}

26
templates/sessao/edit_orador.html

@ -0,0 +1,26 @@
{% extends "sessao/sessaoplenaria_detail.html" %}
{% load i18n %}
{% load crispy_forms_tags %}
{% block detail_content %}
<fieldset>
<legend>Editar Orador</legend>
<form method="POST" action="">
{% csrf_token %}
<ul class="small-block-grid-3 medium-block-grid-3 large-block-grid-3">
<li>Ordem de pronunciamento</li>
<li>Parlamentar</li>
<li>URL Discurso</li>
</ul>
<ul class="small-block-grid-3 medium-block-grid-3 large-block-grid-3">
<li><input type="text" id="numero_ordem" name="numero_ordem" value="{{orador.numero_ordem}}" /></li>
<li><input type="text" id="parlamentar" name="parlamentar" value="{{orador.parlamentar.nome_parlamentar}}" disabled /></li>
<li><input type="text" id="url_discurso" name="url_discurso" value="{{orador.url_discurso}}"/></li>
</ul>
<input type="submit" value="Salvar Orador" />
</form>
</fieldset>
{% endblock detail_content %}

18
templates/sessao/oradorExpediente.html

@ -10,28 +10,24 @@
<li>Ordem de pronunciamento</li> <li>Ordem de pronunciamento</li>
<li>Parlamentar</li> <li>Parlamentar</li>
<li>URL Discurso</li> <li>URL Discurso</li>
<li>Excluir</li> <li>Editar/Excluir</li>
</ul> </ul>
<form method="post" action="./oradorexpediente">
{% csrf_token %}
{% for numero_ordem, url_discurso, 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><input size="2" type="text" id="numero_ordem" name="numero_ordem" value="{{numero_ordem}}" /></li> <li>{{numero_ordem}}</li>
<li>{{parlamentar.nome_parlamentar }}</li> <li>{{parlamentar.nome_parlamentar }}</li>
<li>{% if not url_discurso %}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 id="excluir-orador" href="{% url 'sessaoplenaria:oradorexcluir' object.pk parlamentar.id %}">Excluir</a></li> <li>
<a id="editar-orador" href="{% url 'sessaoplenaria:oradoreditar' object.pk parlamentar.id %}">Editar</a>
/ <a id="excluir-orador" href="{% url 'sessaoplenaria:oradorexcluir' object.pk parlamentar.id %}">Excluir</a>
</li>
</ul> </ul>
{% endfor %} {% endfor %}
<br />
<input type="submit" value="Atualizar" />
</form>
</fieldset> </fieldset>
<fieldset> <fieldset>
<legend>Adicionar Orador</legend> <legend>Adicionar Orador</legend>
<form method="POST" action="{% url 'sessaoplenaria:oradorexpediente' object.pk %}"> <form method="POST" action="">
{% csrf_token %} {% csrf_token %}
<ul class="small-block-grid-3 medium-block-grid-3 large-block-grid-3"> <ul class="small-block-grid-3 medium-block-grid-3 large-block-grid-3">

Loading…
Cancel
Save