From 57b8a7c0e5a40eeb4d1836d171f6aabe8c907adb Mon Sep 17 00:00:00 2001 From: Paul Schilling Date: Tue, 12 Dec 2023 17:04:47 +0100 Subject: [PATCH] [#1914] Check if SSD page is published before accessing on profile page --- src/open_inwoner/accounts/views/profile.py | 6 ++++- src/open_inwoner/cms/profile/cms_appconfig.py | 7 +++++- .../0006_alter_profileconfig_ssd.py | 22 +++++++++++++++++++ src/open_inwoner/cms/utils/page_display.py | 9 ++++++++ .../templates/pages/profile/me.html | 8 +++---- 5 files changed, 46 insertions(+), 6 deletions(-) create mode 100644 src/open_inwoner/cms/profile/migrations/0006_alter_profileconfig_ssd.py diff --git a/src/open_inwoner/accounts/views/profile.py b/src/open_inwoner/accounts/views/profile.py index c721f6385c..99d5c21c08 100644 --- a/src/open_inwoner/accounts/views/profile.py +++ b/src/open_inwoner/accounts/views/profile.py @@ -22,7 +22,10 @@ LoginTypeChoices, StatusChoices, ) -from open_inwoner.cms.utils.page_display import inbox_page_is_published +from open_inwoner.cms.utils.page_display import ( + benefits_page_is_published, + inbox_page_is_published, +) from open_inwoner.haalcentraal.utils import fetch_brp from open_inwoner.plans.models import Plan from open_inwoner.questionnaire.models import QuestionnaireStep @@ -126,6 +129,7 @@ def get_context_data(self, **kwargs): LoginTypeChoices.eherkenning, ) context["inbox_page_is_published"] = inbox_page_is_published() + context["benefits_page_is_published"] = benefits_page_is_published() return context diff --git a/src/open_inwoner/cms/profile/cms_appconfig.py b/src/open_inwoner/cms/profile/cms_appconfig.py index d219695f37..ab674f13c7 100644 --- a/src/open_inwoner/cms/profile/cms_appconfig.py +++ b/src/open_inwoner/cms/profile/cms_appconfig.py @@ -47,5 +47,10 @@ class ProfileConfig(AppHookConfig): ) ssd = models.BooleanField( verbose_name=_("Mijn uitkeringen"), - default=True, + default=False, + help_text=_( + "Designates whether the 'Mijn uitkeringen' section is rendered or not. " + "Should only be enabled if a CMS app has been created and the corresponding " + "CMS page has been published." + ), ) diff --git a/src/open_inwoner/cms/profile/migrations/0006_alter_profileconfig_ssd.py b/src/open_inwoner/cms/profile/migrations/0006_alter_profileconfig_ssd.py new file mode 100644 index 0000000000..41a7069e3e --- /dev/null +++ b/src/open_inwoner/cms/profile/migrations/0006_alter_profileconfig_ssd.py @@ -0,0 +1,22 @@ +# Generated by Django 3.2.23 on 2023-12-13 09:23 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("profile", "0005_remove_profileconfig_selected_categories"), + ] + + operations = [ + migrations.AlterField( + model_name="profileconfig", + name="ssd", + field=models.BooleanField( + default=False, + help_text="Designates whether the 'Mijn uitkeringen' section is rendered or not. Should only be enabled if a CMS app has been created and the corresponding CMS page has been published.", + verbose_name="Mijn uitkeringen", + ), + ), + ] diff --git a/src/open_inwoner/cms/utils/page_display.py b/src/open_inwoner/cms/utils/page_display.py index 2a18b3abc5..de37847f43 100644 --- a/src/open_inwoner/cms/utils/page_display.py +++ b/src/open_inwoner/cms/utils/page_display.py @@ -3,6 +3,7 @@ from cms.models import Page +from open_inwoner.cms.benefits.cms_apps import SSDApphook from open_inwoner.cms.cases.cms_apps import CasesApphook from open_inwoner.cms.collaborate.cms_apps import CollaborateApphook from open_inwoner.cms.inbox.cms_apps import InboxApphook @@ -11,6 +12,7 @@ "inbox": InboxApphook, "collaborate": CollaborateApphook, "cases": CasesApphook, + "ssd": SSDApphook, } @@ -43,3 +45,10 @@ def collaborate_page_is_published() -> bool: :returns: True if the collaborate page published, False otherwise """ return _is_published("collaborate") + + +def benefits_page_is_published() -> bool: + """ + :returns: True if the social benefits page published, False otherwise + """ + return _is_published("ssd") diff --git a/src/open_inwoner/templates/pages/profile/me.html b/src/open_inwoner/templates/pages/profile/me.html index 17a96b1569..c75451539f 100644 --- a/src/open_inwoner/templates/pages/profile/me.html +++ b/src/open_inwoner/templates/pages/profile/me.html @@ -163,9 +163,9 @@

{% trans "Overzicht" %}< {% endrender_column %} {% endif %} {# Benefits #} - {% if view.config.ssd %} + {% if view.config.ssd and benefits_page_is_published %} {% render_column start=forloop.counter_0|multiply:4 span=4 %} -