Browse Source

Add title and help to base template

pull/6/head
Marcio Mazza 10 years ago
parent
commit
f6b6157bf5
  1. 22
      comissoes/views.py
  2. 11
      templates/base.html
  3. 2
      templates/comissoes/comissao_form.html
  4. 3
      templates/comissoes/comissao_list.html

22
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')

11
templates/base.html

@ -7,7 +7,7 @@
<meta charset="utf-8">
<title>{% block head_title %}{% trans 'SAPL - Sistema de Apoio ao Processo Legislativo' %}{% endblock %}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
{% block header_content %}
{% block head_content %}
<link rel="stylesheet" href="{% static 'foundation/css/foundation.min.css' %}">
<script type="text/javascript" src="{% static 'foundation/js/vendor/modernizr.js' %}"></script>
<script type="text/javascript" src="{% static 'foundation/js/vendor/jquery.js' %}"></script>
@ -35,6 +35,15 @@
</div>
{% endfor %}
{% block base_header %}
<div class="clearfix">
{% block help %}
{% if view.help_url %}<a class="contextual-help right" href="{{ view.help_url }}">{% trans 'Ajuda' %}</a>{% endif %}
{% endblock %}
{% block title %}{% if view.title %}<h1>{{ view.title }}</h1>{% endif %}{% endblock %}
</div>
{% endblock %}
{% block base_content %}{% endblock %}
</div>
{% endblock %}

2
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 %}

3
templates/comissoes/comissao_list.html

@ -1,10 +1,7 @@
{% extends "base.html" %}
{% load i18n bootstrap3 %}
{% block title %}SAPL{% endblock %}
{% block base_content %}
<p>Comissões</p>
<a href="/admin/comissoes/comissao/add/">Incluir Comissão</a>
<table class="table table-hover">

Loading…
Cancel
Save