From f6b6157bf5502fcbc2a914cc9b7e067091956cce Mon Sep 17 00:00:00 2001 From: Marcio Mazza Date: Tue, 21 Jul 2015 19:20:17 -0300 Subject: [PATCH] Add title and help to base template --- comissoes/views.py | 22 +++++++++++++++++----- templates/base.html | 11 ++++++++++- templates/comissoes/comissao_form.html | 2 -- templates/comissoes/comissao_list.html | 3 --- 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/comissoes/views.py b/comissoes/views.py index 0611e3863..7891a4c95 100644 --- a/comissoes/views.py +++ b/comissoes/views.py @@ -1,5 +1,6 @@ from braces.views import FormMessagesMixin from django.core.urlresolvers import reverse_lazy +from django.utils.translation import ugettext as _ from django.views.generic import ( CreateView, DeleteView, ListView, UpdateView, DetailView) @@ -7,20 +8,31 @@ from .forms import ComissaoForm from .models import Comissao -class ComissaoListView(ListView): +class BaseMixin(object): + + @property + def title(self): + return self.get_object() + + help_url = '/comissoes/ajuda' + + +class ComissaoListView(BaseMixin, ListView): model = Comissao + title = Comissao._meta.verbose_name_plural -class ComissaoDetailView(DetailView): +class ComissaoDetailView(BaseMixin, DetailView): model = Comissao -class ComissaoCreateView(CreateView): +class ComissaoCreateView(BaseMixin, CreateView): model = Comissao success_url = reverse_lazy('comissao_list') + title = _('Nova Comissão') -class ComissaoUpdateView(FormMessagesMixin, UpdateView): +class ComissaoUpdateView(BaseMixin, FormMessagesMixin, UpdateView): model = Comissao form_class = ComissaoForm success_url = reverse_lazy('comissao_list') @@ -30,6 +42,6 @@ class ComissaoUpdateView(FormMessagesMixin, UpdateView): return u"{0} updated successfully!".format(self.object) -class ComissaoDeleteView(DeleteView): +class ComissaoDeleteView(BaseMixin, DeleteView): model = Comissao success_url = reverse_lazy('comissao_list') diff --git a/templates/base.html b/templates/base.html index 5816cfbe1..4de008e05 100644 --- a/templates/base.html +++ b/templates/base.html @@ -7,7 +7,7 @@ {% block head_title %}{% trans 'SAPL - Sistema de Apoio ao Processo Legislativo' %}{% endblock %} - {% block header_content %} + {% block head_content %} @@ -35,6 +35,15 @@ {% endfor %} + {% block base_header %} +
+ {% block help %} + {% if view.help_url %}{% trans 'Ajuda' %}{% endif %} + {% endblock %} + {% block title %}{% if view.title %}

{{ view.title }}

{% endif %}{% endblock %} +
+ {% endblock %} + {% block base_content %}{% endblock %} {% endblock %} diff --git a/templates/comissoes/comissao_form.html b/templates/comissoes/comissao_form.html index 406416095..2b1272cec 100644 --- a/templates/comissoes/comissao_form.html +++ b/templates/comissoes/comissao_form.html @@ -1,8 +1,6 @@ {% extends "base.html" %} {% load i18n bootstrap3 crispy_forms_tags %} -{% block title %}SAPL{% endblock %} - {% block base_content %} {% crispy form %} {% endblock %} diff --git a/templates/comissoes/comissao_list.html b/templates/comissoes/comissao_list.html index 5eacdcf53..fad72ded9 100644 --- a/templates/comissoes/comissao_list.html +++ b/templates/comissoes/comissao_list.html @@ -1,10 +1,7 @@ {% extends "base.html" %} {% load i18n bootstrap3 %} -{% block title %}SAPL{% endblock %} - {% block base_content %} -

Comissões

Incluir Comissão