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

[#1914] Check if SSD page is published before accessing on profile page #900

Merged
merged 1 commit into from
Dec 13, 2023
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
6 changes: 5 additions & 1 deletion src/open_inwoner/accounts/views/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
7 changes: 6 additions & 1 deletion src/open_inwoner/cms/profile/cms_appconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."
),
)
Original file line number Diff line number Diff line change
@@ -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",
),
),
]
9 changes: 9 additions & 0 deletions src/open_inwoner/cms/utils/page_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -11,6 +12,7 @@
"inbox": InboxApphook,
"collaborate": CollaborateApphook,
"cases": CasesApphook,
"ssd": SSDApphook,
}


Expand Down Expand Up @@ -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")
8 changes: 4 additions & 4 deletions src/open_inwoner/templates/pages/profile/me.html
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ <h2 class="h2 title title--extra-padding" id="overview">{% 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 %}
<div class="card card--compact card--stretch"id="profile-section-ssd">
<div class="card card--compact card--stretch" id="profile-section-ssd">
<div class="card__body">
<a href="{% url 'ssd:uitkeringen' %}" class="profile__link">
<p class="h4"><span class="link link__text">{% trans "Mijn uitkeringen" %}</span></p>
Expand All @@ -188,7 +188,7 @@ <h2 class="h2 title title--extra-padding" id="overview">{% trans "Overzicht" %}<
{# Questions #}
{% if view.config.questions %}
{% render_column start=forloop.counter_0|multiply:4 span=4 %}
<div class="card card--compact card--stretch id="profile-section-questions"">
<div class="card card--compact card--stretch" id="profile-section-questions">
<div class="card__body">
<a href="{% url 'cases:contactmoment_list' %}" class="profile__link">
<p class="h4"><span class="link link__text">{% trans "Mijn vragen" %}</span></p>
Expand All @@ -205,7 +205,7 @@ <h2 class="h2 title title--extra-padding" id="overview">{% trans "Overzicht" %}<
{# Questionnaire #}
{% if questionnaire_exists and view.config.selfdiagnose %}
{% render_column start=forloop.counter_0|multiply:4 span=4 %}
<div class="card card--compact card--stretch id="profile-section-questions"">
<div class="card card--compact card--stretch" id="profile-section-questions">
<div class="card__body">
<a href="{% url 'products:questionnaire_list' %}" class="profile__link">
<p class="h4"><span class="link link__text">{% trans "Zelftest" %}</span></p>
Expand Down