Browse Source

Merge pull request #308 from interlegis/307-Crud-sessao

fix #307 crud sessao
pull/195/head
Edward 9 years ago
parent
commit
28e192f4ec
  1. 73
      sessao/forms.py
  2. 60
      sessao/urls.py
  3. 36
      sessao/views.py
  4. 2
      templates/base.html
  5. 2
      templates/sessao/OrdemDia.html
  6. 2
      templates/sessao/edit_explicacao.html
  7. 2
      templates/sessao/edit_orador.html
  8. 2
      templates/sessao/expediente.html
  9. 2
      templates/sessao/expediente_ordemdia_list.html
  10. 2
      templates/sessao/explicacao.html
  11. 2
      templates/sessao/materia_ordemdia.html
  12. 2
      templates/sessao/materia_ordemdia_edit.html
  13. 2
      templates/sessao/materia_ordemdia_list.html
  14. 2
      templates/sessao/mesa.html
  15. 2
      templates/sessao/orador_expediente.html
  16. 8
      templates/sessao/painel.html
  17. 2
      templates/sessao/presenca.html
  18. 2
      templates/sessao/presenca_ordemdia.html
  19. 2
      templates/sessao/resumo.html
  20. 8
      templates/sessao/sessao_cadastro.html
  21. 26
      templates/sessao/sessao_list.html
  22. 2
      templates/sessao/sessaoplenaria_detail.html
  23. 2
      templates/sessao/votacao/nominal.html
  24. 2
      templates/sessao/votacao/nominal_edit.html
  25. 2
      templates/sessao/votacao/votacao.html
  26. 2
      templates/sessao/votacao/votacao_edit.html

73
sessao/forms.py

@ -1,14 +1,6 @@
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Fieldset, Layout
from django import forms from django import forms
from django.forms import ModelForm
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
import crispy_layout_mixin
from crispy_layout_mixin import form_actions
from .models import SessaoPlenaria
class PresencaForm(forms.Form): class PresencaForm(forms.Form):
presenca = forms.CharField(required=False, initial=False) presenca = forms.CharField(required=False, initial=False)
@ -66,68 +58,3 @@ class VotacaoForm(forms.Form):
class VotacaoEditForm(forms.Form): class VotacaoEditForm(forms.Form):
pass pass
class SessaoForm(ModelForm):
class Meta:
model = SessaoPlenaria
fields = ['numero',
'tipo',
'legislatura',
'sessao_legislativa',
'data_inicio',
'hora_inicio',
'iniciada',
'data_fim',
'hora_fim',
'finalizada',
'upload_pauta',
'upload_ata',
'url_audio',
'url_video']
widgets = {
'hora_inicio': forms.TextInput(attrs={'class': 'hora'}),
'hora_fim': forms.TextInput(attrs={'class': 'hora'}),
}
def __init__(self, *args, **kwargs):
row1 = crispy_layout_mixin.to_row(
[('numero', 3),
('tipo', 3),
('legislatura', 3),
('sessao_legislativa', 3)])
row2 = crispy_layout_mixin.to_row(
[('data_inicio', 4),
('hora_inicio', 4),
('iniciada', 4)])
row3 = crispy_layout_mixin.to_row(
[('data_fim', 4),
('hora_fim', 4),
('finalizada', 4)])
row4 = crispy_layout_mixin.to_row(
[('upload_pauta', 6),
('upload_ata', 6)])
row5 = crispy_layout_mixin.to_row(
[('url_audio', 6),
('url_video', 6)])
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset(
_('Dados Básicos'),
row1,
row2,
row3,
row4,
row5,
form_actions()
)
)
super(SessaoForm, self).__init__(*args, **kwargs)

60
sessao/urls.py

