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

[#1542] Make footer contactform link conditional #685

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
@@ -1,6 +1,7 @@
{% load i18n link_tags button_tags logo_tags footer_tags solo_tags thumbnail %}

{% get_solo "configurations.SiteConfiguration" as config %}
{% get_solo "openklant.OpenKlantConfig" as ok_config %}

<footer class='footer'>
{% firstof config.logo.default_alt_text config.name as logo_alt_text %}
Expand Down Expand Up @@ -35,9 +36,11 @@ <h2 class="h2">{{footer_texts.footer_mailing_title}}</h2>

<nav class="footer__links" aria-label="Footer navigatie">
<ul class="footer__list">
<li class="footer__list-item">
{% link text=_("Contact formulier") secondary=True href="contactform" %}
</li>
{% if ok_config.has_form_configuration %}
<li class="footer__list-item">
{% link text=_("Contact formulier") secondary=True href="contactform" %}
</li>
{% endif %}
{% for flatpage in footer_texts.flatpages.all %}
<li class="footer__list-item">
{% link text=flatpage.title secondary=True href=flatpage.get_absolute_url %}
Expand Down
36 changes: 35 additions & 1 deletion src/open_inwoner/openklant/tests/test_contactform.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

from django.contrib import messages
from django.core import mail
from django.test import override_settings
from django.urls import reverse
from django.utils.translation import gettext_lazy as _
from django.utils.translation import gettext as _

import requests_mock
from django_webtest import WebTest

from open_inwoner.accounts.tests.factories import UserFactory
from open_inwoner.cms.tests import cms_tools
from open_inwoner.openklant.models import OpenKlantConfig
from open_inwoner.openklant.tests.data import MockAPICreateData
from open_inwoner.openklant.tests.factories import ContactFormSubjectFactory
Expand Down Expand Up @@ -77,6 +79,38 @@ def test_no_form_shown_if_not_has_configuration(self, m):
self.assertContains(response, _("Contact formulier niet geconfigureerd."))
self.assertEqual(0, len(response.pyquery("#contactmoment-form")))

@override_settings(ROOT_URLCONF="open_inwoner.cms.tests.urls")
def test_no_form_link_shown_in_footer_if_not_has_configuration(self, m):
# set nothing
config = OpenKlantConfig.get_solo()
self.assertFalse(config.has_form_configuration())

cms_tools.create_homepage()

response = self.app.get(reverse("pages-root"))
links = response.pyquery(".footer__list-item")

self.assertEqual(len(links), 0)

@override_settings(ROOT_URLCONF="open_inwoner.cms.tests.urls")
def test_form_link_is_shown_in_footer_when_has_configuration(self, m):
ok_config = OpenKlantConfig.get_solo()
self.assertFalse(ok_config.has_form_configuration())

ContactFormSubjectFactory(config=ok_config)

ok_config.register_email = "example@example.com"
ok_config.save()

self.assertTrue(ok_config.has_form_configuration())

cms_tools.create_homepage()

response = self.app.get(reverse("pages-root"))
links = response.pyquery(".footer__list-item")

self.assertIn(_("Contact formulier"), links[0].text_content())

def test_anon_form_requires_either_email_or_phonenumber(self, m):
config = OpenKlantConfig.get_solo()
config.register_email = "example@example.com"
Expand Down