diff --git a/src/open_inwoner/conf/base.py b/src/open_inwoner/conf/base.py index 1f1cfda6c7..49d7c3e4e5 100644 --- a/src/open_inwoner/conf/base.py +++ b/src/open_inwoner/conf/base.py @@ -580,6 +580,7 @@ "ProductLocationPlugin", "UserFeedPlugin", "UserAppointmentsPlugin", + "ContactFormPlugin", ], "text_only_plugins": ["LinkPlugin"], "name": _("Content"), @@ -615,10 +616,6 @@ "TextPlugin": ["LinkPlugin"], }, }, - "contact_form": { - "name": _("Contact form plugin"), - "plugins": ["ContactFormPlugin"], - }, } CMS_TOOLBAR_ANONYMOUS_ON = False diff --git a/src/open_inwoner/openklant/cms_plugins.py b/src/open_inwoner/openklant/cms_plugins.py index a229f9ad8d..44c778c155 100644 --- a/src/open_inwoner/openklant/cms_plugins.py +++ b/src/open_inwoner/openklant/cms_plugins.py @@ -7,6 +7,8 @@ from cms.plugin_pool import plugin_pool from open_inwoner.ckeditor5.widgets import CKEditorWidget +from open_inwoner.openklant.forms import ContactForm +from open_inwoner.openklant.models import OpenKlantConfig # # contact form plugin @@ -14,6 +16,11 @@ class ContactFormConfig(CMSPlugin): + title = models.TextField( + _("Title"), + blank=True, + help_text=_("Title of the contact form."), + ) description = models.TextField( _("Description"), blank=True, @@ -26,6 +33,7 @@ class Meta: model = ContactFormConfig fields = "__all__" widgets = { + "title": CKEditorWidget, "description": CKEditorWidget, } @@ -37,3 +45,20 @@ class ContactFormPlugin(CMSPluginBase): name = _("Contact form plugin") render_template = "pages/contactform/form.html" cache = False + + fieldsets = ((None, {"fields": ("title", "description")}),) + + def render(self, context, instance, placeholder): + config = OpenKlantConfig.get_solo() + context.update( + { + "has_form_configuration": config.has_form_configuration(), + "form": ContactForm( + user=context["user"], request_session=context["request"].session + ), + "instance": instance, + "title": instance.title, + "description": instance.description, + } + ) + return context diff --git a/src/open_inwoner/openklant/migrations/0015_contactformconfig_title.py b/src/open_inwoner/openklant/migrations/0015_contactformconfig_title.py new file mode 100644 index 0000000000..ddb8060e8d --- /dev/null +++ b/src/open_inwoner/openklant/migrations/0015_contactformconfig_title.py @@ -0,0 +1,20 @@ +# Generated by Django 4.2.16 on 2024-11-27 15:23 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("openklant", "0014_contactformconfig"), + ] + + operations = [ + migrations.AddField( + model_name="contactformconfig", + name="title", + field=models.TextField( + blank=True, help_text="Title of the contact form.", verbose_name="Title" + ), + ), + ]