diff --git a/.vscode/settings.json b/.vscode/settings.json index 839b1bed5e..5d2307f6d7 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,6 +2,7 @@ "makefile.extensionOutputFolder": "./.vscode", "cSpell.words": [ "Anymail", + "cookieconsent", "coreutils", "modelcluster", "pagedown", diff --git a/hypha/cookieconsent/migrations/0002_remove_cookieconsentsettings_site_and_more.py b/hypha/cookieconsent/migrations/0002_remove_cookieconsentsettings_site_and_more.py new file mode 100644 index 0000000000..e0ddc29cbd --- /dev/null +++ b/hypha/cookieconsent/migrations/0002_remove_cookieconsentsettings_site_and_more.py @@ -0,0 +1,41 @@ +# Generated by Django 4.2.9 on 2024-01-11 14:38 + +from django.db import migrations, models +import wagtail.fields + + +class Migration(migrations.Migration): + dependencies = [ + ("cookieconsent", "0001_initial"), + ] + + operations = [ + migrations.RemoveField( + model_name="cookieconsentsettings", + name="site", + ), + migrations.AlterField( + model_name="cookieconsentsettings", + name="cookieconsent_active", + field=models.BooleanField( + default=False, verbose_name="Activate cookie consent feature" + ), + ), + migrations.AlterField( + model_name="cookieconsentsettings", + name="cookieconsent_message", + field=wagtail.fields.RichTextField( + default='<p>This website deploys cookies for basic functionality and to keep it secure. These cookies are strictly necessary. Optional analysis cookies which provide us with statistical information about the use of the website may also be deployed, but only with your consent. Please review our <a href="/data-privacy-policy/">Privacy & Data Policy</a> for more information.</p>', + verbose_name="cookie consent message", + ), + ), + migrations.AlterField( + model_name="cookieconsentsettings", + name="cookieconsent_title", + field=models.CharField( + default="Your cookie settings", + max_length=255, + verbose_name="cookie consent title", + ), + ), + ] diff --git a/hypha/cookieconsent/models.py b/hypha/cookieconsent/models.py index 60708c6742..d700d4a050 100644 --- a/hypha/cookieconsent/models.py +++ b/hypha/cookieconsent/models.py @@ -1,29 +1,27 @@ from django.db import models from wagtail.admin.panels import FieldPanel, MultiFieldPanel -from wagtail.contrib.settings.models import BaseSiteSetting +from wagtail.contrib.settings.models import BaseGenericSetting, register_setting from wagtail.fields import RichTextField -from hypha.core.wagtail.admin.registry import register_public_site_setting - -@register_public_site_setting -class CookieConsentSettings(BaseSiteSetting): +@register_setting +class CookieConsentSettings(BaseGenericSetting): class Meta: verbose_name = "Cookie consent settings" cookieconsent_active = models.BooleanField( - "Activate cookie concent feature", + "Activate cookie consent feature", default=False, ) cookieconsent_title = models.CharField( - "cookie concent title", + "cookie consent title", max_length=255, default="Your cookie settings", ) cookieconsent_message = RichTextField( - "cookie concent message", + "cookie consent message", default='<p>This website deploys cookies for basic functionality and to keep it secure. These cookies are strictly necessary. Optional analysis cookies which provide us with statistical information about the use of the website may also be deployed, but only with your consent. Please review our <a href="/data-privacy-policy/">Privacy & Data Policy</a> for more information.</p>', ) diff --git a/hypha/cookieconsent/templatetags/cookieconsent_tags.py b/hypha/cookieconsent/templatetags/cookieconsent_tags.py index 6b9960f64e..2c58000cc3 100644 --- a/hypha/cookieconsent/templatetags/cookieconsent_tags.py +++ b/hypha/cookieconsent/templatetags/cookieconsent_tags.py @@ -1,5 +1,4 @@ from django import template -from wagtail.models import Site from ..models import CookieConsentSettings @@ -9,15 +8,13 @@ @register.inclusion_tag("includes/banner.html", takes_context=True) def cookie_banner(context): request = context["request"] - site = Site.find_for_request(request) - cookieconsent_settings = CookieConsentSettings.for_site(site=site) - show_banner = ( - cookieconsent_settings.cookieconsent_active - and not request.COOKIES.get("cookieconsent") + settings = CookieConsentSettings.load(request_or_site=request) + show_banner = settings.cookieconsent_active and not request.COOKIES.get( + "cookieconsent" ) return { "show_banner": show_banner, - "title": cookieconsent_settings.cookieconsent_title, - "message": cookieconsent_settings.cookieconsent_message, + "title": settings.cookieconsent_title, + "message": settings.cookieconsent_message, } diff --git a/hypha/core/wagtail_hooks.py b/hypha/core/wagtail_hooks.py deleted file mode 100644 index 4a16b4bda8..0000000000 --- a/hypha/core/wagtail_hooks.py +++ /dev/null @@ -1,16 +0,0 @@ -from django.utils.translation import gettext_lazy as _ -from wagtail import hooks -from wagtail.admin.menu import Menu -from wagtail.admin.wagtail_hooks import SettingsMenuItem - -public_site_settings_menu = Menu( - register_hook_name="register_public_site_setting_menu_item", - construct_hook_name="construct_public_site_settings_menu", -) - - -@hooks.register("register_admin_menu_item") -def register_public_site_settings_menu(): - return SettingsMenuItem( - _("Public Site"), public_site_settings_menu, icon_name="list-ul", order=9999 - ) diff --git a/hypha/static_src/src/sass/apply/components/_button.scss b/hypha/static_src/src/sass/apply/components/_button.scss index 9c066c7c8e..e570c873cd 100644 --- a/hypha/static_src/src/sass/apply/components/_button.scss +++ b/hypha/static_src/src/sass/apply/components/_button.scss @@ -98,6 +98,7 @@ &--cookieconsent { @include button(transparent, $color--white); + display: inline; &:focus, &:hover { diff --git a/hypha/static_src/src/sass/apply/components/_wrapper.scss b/hypha/static_src/src/sass/apply/components/_wrapper.scss index e46a364ea9..8aab2cb2de 100644 --- a/hypha/static_src/src/sass/apply/components/_wrapper.scss +++ b/hypha/static_src/src/sass/apply/components/_wrapper.scss @@ -313,6 +313,6 @@ &--cookieconsent { padding: 40px 20px; - z-index: 10; + z-index: 20; } }