@ -12,8 +12,7 @@ from sessao.views import (EditExpedienteOrdemDiaView, EditMateriaOrdemDiaView,
PautaExpedienteDetail, PautaOrdemDetail, PautaExpedienteDetail, PautaOrdemDetail,
PautaSessaoDetailView, PautaSessaoListView, PautaSessaoDetailView, PautaSessaoListView,
PresencaOrdemDiaView, PresencaView, ResumoView, PresencaOrdemDiaView, PresencaView, ResumoView,
SessaoCadastroView, SessaoCrud, SessaoListView, SessaoCrud, SessaoPlenariaView, TipoExpedienteCrud,
SessaoPlenariaView, TipoExpedienteCrud,
TipoResultadoVotacaoCrud, TipoSessaoCrud, TipoResultadoVotacaoCrud, TipoSessaoCrud,
VotacaoEditView, VotacaoExpedienteEditView, VotacaoEditView, VotacaoExpedienteEditView,
VotacaoExpedienteView, VotacaoNominalEditView, VotacaoExpedienteView, VotacaoNominalEditView,
@ -25,7 +24,34 @@ from .apps import AppConfig
app_name = AppConfig.name app_name = AppConfig.name
urlpatterns_sessao = SessaoCrud.get_urls() + [ sessao_rest = [
url(r'^sessao$', SessaoPlenariaView.as_view(), name='sessao_rest')
]
urlpatterns = [
url(r'^sessao/', include(SessaoCrud.get_urls())),
url(r'^media/(?P<path>.*)$', serve,
{'document_root': settings.MEDIA_ROOT}),
url(r'^rest/', include(sessao_rest)),
url(r'^sistema/sessao-plenaria/tipo/',
include(TipoSessaoCrud.get_urls())),
url(r'^sistema/sessao-plenaria/tipo-resultado-votacao/',
include(TipoResultadoVotacaoCrud.get_urls())),
url(r'^sistema/sessao-plenaria/tipo-expediente/',
include(TipoExpedienteCrud.get_urls())),
# PAUTA SESSÃO
url(r'^pauta-sessao$',
PautaSessaoListView.as_view(), name='list_pauta_sessao'),
url(r'^pauta-sessao/(?P<pk>\d+)$',
PautaSessaoDetailView.as_view(), name='pauta_sessao_detail'),
url(r'^pauta-sessao/(?P<pk>\d+)/expediente/$',
PautaExpedienteDetail.as_view(), name='pauta_expediente_detail'),
url(r'^pauta-sessao/(?P<pk>\d+)/ordem/$',
PautaOrdemDetail.as_view(), name='pauta_ordem_detail'),
# Subnav sessão
url(r'^(?P<pk>\d+)/expediente$', url(r'^(?P<pk>\d+)/expediente$',
ExpedienteView.as_view(), name='expediente'), ExpedienteView.as_view(), name='expediente'),
url(r'^(?P<pk>\d+)/presenca$', url(r'^(?P<pk>\d+)/presenca$',
@ -89,32 +115,4 @@ urlpatterns_sessao = SessaoCrud.get_urls() + [
VotacaoExpedienteView.as_view(), name='votacaosecretaexp'), VotacaoExpedienteView.as_view(), name='votacaosecretaexp'),
url(r'^(?P<pk>\d+)/matexp/votsec/view/(?P<oid>\d+)/(?P<mid>\d+)$', url(r'^(?P<pk>\d+)/matexp/votsec/view/(?P<oid>\d+)/(?P<mid>\d+)$',
VotacaoExpedienteEditView.as_view(), name='votacaosecretaexpedit'), VotacaoExpedienteEditView.as_view(), name='votacaosecretaexpedit'),
url(r'^sessao-list$',
SessaoListView.as_view(), name='list_sessao'),
url(r'^pauta-sessao-list$',
PautaSessaoListView.as_view(), name='list_pauta_sessao'),
url(r'^(?P<pk>\d+)/pauta-sessao-detail$',
PautaSessaoDetailView.as_view(), name='pauta_sessao_detail'),
url(r'^cadastro$', SessaoCadastroView.as_view(), name='sessao_cadastro'),
url(r'^pauta-sessao/(?P<pk>\d+)/expediente/$',
PautaExpedienteDetail.as_view(), name='pauta_expediente_detail'),
url(r'^pauta-sessao/(?P<pk>\d+)/ordem/$',
PautaOrdemDetail.as_view(), name='pauta_ordem_detail'),
]
sessao_rest = [
url(r'^sessao$', SessaoPlenariaView.as_view(), name='sessao_rest')
]
urlpatterns = [
url(r'^sessao/', include(urlpatterns_sessao)),
url(r'^media/(?P<path>.*)$', serve,
{'document_root': settings.MEDIA_ROOT}),
url(r'^rest/', include(sessao_rest)),
url(r'^sistema/sessao-plenaria/tipo/',
include(TipoSessaoCrud.get_urls())),
url(r'^sistema/sessao-plenaria/tipo-resultado-votacao/',
include(TipoResultadoVotacaoCrud.get_urls())),
url(r'^sistema/sessao-plenaria/tipo-expediente/',
include(TipoExpedienteCrud.get_urls()))
] ]

36
sessao/views.py

@ -7,10 +7,11 @@ from django.core.urlresolvers import reverse, reverse_lazy
from django.forms.utils import ErrorList from django.forms.utils import ErrorList
from django.utils.html import strip_tags from django.utils.html import strip_tags
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.views.generic import CreateView, ListView from django.views.generic import ListView, TemplateView
from django.views.generic.edit import FormMixin from django.views.generic.edit import FormMixin
from rest_framework import generics from rest_framework import generics
import crud.base
from crud.base import Crud, make_pagination from crud.base import Crud, make_pagination
from materia.models import (Autoria, DocumentoAcessorio, from materia.models import (Autoria, DocumentoAcessorio,
TipoMateriaLegislativa, Tramitacao) TipoMateriaLegislativa, Tramitacao)
@ -20,8 +21,7 @@ from sessao.serializers import SessaoPlenariaSerializer
from .forms import (ExpedienteForm, ListMateriaForm, MateriaOrdemDiaForm, from .forms import (ExpedienteForm, ListMateriaForm, MateriaOrdemDiaForm,
MesaForm, OradorDeleteForm, OradorForm, PresencaForm, MesaForm, OradorDeleteForm, OradorForm, PresencaForm,
SessaoForm, VotacaoEditForm, VotacaoForm, VotacaoEditForm, VotacaoForm, VotacaoNominalForm)
VotacaoNominalForm)
from .models import (CargoMesa, ExpedienteMateria, ExpedienteSessao, from .models import (CargoMesa, ExpedienteMateria, ExpedienteSessao,
IntegranteMesa, MateriaLegislativa, Orador, IntegranteMesa, MateriaLegislativa, Orador,
OradorExpediente, OrdemDia, PresencaOrdemDia, OradorExpediente, OrdemDia, PresencaOrdemDia,
@ -30,7 +30,6 @@ from .models import (CargoMesa, ExpedienteMateria, ExpedienteSessao,
VotoParlamentar) VotoParlamentar)
TipoSessaoCrud = Crud.build(TipoSessaoPlenaria, 'tipo_sessao_plenaria') TipoSessaoCrud = Crud.build(TipoSessaoPlenaria, 'tipo_sessao_plenaria')
SessaoCrud = Crud.build(SessaoPlenaria, '')
ExpedienteMateriaCrud = Crud.build(ExpedienteMateria, '') ExpedienteMateriaCrud = Crud.build(ExpedienteMateria, '')
OrdemDiaCrud = Crud.build(OrdemDia, '') OrdemDiaCrud = Crud.build(OrdemDia, '')
TipoResultadoVotacaoCrud = Crud.build( TipoResultadoVotacaoCrud = Crud.build(
@ -39,6 +38,24 @@ TipoExpedienteCrud = Crud.build(TipoExpediente, 'tipo_expediente')
RegistroVotacaoCrud = Crud.build(RegistroVotacao, '') RegistroVotacaoCrud = Crud.build(RegistroVotacao, '')
class SessaoCrud(Crud):
model = SessaoPlenaria
help_path = 'sessao_plenaria'
class BaseMixin(crud.base.BaseMixin):
list_field_names = ['numero', 'tipo', 'legislatura',
'sessao_legislativa', 'data_inicio', 'hora_inicio']
class CrudDetailView(crud.base.BaseMixin, crud.base.DetailView):
model = SessaoPlenaria
help_path = 'sessao_plenaria'
class CreateView(crud.base.CrudCreateView):
def get_success_url(self):
return reverse_lazy('sessao:sessaoplenaria_list')
class PresencaMixin: class PresencaMixin:
def get_parlamentares(self): def get_parlamentares(self):
@ -56,9 +73,10 @@ class PresencaMixin:
yield (parlamentar, False) yield (parlamentar, False)
class PresencaView(FormMixin, PresencaMixin, SessaoCrud.CrudDetailView): class PresencaView(FormMixin, PresencaMixin, SessaoCrud.DetailView):
template_name = 'sessao/presenca.html' template_name = 'sessao/presenca.html'
form_class = PresencaForm form_class = PresencaForm
model = SessaoPlenaria
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
self.object = self.get_object() self.object = self.get_object()
@ -96,7 +114,7 @@ class PresencaView(FormMixin, PresencaMixin, SessaoCrud.CrudDetailView):
return reverse('sessao:presenca', kwargs={'pk': pk}) return reverse('sessao:presenca', kwargs={'pk': pk})
class PainelView(SessaoCrud.CrudDetailView): class PainelView(TemplateView):
template_name = 'sessao/painel.html' template_name = 'sessao/painel.html'
@ -2238,12 +2256,6 @@ class PautaSessaoDetailView(SessaoCrud.CrudDetailView):
return self.render_to_response(context) return self.render_to_response(context)
class SessaoCadastroView(CreateView):
template_name = "sessao/sessao_cadastro.html"
form_class = SessaoForm
success_url = reverse_lazy('sessao:list_sessao')
class SessaoPlenariaView(generics.ListAPIView): class SessaoPlenariaView(generics.ListAPIView):
queryset = SessaoPlenaria.objects.all() queryset = SessaoPlenaria.objects.all()
serializer_class = SessaoPlenariaSerializer serializer_class = SessaoPlenariaSerializer

2
templates/base.html

@ -68,7 +68,7 @@
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li class="nav__sub-item"><a class="nav__sub-link" href="{% url 'materia:list_proposicao' %}">Proposições</a></li> <li class="nav__sub-item"><a class="nav__sub-link" href="{% url 'materia:list_proposicao' %}">Proposições</a></li>
<li class="nav__sub-item"><a class="nav__sub-link" href="{% url 'materia:materialegislativa_list' %}">Matérias Legislativas</a></li> <li class="nav__sub-item"><a class="nav__sub-link" href="{% url 'materia:materialegislativa_list' %}">Matérias Legislativas</a></li>
<li class="nav__sub-item"><a class="nav__sub-link" href="{% url 'sessao:list_sessao' %}">Sessões Plenárias</a></li> <li class="nav__sub-item"><a class="nav__sub-link" href="{% url 'sessao:sessaoplenaria_list' %}">Sessões Plenárias</a></li>
<li class="nav__sub-item"><a class="nav__sub-link" href="{% url 'sessao:list_pauta_sessao' %}">Pautas das Sessões</a></li> <li class="nav__sub-item"><a class="nav__sub-link" href="{% url 'sessao:list_pauta_sessao' %}">Pautas das Sessões</a></li>
<!-- <li class="nav__sub-item"><a class="nav__sub-link" href="#">Atas das Sessões</a></li> <!-- <li class="nav__sub-item"><a class="nav__sub-link" href="#">Atas das Sessões</a></li>
<li class="nav__sub-item"><a class="nav__sub-link" href="#">Reuniões das Comissões</a></li> <li class="nav__sub-item"><a class="nav__sub-link" href="#">Reuniões das Comissões</a></li>

2
templates/sessao/OrdemDia.html

@ -1,4 +1,4 @@
{% extends "sessao/sessaoplenaria_detail.html" %} {% extends "crud/detail.html" %}
{% load i18n %} {% load i18n %}
{% load crispy_forms_tags %} {% load crispy_forms_tags %}

2
templates/sessao/edit_explicacao.html

@ -1,4 +1,4 @@
{% extends "sessao/sessaoplenaria_detail.html" %} {% extends "crud/detail.html" %}
{% load i18n %} {% load i18n %}
{% load crispy_forms_tags %} {% load crispy_forms_tags %}

2
templates/sessao/edit_orador.html

@ -1,4 +1,4 @@
{% extends "sessao/sessaoplenaria_detail.html" %} {% extends "crud/detail.html" %}
{% load i18n %} {% load i18n %}
{% load crispy_forms_tags %} {% load crispy_forms_tags %}

2
templates/sessao/expediente.html

@ -1,4 +1,4 @@
{% extends "sessao/sessaoplenaria_detail.html" %} {% extends "crud/detail.html" %}
{% load i18n %} {% load i18n %}
{% load crispy_forms_tags %} {% load crispy_forms_tags %}

2
templates/sessao/expediente_ordemdia_list.html

@ -1,4 +1,4 @@
{% extends "sessao/sessaoplenaria_detail.html" %} {% extends "crud/detail.html" %}
{% load i18n %} {% load i18n %}
{% block detail_content %} {% block detail_content %}

2
templates/sessao/explicacao.html

@ -1,4 +1,4 @@
{% extends "sessao/sessaoplenaria_detail.html" %} {% extends "crud/detail.html" %}
{% load i18n %} {% load i18n %}
{% load crispy_forms_tags %} {% load crispy_forms_tags %}

2
templates/sessao/materia_ordemdia.html

@ -1,4 +1,4 @@
{% extends "sessao/sessaoplenaria_detail.html" %} {% extends "crud/detail.html" %}
{% load i18n %} {% load i18n %}
{% block detail_content %} {% block detail_content %}

2
templates/sessao/materia_ordemdia_edit.html

@ -1,4 +1,4 @@
{% extends "sessao/sessaoplenaria_detail.html" %} {% extends "crud/detail.html" %}
{% load i18n %} {% load i18n %}
{% load crispy_forms_tags %} {% load crispy_forms_tags %}
{% block detail_content %} {% block detail_content %}

2
templates/sessao/materia_ordemdia_list.html

@ -1,4 +1,4 @@
{% extends "sessao/sessaoplenaria_detail.html" %} {% extends "crud/detail.html" %}
{% load i18n %} {% load i18n %}
{% block detail_content %} {% block detail_content %}

2
templates/sessao/mesa.html

@ -1,4 +1,4 @@
{% extends "sessao/sessaoplenaria_detail.html" %} {% extends "crud/detail.html" %}
{% load i18n %} {% load i18n %}
{% block detail_content %} {% block detail_content %}

2
templates/sessao/orador_expediente.html

@ -1,4 +1,4 @@
{% extends "sessao/sessaoplenaria_detail.html" %} {% extends "crud/detail.html" %}
{% load i18n %} {% load i18n %}
{% load crispy_forms_tags %} {% load crispy_forms_tags %}

8
templates/sessao/painel.html

@ -1,13 +1,13 @@
{% extends "sessao/sessaoplenaria_detail.html" %} {% extends "crud/detail.html" %}
{% load i18n %} {% load i18n %}
{% load staticfiles %} {% load staticfiles %}
{% block actions %} {% endblock %}
{% block detail_content %} {% block detail_content %}
<audio type="hidden" id="audio" src="{% static 'audio/ring.mp3' %}"> </audio> <audio type="hidden" id="audio" src="{% static 'audio/ring.mp3' %}"> </audio>
<div class="row"> <div class="row">
<!--<div class="col-md-6"><a href="{% url 'painel:painel_principal' object.pk %}" class="btn btn-primary btn-sm active">Iniciar painel presidente</a></div> --> <!--<div class="col-md-6"><a href="{% url 'painel:painel_principal' pk %}" class="btn btn-primary btn-sm active">Iniciar painel presidente</a></div> -->
<div class="col-md-6"><a href="{% url 'painel:painel_principal' object.pk %}" class="btn btn-primary btn-sm active">Iniciar painel completo</a></div> <div class="col-md-6"><a href="{% url 'painel:painel_principal' pk %}" class="btn btn-primary btn-sm active">Iniciar painel completo</a></div>
<!--<div class="col-md-6"><a href="{% url 'painel:painel_mensagem' %}" class="btn btn-primary btn-sm active">Iniciar painel mensagem</a></div> <!--<div class="col-md-6"><a href="{% url 'painel:painel_mensagem' %}" class="btn btn-primary btn-sm active">Iniciar painel mensagem</a></div>
<div class="col-md-6"><a href="{% url 'painel:painel_parlamentares' %}" class="btn btn-primary btn-sm active">Iniciar painel parlamentares</a></div> <div class="col-md-6"><a href="{% url 'painel:painel_parlamentares' %}" class="btn btn-primary btn-sm active">Iniciar painel parlamentares</a></div>
<div class="col-md-6"><a href="{% url 'painel:painel_votacao' %}" class="btn btn-primary btn-sm active">Iniciar painel votação</a></div> --> <div class="col-md-6"><a href="{% url 'painel:painel_votacao' %}" class="btn btn-primary btn-sm active">Iniciar painel votação</a></div> -->

2
templates/sessao/presenca.html

@ -1,4 +1,4 @@
{% extends "sessao/sessaoplenaria_detail.html" %} {% extends "crud/detail.html" %}
{% load i18n %} {% load i18n %}
{% block detail_content %} {% block detail_content %}

2
templates/sessao/presenca_ordemdia.html

@ -1,4 +1,4 @@
{% extends "sessao/sessaoplenaria_detail.html" %} {% extends "crud/detail.html" %}
{% load i18n %} {% load i18n %}
{% block detail_content %} {% block detail_content %}

2
templates/sessao/resumo.html

@ -1,4 +1,4 @@
{% extends "sessao/sessaoplenaria_detail.html" %} {% extends "crud/detail.html" %}
{% load i18n %} {% load i18n %}
{% load crispy_forms_tags %} {% load crispy_forms_tags %}

8
templates/sessao/sessao_cadastro.html

@ -1,8 +0,0 @@
{% extends "crud/detail.html" %}
{% load i18n %}
{% load crispy_forms_tags %}
{% block actions %} {% endblock %}
{% block detail_content %}
{% crispy form %}
{% endblock detail_content %}

26
templates/sessao/sessao_list.html

@ -1,26 +0,0 @@
{% extends "crud/list.html" %}
{% load i18n %}
{% load crispy_forms_tags %}
{% block base_content %}
<h2><b>Sessões Plenárias</b></h2>
<div class="actions btn-group pull-right" role="group">
<a href="{% url 'sessao:sessao_cadastro' %}" class="btn btn-default">
{% blocktrans with verbose_name=view.verbose_name %} Adicionar Sessão Plenária {% endblocktrans %}
</a>
</div>
{% block detail_content %}
<table width="100%">
{% for sessao in page_obj %}
<tr>
<th>
<a href="{% url 'sessao:sessaoplenaria_detail' sessao.id %}">{{sessao}}</a>
<br />
Data: {{sessao.data_inicio}} - Abertura {{sessao.hora_inicio}}
</th>
</tr>
{% endfor %}
</table>
{% include "paginacao.html" %}
{% endblock %}
{% endblock %}

2
templates/sessao/sessaoplenaria_detail.html

@ -1,2 +0,0 @@
{% extends "crud/detail.html" %}
{% block actions %}{% endblock %}

2
templates/sessao/votacao/nominal.html

@ -1,4 +1,4 @@
{% extends "sessao/sessaoplenaria_detail.html" %} {% extends "crud/detail.html" %}
{% load i18n %} {% load i18n %}
{% block detail_content %} {% block detail_content %}

2
templates/sessao/votacao/nominal_edit.html

@ -1,4 +1,4 @@
{% extends "sessao/sessaoplenaria_detail.html" %} {% extends "crud/detail.html" %}
{% load i18n %} {% load i18n %}
{% block detail_content %} {% block detail_content %}

2
templates/sessao/votacao/votacao.html

@ -1,4 +1,4 @@
{% extends "sessao/sessaoplenaria_detail.html" %} {% extends "crud/detail.html" %}
{% load i18n %} {% load i18n %}
{% block detail_content %} {% block detail_content %}

2
templates/sessao/votacao/votacao_edit.html

@ -1,4 +1,4 @@
{% extends "sessao/sessaoplenaria_detail.html" %} {% extends "crud/detail.html" %}
{% load i18n %} {% load i18n %}
{% block detail_content %} {% block detail_content %}

Loading…
Cancel
Save