Skip to content

Commit e0a404d

Browse files
committed
Merge branch 'develop' into feature/1647-banner
2 parents 4e455b5 + ae69cd9 commit e0a404d

39 files changed

+505
-244
lines changed

requirements/base.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ django-js-asset==1.2.2
195195
# django-mptt
196196
django-localflavor==3.1
197197
# via -r requirements/base.in
198-
django-log-outgoing-requests==0.4.0
198+
django-log-outgoing-requests==0.5.0
199199
# via -r requirements/base.in
200200
django-mptt==0.13.4
201201
# via django-filer

requirements/ci.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ django-localflavor==3.1
309309
# via
310310
# -c requirements/base.txt
311311
# -r requirements/base.txt
312-
django-log-outgoing-requests==0.4.0
312+
django-log-outgoing-requests==0.5.0
313313
# via
314314
# -c requirements/base.txt
315315
# -r requirements/base.txt

requirements/dev.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ django-localflavor==3.1
338338
# via
339339
# -c requirements/ci.txt
340340
# -r requirements/ci.txt
341-
django-log-outgoing-requests==0.4.0
341+
django-log-outgoing-requests==0.5.0
342342
# via
343343
# -c requirements/ci.txt
344344
# -r requirements/ci.txt

src/open_inwoner/components/templates/components/Form/ChoiceRadio.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{% load l10n form_tags %}
22

3-
<label class="radio">
3+
<div class="radio">
44
{% spaceless %}
55
{% initial_match as checked %}
66
<input
@@ -13,4 +13,4 @@
1313
/>
1414
<label class="radio__label" for="id_{{ name }}_{{ index }}">{{ choice.1 }}</label>
1515
{% endspaceless %}
16-
</label>
16+
</div>

src/open_inwoner/components/templates/components/Form/Input.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
<div class="form__control {{ extra_classes|default:"" }}">
44
<label class="label {% if no_label %}label--gapless{% endif %}">
55
{% if icon %}{% icon icon outlined=True %}{% endif %}
6-
<label class="label__label {% if no_label %}label__label--hidden{% endif %}">
6+
<span class="label__label {% if no_label %}label__label--hidden{% endif %}">
77
{{ field.label }}
88
{% if field.field.required %}<span class="label__label--required"> * </span>{% endif %}
9-
</label>
9+
</span>
1010
{{ field|addclass:"input" }}
1111
{% if field.help_text and not no_help %}
1212
<p class="p">{{ field.help_text }}</p>

src/open_inwoner/components/templates/components/Form/Label.html

-27
This file was deleted.

src/open_inwoner/components/templates/components/Header/Header.html

+52-43
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
{% get_solo "configurations.SiteConfiguration" as config %}
44

55
{% accessibility_header request=request %}
6+
67
<header class="header" aria-label="Navigatie header">
78
<div class="header__container">
89
<div class="header__menu">
@@ -28,13 +29,15 @@
2829
<div class="header__submenu">
2930

3031
{% if cms_apps.products %}
31-
<nav class="header__actions" aria-label="Zoek navigatie mobiel">
32-
{% url 'search:search' as search_url %}
33-
{% render_form form=search_form method="GET" form_action=search_url inline=True spaceless=False %}
34-
{% input search_form.query no_label=True %}
35-
{% form_actions primary_icon="search" primary_text=_("Zoeken") hide_primary_text=True %}
36-
{% endrender_form %}
37-
</nav>
32+
{% if request.user.is_authenticated or not config.hide_search_from_anonymous_users %}
33+
<nav class="header__actions" aria-label="Zoek navigatie mobiel">
34+
{% url 'search:search' as search_url %}
35+
{% render_form form=search_form method="GET" form_action=search_url inline=True spaceless=False %}
36+
{% input search_form.query no_label=True %}
37+
{% form_actions primary_icon="search" primary_text=_("Zoeken") hide_primary_text=True %}
38+
{% endrender_form %}
39+
</nav>
40+
{% endif %}
3841
{% endif %}
3942

4043
<nav class="primary-navigation" aria-label="Hoofd navigatie">
@@ -45,25 +48,27 @@
4548
{% link text=link_text href="/" icon="grid_view" icon_position="before" %}
4649
</li>
4750

48-
{% if cms_apps.products and categories %}
49-
<li class="primary-navigation__list-item dropdown-nav__toggle">
50-
<a href="#" class="link link--toggle link--icon link--icon-position-before" aria-label="{% trans "Onderwerpen" %}" title="{% trans "Onderwerpen" %}" aria-expanded="false">
51-
<span >{% trans "Onderwerpen" %}</span>
52-
<span aria-hidden="true" class="material-icons-outlined ">description</span>
53-
{% icon icon="expand_more" icon_position="after" icon_outlined=True %}
54-
</a>
55-
56-
{% if categories %}
57-
<ul class="primary-navigation__list subpage-list">
58-
{% for category in categories %}
59-
<li class="primary-navigation__list-item">
60-
{% url 'products:category_detail' slug=category.slug as category_href %}
61-
{% link text=category.name href=category_href %}
62-
</li>
63-
{% endfor %}
64-
</ul>
51+
{% if cms_apps.products %}
52+
{% if request.user.is_authenticated or not config.hide_categories_from_anonymous_users %}
53+
<li class="primary-navigation__list-item dropdown-nav__toggle">
54+
<a href="#" class="link link--toggle link--icon link--icon-position-before" aria-label="{% trans "Onderwerpen" %}" title="{% trans "Onderwerpen" %}" aria-expanded="false">
55+
<span >{% trans "Onderwerpen" %}</span>
56+
<span aria-hidden="true" class="material-icons-outlined ">description</span>
57+
{% icon icon="expand_more" icon_position="after" icon_outlined=True %}
58+
</a>
59+
60+
{% if menu_categories %}
61+
<ul class="primary-navigation__list subpage-list">
62+
{% for category in menu_categories %}
63+
<li class="primary-navigation__list-item">
64+
{% url 'products:category_detail' slug=category.slug as category_href %}
65+
{% link text=category.name href=category_href %}
66+
</li>
67+
{% endfor %}
68+
</ul>
69+
{% endif %}
70+
</li>
6571
{% endif %}
66-
</li>
6772
{% endif %}
6873

6974
{% show_menu_below_id "home" 0 100 100 100 "cms/menu/primary.html" %}
@@ -103,30 +108,34 @@
103108
{% firstof config.logo.default_alt_text config.name as logo_alt_text %}
104109
<div class="logo__desktop">{% logo src=config.logo.file.url alt="Homepage "|add:logo_alt_text svg_height=75 %}</div>
105110

106-
{% primary_navigation categories=categories request=request has_general_faq_questions=has_general_faq_questions cms_apps=cms_apps show_plans=show_plans %}
111+
{% include "components/Header/PrimaryNavigation.html" %}
107112

108113
{% if cms_apps.products %}
109-
<nav class="header__actions" aria-label="Zoek navigatie desktop">
110-
{% url 'search:search' as search_url %}
111-
{% render_form form=search_form method="GET" form_action=search_url inline=True spaceless=True %}
112-
{% input search_form.query no_label=True %}
113-
{% form_actions primary_icon="search" primary_text=_("Zoeken") hide_primary_text=True %}
114-
{% endrender_form %}
115-
</nav>
114+
{% if request.user.is_authenticated or not config.hide_search_from_anonymous_users %}
115+
<nav class="header__actions" aria-label="Zoek navigatie desktop">
116+
{% url 'search:search' as search_url %}
117+
{% render_form form=search_form method="GET" form_action=search_url inline=True spaceless=True %}
118+
{% input search_form.query no_label=True %}
119+
{% form_actions primary_icon="search" primary_text=_("Zoeken") hide_primary_text=True %}
120+
{% endrender_form %}
121+
</nav>
122+
{% endif %}
116123
{% endif %}
117124

118-
{% navigation_authenticated categories=categories request=request has_general_faq_questions=has_general_faq_questions %}
125+
{% include "components/Header/NavigationAuthenticated.html" %}
119126
</div>
120127
</header>
121128

