Skip to content

Commit

Permalink
Merge branch 'develop' into feature/1378-mobile-header-navigation-no-…
Browse files Browse the repository at this point in the history
…hamburger
  • Loading branch information
jiromaykin authored May 11, 2023
2 parents 45fdabf + 325d753 commit c80f731
Show file tree
Hide file tree
Showing 37 changed files with 565 additions and 646 deletions.
1 change: 1 addition & 0 deletions requirements/base.in
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ djangocms-picture
# djangocms-googlemap
# djangocms-snippet
# djangocms-style
aldryn-apphooks-config

# API libraries
djangorestframework
Expand Down
7 changes: 7 additions & 0 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#
# ./bin/compile_dependencies.sh
#
aldryn-apphooks-config==0.6.0
# via -r requirements/base.in
amqp==5.1.1
# via kombu
asgiref==3.4.1
Expand Down Expand Up @@ -72,6 +74,7 @@ django==3.2.15
# via
# -r requirements/base.in
# django-appconf
# django-appdata
# django-axes
# django-choices
# django-classy-tags
Expand Down Expand Up @@ -120,6 +123,8 @@ django-appconf==1.0.5
# via
# django-image-cropping
# django-timeline-logger
django-appdata==0.3.2
# via aldryn-apphooks-config
django-autoslug==1.9.8
# via -r requirements/base.in
django-axes==5.25.0
Expand All @@ -142,6 +147,7 @@ django-classy-tags==4.0.0
django-cms==3.11.1
# via
# -r requirements/base.in
# aldryn-apphooks-config
# djangocms-attributes-field
# djangocms-file
# djangocms-link
Expand Down Expand Up @@ -453,6 +459,7 @@ simplejson==3.18.0
six==1.16.0
# via
# click-repl
# django-appdata
# django-choices
# django-elasticsearch-dsl
# elasticsearch-dsl
Expand Down
12 changes: 12 additions & 0 deletions requirements/ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
#
# ./bin/compile_dependencies.sh
#
aldryn-apphooks-config==0.6.0
# via
# -c requirements/base.txt
# -r requirements/base.txt
amqp==5.1.1
# via
# -c requirements/base.txt
Expand Down Expand Up @@ -131,6 +135,7 @@ django==3.2.15
# -c requirements/base.txt
# -r requirements/base.txt
# django-appconf
# django-appdata
# django-axes
# django-choices
# django-classy-tags
Expand Down Expand Up @@ -183,6 +188,11 @@ django-appconf==1.0.5
# -r requirements/base.txt
# django-image-cropping
# django-timeline-logger
django-appdata==0.3.2
# via
# -c requirements/base.txt
# -r requirements/base.txt
# aldryn-apphooks-config
django-autoslug==1.9.8
# via
# -c requirements/base.txt
Expand Down Expand Up @@ -217,6 +227,7 @@ django-cms==3.11.1
# via
# -c requirements/base.txt
# -r requirements/base.txt
# aldryn-apphooks-config
# djangocms-attributes-field
# djangocms-file
# djangocms-link
Expand Down Expand Up @@ -816,6 +827,7 @@ six==1.16.0
# -c requirements/base.txt
# -r requirements/base.txt
# click-repl
# django-appdata
# django-choices
# django-elasticsearch-dsl
# elasticsearch-dsl
Expand Down
12 changes: 12 additions & 0 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
#
alabaster==0.7.12
# via sphinx
aldryn-apphooks-config==0.6.0
# via
# -c requirements/ci.txt
# -r requirements/ci.txt
amqp==5.1.1
# via
# -c requirements/ci.txt
Expand Down Expand Up @@ -154,6 +158,7 @@ django==3.2.15
# -r requirements/ci.txt
# ddt-api-calls
# django-appconf
# django-appdata
# django-axes
# django-choices
# django-classy-tags
Expand Down Expand Up @@ -208,6 +213,11 @@ django-appconf==1.0.5
# -r requirements/ci.txt
# django-image-cropping
# django-timeline-logger
django-appdata==0.3.2
# via
# -c requirements/ci.txt
# -r requirements/ci.txt
# aldryn-apphooks-config
django-autoslug==1.9.8
# via
# -c requirements/ci.txt
Expand Down Expand Up @@ -242,6 +252,7 @@ django-cms==3.11.1
# via
# -c requirements/ci.txt
# -r requirements/ci.txt
# aldryn-apphooks-config
# djangocms-attributes-field
# djangocms-file
# djangocms-link
Expand Down Expand Up @@ -909,6 +920,7 @@ six==1.16.0
# -c requirements/ci.txt
# -r requirements/ci.txt
# click-repl
# django-appdata
# django-choices
# django-elasticsearch-dsl
# elasticsearch-dsl
Expand Down
14 changes: 14 additions & 0 deletions src/open_inwoner/accounts/tests/test_profile_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
from django.utils.translation import ugettext_lazy as _

