Skip to content

Commit a049f00

Browse files
committed
[#2856] Make contact form plugin configurable via CMS
1 parent b534838 commit a049f00

File tree

3 files changed

+46
-4
lines changed

3 files changed

+46
-4
lines changed

src/open_inwoner/conf/base.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,7 @@
580580
"ProductLocationPlugin",
581581
"UserFeedPlugin",
582582
"UserAppointmentsPlugin",
583+
"ContactFormPlugin",
583584
],
584585
"text_only_plugins": ["LinkPlugin"],
585586
"name": _("Content"),
@@ -615,10 +616,6 @@
615616
"TextPlugin": ["LinkPlugin"],
616617
},
617618
},
618-
"contact_form": {
619-
"name": _("Contact form plugin"),
620-
"plugins": ["ContactFormPlugin"],
621-
},
622619
}
623620

624621
CMS_TOOLBAR_ANONYMOUS_ON = False

src/open_inwoner/openklant/cms_plugins.py

+25
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,20 @@
77
from cms.plugin_pool import plugin_pool
88

99
from open_inwoner.ckeditor5.widgets import CKEditorWidget
10+
from open_inwoner.openklant.forms import ContactForm
11+
from open_inwoner.openklant.models import OpenKlantConfig
1012

1113
#
1214
# contact form plugin
1315
#
1416

1517

1618
class ContactFormConfig(CMSPlugin):
19+
title = models.TextField(
20+
_("Title"),
21+
blank=True,
22+
help_text=_("Title of the contact form."),
23+
)
1724
description = models.TextField(
1825
_("Description"),
1926
blank=True,
@@ -26,6 +33,7 @@ class Meta:
2633
model = ContactFormConfig
2734
fields = "__all__"
2835
widgets = {
36+
"title": CKEditorWidget,
2937
"description": CKEditorWidget,
3038
}
3139

@@ -37,3 +45,20 @@ class ContactFormPlugin(CMSPluginBase):
3745
name = _("Contact form plugin")
3846
render_template = "pages/contactform/form.html"
3947
cache = False
48+
49+
fieldsets = ((None, {"fields": ("title", "description")}),)
50+
51+
def render(self, context, instance, placeholder):
52+
config = OpenKlantConfig.get_solo()
53+
context.update(
54+
{
55+
"has_form_configuration": config.has_form_configuration(),
56+
"form": ContactForm(
57+
user=context["user"], request_session=context["request"].session
58+
),
59+
"instance": instance,
60+
"title": instance.title,
61+
"description": instance.description,
62+
}
63+
)
64+
return context
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Generated by Django 4.2.16 on 2024-11-27 15:23
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("openklant", "0014_contactformconfig"),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name="contactformconfig",
15+
name="title",
16+
field=models.TextField(
17+
blank=True, help_text="Title of the contact form.", verbose_name="Title"
18+
),
19+
),
20+
]

0 commit comments

Comments
 (0)