Browse Source

Add sessao structure based on crud

pull/6/head
Marcio Mazza 10 years ago
parent
commit
24bdc2bace
  1. 3
      sapl/urls.py
  2. 20
      sessao/urls.py
  3. 38
      sessao/views.py
  4. 6
      templates/sessao/expediente.html
  5. 9
      templates/sessao/sessaoplenaria_detail.html
  6. 8
      templates/sessao/sessaoplenaria_form.html
  7. 28
      templates/sessao/sessaoplenaria_list.html

3
sapl/urls.py

@ -32,6 +32,7 @@ from parlamentares.views import (cargo_mesa_crud, coligacao_crud,
partido_crud, sessao_legislativa_crud,
tipo_afastamento_crud, tipo_dependente_crud,
tipo_militar_crud)
from sessao.urls import sessao_urls
from sessao.views import (tipo_expediente_crud, tipo_resultado_votacao_crud,
tipo_sessao_crud)
@ -41,7 +42,7 @@ urlpatterns = [
# main apps
url(r'^comissoes/', include(comissoes_urls)),
url(r'^sessao/', include('sessao.urls')),
url(r'^sessao/', include(sessao_urls)),
# SYSTEM DATA

20
sessao/urls.py

@ -1,15 +1,9 @@
from django.conf.urls import patterns, url
from django.conf.urls import url
from sessao.views import (SessaoPlenariaCreateView, SessaoPlenariaDetailView,
SessaoPlenariaListView, SessaoPlenariaUpdateView)
from sessao.views import ExpedienteView, sessao_crud
urlpatterns = patterns(
'sessao.views',
url(r'^$', SessaoPlenariaListView.as_view(), name='sessao_list'),
url(r'^(?P<pk>\d+)$', SessaoPlenariaDetailView.as_view(),
name='sessao_detail'),
url(r'^create$', SessaoPlenariaCreateView.as_view(),
name='sessao_create'),
url(r'^(?P<pk>\d+)/edit$', SessaoPlenariaUpdateView.as_view(),
name='sessao_update'),
)
urlpatterns = sessao_crud.urlpatterns + [
url(r'^(?P<pk>\d+)/expediente$',
ExpedienteView.as_view(), name='expediente'),
]
sessao_urls = urlpatterns, sessao_crud.namespace, sessao_crud.namespace

38
sessao/views.py

@ -1,8 +1,4 @@
from braces.views import FormMessagesMixin
from django.core.urlresolvers import reverse_lazy
from django.utils.translation import ugettext_lazy as _
from django.views.generic import (CreateView, DeleteView, DetailView, ListView,
UpdateView)
from sapl.crud import build_crud
@ -87,34 +83,6 @@ registro_votacao_crud = build_crud(
)
class SessaoPlenariaListView(ListView):
model = SessaoPlenaria
class SessaoPlenariaDetailView(DetailView):
model = SessaoPlenaria
class SessaoPlenariaCreateView(CreateView):
model = SessaoPlenaria
# fields = [f.name for f in SessaoPlenaria._meta.fields]
form_invalid_message = u"Something went wrong, post was not saved"
success_url = reverse_lazy('sessao_list')
class SessaoPlenariaUpdateView(FormMessagesMixin, UpdateView):
model = SessaoPlenaria
fields = [f.name for f in SessaoPlenaria._meta.fields]
success_url = reverse_lazy('sessao_list')
form_invalid_message = u"Something went wrong, post was not saved"
def get_form_valid_message(self):
return u"{0} updated successfully!".format(self.object)
class SessaoPlenariaDeleteView(DeleteView):
model = SessaoPlenaria
success_url = reverse_lazy('sessao_list')
class ExpedienteView(sessao_crud.CrudDetailView):
template_name = 'sessao/expediente.html'
# TODO ...

6
templates/sessao/expediente.html

@ -0,0 +1,6 @@
{% extends "sessao/sessaoplenaria_detail.html" %}
{% load i18n %}
{% block detail_content %}
TODO ... Expediente
{% endblock detail_content %}

9
templates/sessao/sessaoplenaria_detail.html

@ -0,0 +1,9 @@
{% extends "crud/detail.html" %}
{% load i18n %}
{% block sections_nav %}
<dl class="sub-nav left">
<dd><a href="{% url 'sessaoplenaria:detail' object.pk %}" class="button secondary">{% trans 'Início' %}</a></dd>
<dd><a href="{% url 'sessaoplenaria:expediente' object.pk %}" class="button secondary">{% trans 'Expediente' %}</a></dd>
</dl>
{% endblock sections_nav %}

8
templates/sessao/sessaoplenaria_form.html

@ -1,8 +0,0 @@
{% extends "base.html" %}
{% load i18n crispy_forms_tags %}
{% block title %}SAPL{% endblock %}
{% block base_content %}
{% crispy form %}
{% endblock %}

28
templates/sessao/sessaoplenaria_list.html

@ -1,28 +0,0 @@
{% extends "base.html" %}
{% load i18n %}
{% block title %}SAPL{% endblock %}
{% block base_content %}
<p>Sessão Plenária</p>
<a href="{% url 'sessao_create' %}" class="btn btn-default">Incluir Sessão</a>
<hr/>
<table class="table table-hover">
<thead>
<tr>
<th>{% trans 'Sessão Legislativa' %}</th>
<th>{% trans 'Legislatura' %}</th>
<th>{% trans 'Tipo' %}</th>
</tr>
</thead>
<tbody>
{% for sessao in object_list %}
<td>{{ sessao.sessao_legislativa }}</td>
<td>{{ sessao.legislatura }}</td>
<td>{{ sessao.tipo }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}
Loading…
Cancel
Save