Skip to content

Commit ac7a84f

Browse files
committed
Pass user into flat page lookup, fix issues
1 parent b947a52 commit ac7a84f

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,30 @@
1+
{% from "macros/links.jinja" import object_link -%}
12
{% extends "layouts/sub_header_base.jinja" %}
23

34
{% block head_title %}{{ flatpage.title }}{% endblock %}
45

56
{% block sub_header %}{{ flatpage.title }}{% endblock %}
67

8+
{% block sub_actions %}
9+
{%- set pages = get_flatpages(starts_with=flatpage.url, user=user) %}
10+
{% if pages.count() > 0 %}
11+
<div class="navbar-text text-muted">
12+
{{ _("Sub Pages:") }}&nbsp;
13+
</div>
14+
{% endif %}
15+
<ul class="navbar-nav">
16+
{%- for page in pages %}
17+
<li class="nav-item">
18+
{%- call object_link(page, "page-link", ["nav-link"]) -%}
19+
{{ page.title }}
20+
{%- endcall -%}
21+
</li>
22+
{% endfor -%}
23+
</ul>
24+
{% endblock %}
25+
726
{% block content %}
27+
<div class="content">
828
{{ markdown(flatpage.content) }}
29+
</div>
930
{% endblock %}

toolhub/templates/partials/footer.jinja

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
</div>
1212
<div>
1313
{% block footer_container %}
14-
{%- set pages = get_flatpages() %}
14+
{%- set pages = get_flatpages(user=user) %}
1515
{%- for page in pages %}
1616
{%- call object_link(page, "page-link", ["text-white"]) -%}
1717
{{ page.title }}
18-
<br>
1918
{%- endcall -%}
19+
<br>
2020
{% endfor -%}
2121
{% endblock %}
2222
</div>

utils/templatetags/flatpages.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def get_flatpages(context, starts_with=None, user=None):
1515
flatpages = FlatPage.objects.filter(sites__id=site_pk)
1616
# If a prefix was specified, add a filter
1717
if starts_with:
18-
flatpages = flatpages.filter(url__startswith=starts_with)
18+
flatpages = flatpages.filter(url__startswith=starts_with).exclude(url=starts_with)
1919

2020
# If the provided user is not authenticated, or no user
2121
# was provided, filter the list to only public flatpages.

0 commit comments

Comments
 (0)