Skip to content

Commit

Permalink
Merge branch 'main' into 11277-pni-seo-page-titles
Browse files Browse the repository at this point in the history
  • Loading branch information
robdivincenzo authored Mar 19, 2024
2 parents 8993a97 + 68ebe80 commit 1719df1
Show file tree
Hide file tree
Showing 12 changed files with 717 additions and 1,039 deletions.
14 changes: 6 additions & 8 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ asgiref==3.7.2
# via
# -c requirements.txt
# django
black==24.1.1
black==24.3.0
# via -r dev-requirements.in
click==8.1.3
# via
Expand All @@ -17,12 +17,10 @@ click==8.1.3
colorama==0.4.6
# via djlint
coverage[toml]==7.4.1
# via
# coverage
# pytest-cov
# via pytest-cov
cssbeautifier==1.14.7
# via djlint
django==4.2.10
django==4.2.11
# via
# -c requirements.txt
# django-debug-toolbar
Expand Down Expand Up @@ -56,7 +54,7 @@ jsbeautifier==1.14.7
# djlint
mccabe==0.7.0
# via flake8
mypy==1.8.0
mypy==1.9.0
# via -r dev-requirements.in
mypy-extensions==1.0.0
# via
Expand All @@ -82,7 +80,7 @@ pycodestyle==2.11.0
# via flake8
pyflakes==3.2.0
# via flake8
pytest==8.0.1
pytest==8.1.1
# via
# -r dev-requirements.in
# pytest-cov
Expand Down Expand Up @@ -119,7 +117,7 @@ tqdm==4.63.0
# via
# -c requirements.txt
# djlint
types-python-slugify==8.0.2.20240127
types-python-slugify==8.0.2.20240310
# via -r dev-requirements.in
types-requests==2.31.0.6
# via -r dev-requirements.in
Expand Down
4 changes: 2 additions & 2 deletions network-api/networkapi/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,8 +679,8 @@ class DatabasesDict(TypedDict):
"django.db.backends": {"handlers": ["debug-error"], "level": "ERROR"},
"django.utils.autoreload": {"handlers": ["debug-error"], "level": "ERROR"},
"networkapi": {
"handlers": ["debug"],
"level": "DEBUG",
"handlers": ["info"],
"level": "INFO",
},
},
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{% load bg_nav_tags i18n wagtailroutablepage_tags %}

{% with request.get_full_path as current_url %}
{% routablepageurl page 'about-why-view' as about_why_url %}
{% routablepageurl page 'how-to-use-view' as how_to_use_url %}
{% routablepageurl page 'about-why-view' as about_why_url %}
{% routablepageurl page 'methodology-view' as methodology_url %}
{% routablepageurl page 'contact-view' as contact_url %}
{% routablepageurl page 'press-view' as press_url %}

<div class="col-lg-3">
<nav class="vertical-nav mt-5 pt-sm-2" title="{% trans "about sections" context "Tooltip on menu items" %}">
<div class="multipage-link-wrapper"><a class="multipage-link about-link {% bg_active_nav current_url about_why_url %}" href="{{ about_why_url }}">{% trans "Why we made this guide" %}</a></div>
<div class="multipage-link-wrapper"><a class="multipage-link about-link {% bg_active_nav current_url how_to_use_url %}" href="{{ how_to_use_url }}">{% trans "How to use this guide" %}</a></div>
<div class="multipage-link-wrapper"><a class="multipage-link about-link {% bg_active_nav current_url about_why_url %}" href="{{ about_why_url }}">{% trans "Why we made this guide" %}</a></div>
<div class="multipage-link-wrapper"><a class="multipage-link about-link {% bg_active_nav current_url methodology_url %}" href="{{ methodology_url }}">{% trans "Methodology" %}</a></div>
<div class="multipage-link-wrapper"><a class="multipage-link about-link {% bg_active_nav current_url contact_url %}" href="{{ contact_url }}">{% trans "Contact us" %}</a></div>
<div class="multipage-link-wrapper"><a class="multipage-link about-link {% bg_active_nav current_url press_url %}" href="{{ press_url }}">{% trans "Press" %}</a></div>
</nav>
</div>

{% endwith %}
{% endwith %}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
height="10"
>
{% if editorial_content_index %}
<a class="{{ class }} {% bg_active_nav request.get_full_path editorial_content_index.url %} " href="{% pageurl editorial_content_index %}">{{ editorial_content_index }}</a>
<a class="{{ class }} {% bg_active_nav request.get_full_path editorial_content_index.url 'primary_nav' %} " href="{% pageurl editorial_content_index %}">{{ editorial_content_index }}</a>
{% endif %}
{% endwith %}
{% routablepageurl home_page 'about-why-view' as about_why_url %}
<a class="{{ class }} {% bg_active_nav request.get_full_path about_why_url %}" href="{{ about_why_url }}">{% trans "About" %}</a>
{% routablepageurl home_page 'how-to-use-view' as how_to_use_url %}

<a class="{{ class }} {% bg_active_nav request.get_full_path how_to_use_url 'primary_nav' %}" href="{{ how_to_use_url }}">{% trans "About" %}</a>
<a data-donate-header-button class="{{ class }}" href="?form=donate&utm_medium=FMO&utm_source=PNI&utm_campaign=23-PNI&utm_content=header&c_id=7014x000000eQOD">{% trans "Donate" %}</a>
{{ post }}
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ def check_active_category(current_category, target_category):
return "active" if match else ""


# Determine if a nav link should be active.
# Determine if a nav (sidebar nav or primary nav) link should be active.
@register.simple_tag(name="bg_active_nav")
def bg_active_nav(current, target):
return "active" if urlparse(current).path == urlparse(target).path else ""
def bg_active_nav(current, target, nav="sidebar"):
if nav == "primary_nav":
return "active" if urlparse(target).path in urlparse(current).path else ""
else:
return "active" if urlparse(target).path == urlparse(current).path else ""


@register.simple_tag(name="product_in_category")
Expand Down
10 changes: 0 additions & 10 deletions network-api/networkapi/wagtailpages/templatetags/mini_site_tags.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import logging
from urllib.parse import parse_qsl, urlencode, urlparse, urlunparse

from django import template
Expand All @@ -10,8 +9,6 @@

register = template.Library()

logger = logging.getLogger(__name__)


# Instantiate a mini-site sidebar menu based on the current page's relation to other pages
@register.inclusion_tag("wagtailpages/tags/mini_site_sidebar.html", takes_context=True)
Expand All @@ -30,19 +27,12 @@ def _generate_thank_you_url(url):
Generate a thank you page URL by grabbing the current url and appending thank_you=true
"""

logger.debug(f'Generating "thank you URL" for {url}')

parsed_url = urlparse(url)
logger.debug(f"parsed_url: {parsed_url}")
query_params = parse_qsl(parsed_url.query)
logger.debug(f"query_params: {query_params}")
query_params.append(("thank_you", "true"))
query_string = urlencode(query_params)
logger.debug(f"query_string: {query_string}")
thank_you_url = urlunparse(parsed_url._replace(query=query_string))

logger.debug(f'Generated "thank you URL": {thank_you_url}')

return thank_you_url


Expand Down
Loading

0 comments on commit 1719df1

Please sign in to comment.