✨ use view-based breadcrumbs
This commit is contained in:
parent
84b36e5d23
commit
f72e87f404
4 changed files with 33 additions and 38 deletions
|
|
@ -4,26 +4,15 @@
|
|||
{% load menu_tags %}
|
||||
|
||||
{% block navbar %}
|
||||
{% include "header_reduced.html" %}
|
||||
{% endblock %}
|
||||
{{ block.super }}
|
||||
|
||||
{% include "snippets/breadcrumbs.html" with breadcrumbs_background="blue-10" overlay=True %}
|
||||
{% endblock navbar %}
|
||||
|
||||
{% block body %}
|
||||
<nav class="bg-body-secondary" aria-label="breadcrumb">
|
||||
<div class="container">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item">
|
||||
<a href="{{ request.current_page.get_absolute_url }}">
|
||||
{{ request.current_page.get_title }}
|
||||
</a>
|
||||
</li>
|
||||
{% block govplan_breadcrumbs %}{% endblock %}
|
||||
</ol>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
{% static_placeholder "govplan_header" %}
|
||||
{% block app_body %}
|
||||
{% placeholder "content" %}
|
||||
{% endblock %}
|
||||
{% endblock app_body %}
|
||||
{% static_placeholder "govplan_footer" %}
|
||||
{% endblock %}
|
||||
{% endblock body %}
|
||||
|
|
|
|||
|
|
@ -9,20 +9,11 @@
|
|||
{% load content_helper %}
|
||||
{% load thumbnail %}
|
||||
|
||||
{% block title %}{{ object.title }}{% endblock %}
|
||||
{% block title %}{{ object.title }}{% endblock title %}
|
||||
|
||||
{% block meta %}
|
||||
{% include "snippets/meta.html" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block govplan_breadcrumbs %}
|
||||
<li class="breadcrumb-item">
|
||||
<a href="{{ section.get_absolute_url }}">{{ section.title}}</a>
|
||||
</li>
|
||||
<li class="breadcrumb-item active" aria-current="page">
|
||||
<a href="{{ object.get_absolute_url }}">{{ object.title }}</a>
|
||||
</li>
|
||||
{% endblock %}
|
||||
{% endblock meta %}
|
||||
|
||||
{% block app_body %}
|
||||
<div class="container mb-3">
|
||||
|
|
@ -203,7 +194,5 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% endblock app_body %}
|
||||
|
|
|
|||
|
|
@ -12,12 +12,6 @@
|
|||
{% include "snippets/meta.html" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block govplan_breadcrumbs %}
|
||||
<li class="breadcrumb-item active" aria-current="page">
|
||||
<a href="{{ object.get_absolute_url }}">{{ object.title }}</a>
|
||||
</li>
|
||||
{% endblock %}
|
||||
|
||||
{% block app_body %}
|
||||
<div class="container">
|
||||
<div class="row justify-content-center mb-5">
|
||||
|
|
@ -54,4 +48,4 @@
|
|||
|
||||
{% include "froide_govplan/plugins/card_cols.html" with object_list=plans %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% endblock app_body %}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,16 @@ class GovernmentMixin:
|
|||
Government, slug=self.kwargs["gov"], **filter_kwarg
|
||||
)
|
||||
|
||||
def get_breadcrumbs(self, context):
|
||||
if "request" in context:
|
||||
request = context["request"]
|
||||
|
||||
title = request.current_page.get_title()
|
||||
url = request.current_page.get_absolute_url()
|
||||
return [(title, url)]
|
||||
|
||||
return []
|
||||
|
||||
|
||||
class GovPlanSectionDetailView(GovernmentMixin, DetailView):
|
||||
slug_url_kwarg = "section"
|
||||
|
|
@ -38,6 +48,11 @@ class GovPlanSectionDetailView(GovernmentMixin, DetailView):
|
|||
context["plans"] = context["object"].get_plans(queryset=queryset)
|
||||
return context
|
||||
|
||||
def get_breadcrumbs(self, context):
|
||||
return super().get_breadcrumbs(context) + [
|
||||
(self.object.title, self.object.get_absolute_url())
|
||||
]
|
||||
|
||||
|
||||
class GovPlanDetailView(GovernmentMixin, DetailView):
|
||||
slug_url_kwarg = "plan"
|
||||
|
|
@ -63,6 +78,14 @@ class GovPlanDetailView(GovernmentMixin, DetailView):
|
|||
self.request.govplan = self.object
|
||||
return context
|
||||
|
||||
def get_breadcrumbs(self, context):
|
||||
obj = context["object"]
|
||||
section = context["section"]
|
||||
return super().get_breadcrumbs(context) + [
|
||||
(section.title, section.get_absolute_url()),
|
||||
(obj.title, obj.get_absolute_url()),
|
||||
]
|
||||
|
||||
|
||||
class GovPlanProposeUpdateView(GovernmentMixin, LoginRequiredMixin, UpdateView):
|
||||
slug_url_kwarg = "plan"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue