Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#1352] Hide sidemenu ctabutton when it exists in product content #575

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,19 @@
</li>
{% endfor %}
{{ contents }}

<!-- dynamic anchor item for products -->
<div class="anchor-menu__start-inquiry">
{% if product.form %}
{% button_row mobile=True %}
{% button href=product.form_link text=_("Aanvraag starten") primary=True icon="arrow_forward" icon_position="before" %}
{% endbutton_row %}
{% elif product.link %}
{% button_row mobile=True %}
{% button href=product.link text=_("Aanvraag starten") primary=True icon="arrow_forward" icon_position="before" %}
{% endbutton_row %}
{% if '\[CTABUTTON\]' not in product.content %}
vaszig marked this conversation as resolved.
Show resolved Hide resolved
{% if product.form %}
{% button_row mobile=True %}
{% button href=product.form_link text=_("Aanvraag starten") primary=True icon="arrow_forward" icon_position="before" %}
{% endbutton_row %}
{% elif product.link %}
{% button_row mobile=True %}
{% button href=product.link text=_("Aanvraag starten") primary=True icon="arrow_forward" icon_position="before" %}
{% endbutton_row %}
{% endif %}
{% endif %}
</div>
</ul>
Expand Down
27 changes: 27 additions & 0 deletions src/open_inwoner/pdc/tests/test_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,30 @@ def test_button_is_not_rendered_inside_content_when_no_form_or_link(self):
cta_button = response.pyquery(".grid__main")[0].find_class("cta-button")

self.assertFalse(cta_button)

def test_sidemenu_button_is_not_rendered_when_cta_inside_product_content(self):
product = ProductFactory(
content="Some content \[CTABUTTON\]", link="http://www.example.com"
)

response = self.app.get(
reverse("pdc:product_detail", kwargs={"slug": product.slug})
)
sidemenu_cta_button = response.pyquery(
'.anchor-menu__list-item a[href="http://www.example.com"]'
)

self.assertFalse(sidemenu_cta_button)

def test_sidemenu_button_is_rendered_when_no_cta_inside_product_content(self):
product = ProductFactory(content="Some content", link="http://www.example.com")

response = self.app.get(
reverse("pdc:product_detail", kwargs={"slug": product.slug})
)
sidemenu_cta_button = response.pyquery(
'.anchor-menu__list-item a[href="http://www.example.com"]'
)

self.assertTrue(sidemenu_cta_button)
self.assertIn(product.link, sidemenu_cta_button[0].values())
28 changes: 10 additions & 18 deletions src/open_inwoner/templates/pages/product/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@

{% block sidebar_content %}
{% anchor_menu anchors=anchors desktop=True %}
{% if product.form %}
<li class="anchor-menu__list-item">
{% button href=product.form_link size="big" text=_("Aanvraag starten") primary=True icon="arrow_forward" icon_position="before" %}
</li>
{% elif product.link %}
<li class="anchor-menu__list-item">
{% button href=product.link size="big" text=_("Aanvraag starten") primary=True icon="arrow_forward" icon_position="before" %}
</li>
{% if '\[CTABUTTON\]' not in product.content %}
vaszig marked this conversation as resolved.
Show resolved Hide resolved
{% if product.form %}
<li class="anchor-menu__list-item">
{% button href=product.form_link size="big" text=_("Aanvraag starten") primary=True icon="arrow_forward" icon_position="before" %}
</li>
{% elif product.link %}
<li class="anchor-menu__list-item">
{% button href=product.link size="big" text=_("Aanvraag starten") primary=True icon="arrow_forward" icon_position="before" %}
</li>
{% endif %}
{% endif %}
{% endanchor_menu %}
{% endblock sidebar_content %}
Expand All @@ -34,16 +36,6 @@ <h1 class="h1" id="title">
<p class="p">{{ object.summary }}</p>
{{ object|product_ckeditor_content|safe }}

{% if product.form %}
{% button_row mobile=True %}
{% button href=product.form_link text=_("Aanvraag starten") primary=True icon="arrow_forward" icon_position="before" %}
{% endbutton_row %}
{% elif product.link %}
{% button_row mobile=True %}
{% button href=product.link text=_("Aanvraag starten") primary=True icon="arrow_forward" icon_position="before" %}
{% endbutton_row %}
{% endif %}

{% if object.question_set.exists %}
<hr class="divider">
{% faq object.question_set.all %}
Expand Down