Browse Source

Add sessao url, views and html placeholders

pull/6/head
Edward Ribeiro 10 years ago
parent
commit
48a90bb42d
  1. 1
      sapl/urls.py
  2. 11
      sessao/urls.py
  3. 36
      sessao/views.py
  4. 30
      templates/comissoes/sessao_list.html
  5. 22
      templates/sessao/sessaoplenaria_form.html
  6. 30
      templates/sessao/sessaoplenaria_list.html

1
sapl/urls.py

@ -22,4 +22,5 @@ urlpatterns = [
url(r'^$', TemplateView.as_view(template_name='index.html')), url(r'^$', TemplateView.as_view(template_name='index.html')),
url(r'^admin/', include(admin.site.urls)), url(r'^admin/', include(admin.site.urls)),
url(r'^comissoes/', include('comissoes.urls')), url(r'^comissoes/', include('comissoes.urls')),
url(r'^sessao/', include('sessao.urls')),
] ]

11
sessao/urls.py

@ -0,0 +1,11 @@
from django.conf.urls import patterns, url
from sessao.views import SessaoListView, SessaoDetailView, SessaoUpdateView
urlpatterns = patterns(
'comissoes.views',
url(r'^$', SessaoListView.as_view(), name='sessao_list'),
url(r'^(?P<pk>\d+)$', SessaoDetailView.as_view(), name='sessao_detail'),
url(r'^(?P<pk>\d+)/edit$', SessaoUpdateView.as_view(), name='sessao_update'),
)

36
sessao/views.py

@ -1,3 +1,35 @@
from django.shortcuts import render from braces.views import FormMessagesMixin
from django.core.urlresolvers import reverse_lazy
from django.views.generic import CreateView, DeleteView, ListView, UpdateView, DetailView
# Create your views here. from sessao.models import SessaoPlenaria
class SessaoListView(ListView):
model = SessaoPlenaria
class SessaoDetailView(DetailView):
model = SessaoPlenaria
class SessaoCreateView(CreateView):
model = SessaoPlenaria
success_url = reverse_lazy('sessao_list')
class SessaoUpdateView(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 SessaoDeleteView(DeleteView):
model = SessaoPlenaria
success_url = reverse_lazy('sessao_list')

30
templates/comissoes/sessao_list.html

@ -0,0 +1,30 @@
{% extends "base.html" %}
{% load i18n bootstrap3 %}
{% block title %}SAPL{% endblock %}
{% block content %}
<div id="content-main">
<p>Sessão Legislativa</p>
<a href="/admin/sessao/sessao/add/">Incluir Sessão</a>
<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>
</div>
{% endblock %}

22
templates/sessao/sessaoplenaria_form.html

@ -0,0 +1,22 @@
{% extends "base.html" %}
{% load i18n bootstrap3 %}
{% block title %}SAPL{% endblock %}
{% block content %}
<div id="content-main">
{# Display a form #}
<form method="post" class="form">
{% csrf_token %}
{% bootstrap_form form %}
{% buttons %}
<button type="submit" class="btn btn-primary">
{% bootstrap_icon "star" %} Submit
</button>
{% endbuttons %}
</form>
</div>
{% endblock %}

30
templates/sessao/sessaoplenaria_list.html

@ -0,0 +1,30 @@
{% extends "base.html" %}
{% load i18n bootstrap3 %}
{% block title %}SAPL{% endblock %}
{% block content %}
<div id="content-main">
<p>Comissões</p>
<a href="/admin/comissoes/comissao/add/">Incluir Sessão</a>
<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>
</div>
{% endblock %}
Loading…
Cancel
Save