122129
{% if cms_apps.products %}
123-
<section class="search search__mobile">
124-
<nav class="search__actions " aria-label="Zoek navigatie mobiel">
125-
{% url 'search:search' as search_url %}
126-
{% render_form form=search_form method="GET" form_action=search_url inline=True spaceless=False %}
127-
{% input search_form.query no_label=True %}
128-
{% form_actions primary_icon="search" primary_text=_("Zoeken") hide_primary_text=True %}
129-
{% endrender_form %}
130-
</nav>
131-
</section>
130+
{% if request.user.is_authenticated or not config.hide_search_from_anonymous_users %}
131+
<section class="search search__mobile">
132+
<nav class="search__actions " aria-label="Zoek navigatie mobiel">
133+
{% url 'search:search' as search_url %}
134+
{% render_form form=search_form method="GET" form_action=search_url inline=True spaceless=False %}
135+
{% input search_form.query no_label=True %}
136+
{% form_actions primary_icon="search" primary_text=_("Zoeken") hide_primary_text=True %}
137+
{% endrender_form %}
138+
</nav>
139+
</section>
140+
{% endif %}
132141
{% endif %}

src/open_inwoner/components/templates/components/Header/PrimaryNavigation.html

+12-13
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,21 @@
44

55
<nav class="primary-navigation primary-navigation__main" aria-label="Hoofd navigatie">
66
<ul class="primary-navigation__list">
7-
87
{% if cms_apps.products and categories %}
9-
<li class="primary-navigation__list-item">
10-
{% button text=_('Onderwerpen') type="button" icon="expand_more" icon_position="after" icon_outlined=True transparent=True extra_classes="primary-navigation--toggle" %}
8+
{% if request.user.is_authenticated or not config.hide_categories_from_anonymous_users %}
9+
<li class="primary-navigation__list-item">
10+
{% button text=_('Onderwerpen') type="button" icon="expand_more" icon_position="after" icon_outlined=True transparent=True extra_classes="primary-navigation--toggle" %}
1111

12-
{% if categories %}
13-
<ul class="primary-navigation__list subpage-list">
14-
{% for category in categories %}
15-
<li class="primary-navigation__list-item">
16-
{% url 'products:category_detail' slug=category.slug as category_href %}
17-
{% link text=category.name href=category_href %}
18-
</li>
19-
{% endfor %}
20-
</ul>
12+
<ul class="primary-navigation__list subpage-list">
13+
{% for category in categories %}
14+
<li class="primary-navigation__list-item">
15+
{% url 'products:category_detail' slug=category.slug as category_href %}
16+
{% link text=category.name href=category_href %}
17+
</li>
18+
{% endfor %}
19+
</ul>
20+
</li>
2121
{% endif %}
22-
</li>
2322
{% endif %}
2423
</ul>
2524
</nav>

src/open_inwoner/components/templatetags/header_tags.py

-46
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from django import template
22

33
from open_inwoner.configurations.models import SiteConfiguration
4-
from open_inwoner.questionnaire.models import QuestionnaireStep
54

65
register = template.Library()
76

