diff --git a/comissoes/templates/comissoes/criar_comissao.html b/comissoes/templates/comissoes/criar_comissao.html
deleted file mode 100644
index 59df07ed1..000000000
--- a/comissoes/templates/comissoes/criar_comissao.html
+++ /dev/null
@@ -1 +0,0 @@
-
Incluir comissão
\ No newline at end of file
diff --git a/comissoes/templates/comissoes/lista_comissao.html b/comissoes/templates/comissoes/lista_comissao.html
deleted file mode 100644
index 725be9661..000000000
--- a/comissoes/templates/comissoes/lista_comissao.html
+++ /dev/null
@@ -1,23 +0,0 @@
-{% load i18n %}
-{% load tz %}
-
-Comissões
-Incluir Comissão
-
-
-
-
- {% trans 'Nome' %} |
- {% trans 'Sigla' %} |
- {% trans 'Tipo' %} |
-
-
-
- {% for comissao in comissoes %}
- {{ comissao.nome }} |
- {{ comissao.sigla }} |
- {{ comissao.tipo }} |
-
- {% endfor %}
-
-
\ No newline at end of file
diff --git a/comissoes/urls.py b/comissoes/urls.py
index cd27dabf5..3095fac45 100644
--- a/comissoes/urls.py
+++ b/comissoes/urls.py
@@ -1,9 +1,11 @@
from django.conf.urls import patterns, url
-from comissoes.views import ListaComissoes
+from comissoes.views import ComissaoListView, ComissaoDetailView, ComissaoUpdateView
urlpatterns = patterns(
'comissoes.views',
- url(r'^$', ListaComissoes.as_view(), name='ListaComissoes'),
+ url(r'^$', ComissaoListView.as_view(), name='comissao_list'),
+ url(r'^(?P\d+)$', ComissaoDetailView.as_view(), name='comissao_detail'),
+ url(r'^(?P\d+)/edit$', ComissaoUpdateView.as_view(), name='comissao_update'),
)
diff --git a/comissoes/views.py b/comissoes/views.py
index d2dfd2cdc..a75b0802f 100644
--- a/comissoes/views.py
+++ b/comissoes/views.py
@@ -1,20 +1,35 @@
+from braces.views import FormMessagesMixin
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
-class ListaComissoes(ListView):
+class ComissaoListView(ListView):
model = Comissao
- context_object_name = 'comissoes'
- template_name = 'comissoes/lista_comissao.html'
-class CriarComissao(CreateView):
+class ComissaoDetailView(DetailView):
model = Comissao
- success_url = reverse_lazy('ListaComissoes')
-class DetalheComissao(ListView):
+class ComissaoCreateView(CreateView):
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')
diff --git a/requirements/requirements.txt b/requirements/requirements.txt
index 9834e8f27..27abca251 100644
--- a/requirements/requirements.txt
+++ b/requirements/requirements.txt
@@ -1,6 +1,7 @@
Django
django-admin-bootstrapped
django-bootstrap3
+django-braces
django-vanilla-views
mysqlclient
psycopg2
diff --git a/templates/comissoes/comissao_form.html b/templates/comissoes/comissao_form.html
new file mode 100644
index 000000000..f0e38178c
--- /dev/null
+++ b/templates/comissoes/comissao_form.html
@@ -0,0 +1,22 @@
+{% extends "base.html" %}
+{% load i18n bootstrap3 %}
+
+{% block title %}SAPL{% endblock %}
+
+{% block content %}
+
+ {# Display a form #}
+
+
+{% endblock %}
+
diff --git a/templates/comissoes/comissao_list.html b/templates/comissoes/comissao_list.html
new file mode 100644
index 000000000..87e2b7fed
--- /dev/null
+++ b/templates/comissoes/comissao_list.html
@@ -0,0 +1,30 @@
+{% extends "base.html" %}
+{% load i18n bootstrap3 %}
+
+{% block title %}SAPL{% endblock %}
+
+{% block content %}
+
+
Comissões
+
Incluir Comissão
+
+
+
+
+ {% trans 'Nome' %} |
+ {% trans 'Sigla' %} |
+ {% trans 'Tipo' %} |
+
+
+
+ {% for comissao in object_list %}
+ {{ comissao.nome }} |
+ {{ comissao.sigla }} |
+ {{ comissao.tipo }} |
+
+ {% endfor %}
+
+
+
+{% endblock %}
+