import requests_mock
from cms import api
from django_webtest import WebTest
from PIL import Image
from timeline_logger.models import TimelineLog
from webtest import Upload

from open_inwoner.accounts.choices import StatusChoices
from open_inwoner.cms.profile.cms_appconfig import ProfileConfig
from open_inwoner.haalcentraal.tests.mixins import HaalCentraalMixin
from open_inwoner.pdc.tests.factories import CategoryFactory
from open_inwoner.utils.logentry import LOG_ACTIONS
Expand All @@ -35,6 +37,17 @@ def setUp(self):
status=StatusChoices.open,
)

# cms profile apphook configuration
self.profile_app = ProfileConfig.objects.create(namespace="profile")
api.create_page(
"profile",
"INHERIT",
"nl",
published=True,
apphook="ProfileApphook",
apphook_namespace=self.profile_app.namespace,
)

def test_login_required(self):
login_url = reverse("login")
response = self.app.get(self.url)
Expand All @@ -56,6 +69,7 @@ def test_get_empty_profile_page(self):
self.assertContains(response, _("U heeft nog geen contacten."))
self.assertContains(response, "0 acties staan open.")
self.assertNotContains(response, reverse("products:questionnaire_list"))
self.assertContains(response, _("messages, plans"))

def test_get_filled_profile_page(self):
ActionFactory(created_by=self.user)
Expand Down
20 changes: 16 additions & 4 deletions src/open_inwoner/accounts/views/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@
from django.views.generic.detail import SingleObjectMixin
from django.views.generic.edit import DeletionMixin, UpdateView

from aldryn_apphooks_config.mixins import AppConfigMixin
from aldryn_apphooks_config.utils import get_app_instance
from cms.models import Page
from privates.views import PrivateMediaView
from view_breadcrumbs import BaseBreadcrumbMixin

from open_inwoner.cms.collaborate.cms_apps import CollaborateApphook
from open_inwoner.components.utils import RenderableTag
from open_inwoner.configurations.models import SiteConfiguration
from open_inwoner.htmx.views import HtmxTemplateTagModelFormView
from open_inwoner.utils.logentry import get_verbose_change_message
from open_inwoner.utils.mixins import ExportMixin
Expand All @@ -26,11 +29,14 @@
from ..models import Action


class ActionsEnabledMixin:
class ActionsEnabledMixin(AppConfigMixin):
def dispatch(self, request, *args, **kwargs):
config = SiteConfiguration.get_solo()
if not config.show_actions:
self.namespace, self.config = get_app_instance(request)
request.current_app = self.namespace

if self.config and not self.config.actions:
raise Http404("actions not enabled")

return super().dispatch(request, *args, **kwargs)


Expand Down Expand Up @@ -89,6 +95,12 @@ def get_context_data(self, **kwargs):
context["page_obj"] = page
context["is_paginated"] = is_paginated
context["actions"] = queryset
context["show_plans"] = (
Page.objects.published()
.filter(application_namespace=CollaborateApphook.app_name)
.exists()
)

return context


Expand Down
8 changes: 7 additions & 1 deletion src/open_inwoner/accounts/views/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from django.utils.translation import gettext as _
from django.views.generic import DetailView, FormView, TemplateView, UpdateView

from aldryn_apphooks_config.mixins import AppConfigMixin
from glom import glom
from view_breadcrumbs import BaseBreadcrumbMixin

Expand All @@ -29,7 +30,12 @@