@@ -38,51 +37,6 @@ def header(categories, request, **kwargs):
3837
+ request: Request | the django request object.
3938
- has_general_faq_questions: boolean | If the FAQ menu item should be shown.
4039
"""
41-
return {
42-
**kwargs,
43-
"categories": categories,
44-
"request": request,
45-
}
46-
47-
48-
@register.inclusion_tag("components/Header/PrimaryNavigation.html")
49-
def primary_navigation(categories, request, **kwargs):
50-
"""
51-
Displaying the primary navigation
52-
53-
Usage:
54-
{% primary_navigation categories=Category.objects.all request=request %}
55-
56-
Variables:
57-
+ categories: Category[] | The categories that should be displayed in the theme dropdown.
58-
+ request: Request | The django request object.
59-
+ questionnaire: QuestionnaireStep | The default QuestionnaireStep, if any.
60-
- has_general_faq_questions: boolean | If the FAQ menu item should be shown.
61-
- show_plans: boolean | If the Plan item should be shown.
62-
"""
63-
64-
return {
65-
**kwargs,
66-
"categories": categories,
67-
"request": request,
68-
}
69-
70-
71-
@register.inclusion_tag("components/Header/NavigationAuthenticated.html")
72-
def navigation_authenticated(categories, request, **kwargs):
73-
"""
74-
Displaying the desktop navigation when user is authenticated
75-
76-
Usage:
77-
{% navigation_authenticated categories=Category.objects.all request=request %}
78-
79-
Variables:
80-
+ categories: Category[] | The categories that should be displayed in the theme dropdown.
81-
+ request: Request | The django request object.
82-
+ questionnaire: QuestionnaireStep | The default QuestionnaireStep, if any.
83-
- has_general_faq_questions: boolean | If the FAQ menu item should be shown.
84-
- show_plans: boolean | If the Plan item should be shown.
85-
"""
8640

8741
return {
8842
**kwargs,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
from django.test import TestCase
2+
3+
from pyquery import PyQuery
4+
5+
from open_inwoner.accounts.tests.factories import UserFactory
6+
from open_inwoner.cms.products.cms_apps import ProductsApphook
7+
from open_inwoner.cms.tests import cms_tools
8+
from open_inwoner.cms.tests.cms_tools import create_apphook_page
9+
from open_inwoner.configurations.models import SiteConfiguration
10+
from open_inwoner.pdc.tests.factories import CategoryFactory
11+
12+
13+
class HeaderTest(TestCase):
14+
@classmethod
15+
def setUpTestData(cls):
16+
cls.user = UserFactory()
17+
cls.user.set_password("12345")
18+
cls.user.email = "[email protected]"
19+
cls.user.save()
20+
21+
cms_tools.create_homepage()
22+
23+
# PrimaryNavigation.html requires apphook + categories
24+
create_apphook_page(ProductsApphook)
25+
cls.published1 = CategoryFactory(
26+
path="0001", name="First one", slug="first-one"
27+
)
28+
cls.published2 = CategoryFactory(
29+
path="0002", name="Second one", slug="second-one"
30+
)
31+
32+
def test_categories_hidden_from_anonymous_users(self):
33+
config = SiteConfiguration.get_solo()
34+
config.hide_categories_from_anonymous_users = True
35+
config.save()
36+
37+
response = self.client.get("/")
38+
39+
doc = PyQuery(response.content)
40+
41+
categories = doc.find("[title='Onderwerpen']")
42+
self.assertEqual(len(categories), 0)
43+
44+
def test_categories_not_hidden_from_anonymous_users(self):
45+
config = SiteConfiguration.get_solo()
46+
config.hide_categories_from_anonymous_users = False
47+
config.save()
48+
49+
response = self.client.get("/")
50+
51+
doc = PyQuery(response.content)
52+
53+
categories = doc.find("[title='Onderwerpen']")
54+
self.assertEqual(len(categories), 2)
55+
self.assertEqual(categories[0].tag, "a")
56+
self.assertEqual(categories[1].tag, "button")
57+
58+
def test_search_bar_hidden_from_anonymous_users(self):
59+
config = SiteConfiguration.get_solo()
60+
config.hide_search_from_anonymous_users = True
61+
config.save()
62+
63+
response = self.client.get("/")
64+
65+
doc = PyQuery(response.content)
66+
67+
search_buttons = doc.find("[title='Zoeken']")
68+
69+
self.assertEqual(len(search_buttons), 0)
70+
71+
def test_search_bar_not_hidden_from_anonymous_users(self):
72+
config = SiteConfiguration.get_solo()
73+
config.hide_search_from_anonymous_users = False
74+
config.save()
75+
76+
response = self.client.get("/")
77+
78+
doc = PyQuery(response.content)
79+
80+
search_buttons = doc.find("[title='Zoeken']")
81+
82+
for button in search_buttons:
83+
self.assertEqual(button.tag, "button")

0 commit comments

Comments
 (0)