Browse Source

Restructure comissoes views

pull/6/head
Marcio Mazza 10 years ago
parent
commit
e3c1f8066e
  1. 1
      comissoes/templates/comissoes/criar_comissao.html
  2. 23
      comissoes/templates/comissoes/lista_comissao.html
  3. 6
      comissoes/urls.py
  4. 31
      comissoes/views.py
  5. 1
      requirements/requirements.txt
  6. 22
      templates/comissoes/comissao_form.html
  7. 30
      templates/comissoes/comissao_list.html

1
comissoes/templates/comissoes/criar_comissao.html

@ -1 +0,0 @@
<p>Incluir comissão</p>

23
comissoes/templates/comissoes/lista_comissao.html

@ -1,23 +0,0 @@
{% load i18n %}
{% load tz %}
<p>Comissões</p>
<a href="/admin/comissoes/comissao/add/">Incluir Comissão</a>
<table class="table table-hover">
<thead>
<tr>
<th>{% trans 'Nome' %}</th>
<th>{% trans 'Sigla' %}</th>
<th>{% trans 'Tipo' %}</th>
</tr>
</thead>
<tbody>
{% for comissao in comissoes %}
<td>{{ comissao.nome }}</td>
<td>{{ comissao.sigla }}</td>
<td>{{ comissao.tipo }}</td>
</tr>
{% endfor %}
</tbody>
</table>

6
comissoes/urls.py

@ -1,9 +1,11 @@
from django.conf.urls import patterns, url from django.conf.urls import patterns, url
from comissoes.views import ListaComissoes from comissoes.views import ComissaoListView, ComissaoDetailView, ComissaoUpdateView
urlpatterns = patterns( urlpatterns = patterns(
'comissoes.views', 'comissoes.views',
url(r'^$', ListaComissoes.as_view(), name='ListaComissoes'), url(r'^$', ComissaoListView.as_view(), name='comissao_list'),
url(r'^(?P<pk>\d+)$', ComissaoDetailView.as_view(), name='comissao_detail'),
url(r'^(?P<pk>\d+)/edit$', ComissaoUpdateView.as_view(), name='comissao_update'),
) )

31
comissoes/views.py

@ -1,20 +1,35 @@
from braces.views import FormMessagesMixin
from django.core.urlresolvers import reverse_lazy from django.core.urlresolvers import reverse_lazy
from vanilla import CreateView, ListView from django.views.generic import CreateView, DeleteView, ListView, UpdateView, DetailView
from comissoes.models import Comissao from comissoes.models import Comissao
class ListaComissoes(ListView): class ComissaoListView(ListView):
model = Comissao model = Comissao
context_object_name = 'comissoes'
template_name = 'comissoes/lista_comissao.html'
class CriarComissao(CreateView): class ComissaoDetailView(DetailView):
model = Comissao model = Comissao
success_url = reverse_lazy('ListaComissoes')
class DetalheComissao(ListView): class ComissaoCreateView(CreateView):
model = Comissao model = Comissao
context_object_name = 'comissoes' success_url = reverse_lazy('comissao_list')
class ComissaoUpdateView(FormMessagesMixin, UpdateView):
model = Comissao
fields = [f.name for f in Comissao._meta.fields]
success_url = reverse_lazy('comissao_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 ComissaoDeleteView(DeleteView):
model = Comissao
success_url = reverse_lazy('comissao_list')

1
requirements/requirements.txt

@ -1,6 +1,7 @@
Django Django
django-admin-bootstrapped django-admin-bootstrapped
django-bootstrap3 django-bootstrap3
django-braces
django-vanilla-views django-vanilla-views
mysqlclient mysqlclient
psycopg2 psycopg2

22
templates/comissoes/comissao_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/comissoes/comissao_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 Comissão</a>
<table class="table table-hover">
<thead>
<tr>
<th>{% trans 'Nome' %}</th>
<th>{% trans 'Sigla' %}</th>
<th>{% trans 'Tipo' %}</th>
</tr>
</thead>
<tbody>
{% for comissao in object_list %}
<td>{{ comissao.nome }}</td>
<td>{{ comissao.sigla }}</td>
<td>{{ comissao.tipo }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %}
Loading…
Cancel
Save