class MyProfileView(
LogMixin, LoginRequiredMixin, CommonPageMixin, BaseBreadcrumbMixin, FormView
LogMixin,
LoginRequiredMixin,
CommonPageMixin,
BaseBreadcrumbMixin,
AppConfigMixin,
FormView,
):
template_name = "pages/profile/me.html"
form_class = Form
Expand Down
19 changes: 19 additions & 0 deletions src/open_inwoner/cms/profile/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from django.contrib import admin

from aldryn_apphooks_config.admin import BaseAppHookConfig

from .cms_appconfig import ProfileConfig


@admin.register(ProfileConfig)
class ProfileConfigAdmin(BaseAppHookConfig, admin.ModelAdmin):
def get_config_fields(self):
return (
"my_data",
"selected_categories",
"mentors",
"my_contacts",
"selfdiagnose",
"actions",
"notifications",
)
49 changes: 49 additions & 0 deletions src/open_inwoner/cms/profile/cms_appconfig.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
from django.db import models
from django.utils.translation import gettext_lazy as _

from aldryn_apphooks_config.models import AppHookConfig


class ProfileConfig(AppHookConfig):
my_data = models.BooleanField(
verbose_name=_("Mijn gegevens"),
default=True,
help_text=_(
"Designates whether 'My data' section is rendered or not (Only for digid users)."
),
)
selected_categories = models.BooleanField(
verbose_name=_("Interessegebieden"),
default=True,
help_text=_(
"Designates whether 'selected categories' section is rendered or not."
),
)
mentors = models.BooleanField(
verbose_name=_("Begeleiders"),
default=True,
help_text=_("Designates whether 'mentors' section is rendered or not."),
)
my_contacts = models.BooleanField(
verbose_name=_("Mijn netwerkcontacten"),
default=True,
help_text=_("Designates whether 'contacts' section is rendered or not."),
)
selfdiagnose = models.BooleanField(
verbose_name=_("Zelfdiagnose"),
default=True,
help_text=_("Designates whether 'self diagnose' section is rendered or not."),
)
actions = models.BooleanField(
verbose_name=_("Acties"),
default=True,
help_text=_(
"Designates whether 'actions' section is rendered or not."
"If this is disabled, plans (page and menu) should be disabled as well."
),
)
notifications = models.BooleanField(
verbose_name=_("Communicatievoorkeuren"),
default=True,
help_text=_("Designates whether 'notifications' section is rendered or not."),
)
7 changes: 5 additions & 2 deletions src/open_inwoner/cms/profile/cms_apps.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
from django.utils.translation import gettext_lazy as _

from cms.app_base import CMSApp
from aldryn_apphooks_config.app_base import CMSConfigApp
from cms.apphook_pool import apphook_pool

from .cms_appconfig import ProfileConfig


@apphook_pool.register
class ProfileApphook(CMSApp):
class ProfileApphook(CMSConfigApp):
app_name = "profile"
name = _("Profile Application")
app_config = ProfileConfig

def get_urls(self, page=None, language=None, **kwargs):
return ["open_inwoner.cms.profile.urls"]
34 changes: 34 additions & 0 deletions src/open_inwoner/cms/profile/cms_toolbars.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from django.urls import reverse
from django.utils.translation import ugettext_lazy as _

from aldryn_apphooks_config.utils import get_app_instance
from cms.extensions.toolbar import ExtensionToolbar
from cms.toolbar_pool import toolbar_pool

from open_inwoner.cms.profile.cms_appconfig import ProfileConfig


@toolbar_pool.register
class ProfileApphookConfigToolbar(ExtensionToolbar):
model = ProfileConfig
supported_apps = ("profile",)

def populate(self):
current_page_menu = self._setup_extension_toolbar()
if current_page_menu:
self.namespace, self.config = get_app_instance(self.request)
self.request.current_app = self.namespace

if not self.config:
url = reverse("admin:profile_profileconfig_changelist")
else:
url = reverse(
"admin:profile_profileconfig_change",
kwargs={"object_id": self.config.id},
)

current_page_menu.add_modal_item(
_("Profile apphook configurations"),
url=url,
disabled=(not self.page.application_urls == "ProfileApphook"),
)
Loading

0 comments on commit c80f731

Please sign in to comment.