7
7
from cms .plugin_pool import plugin_pool
8
8
9
9
from open_inwoner .ckeditor5 .widgets import CKEditorWidget
10
+ from open_inwoner .openklant .forms import ContactForm
11
+ from open_inwoner .openklant .models import OpenKlantConfig
10
12
11
13
#
12
14
# contact form plugin
13
15
#
14
16
15
17
16
18
class ContactFormConfig (CMSPlugin ):
19
+ title = models .TextField (
20
+ _ ("Title" ),
21
+ blank = True ,
22
+ help_text = _ ("Title of the contact form." ),
23
+ )
17
24
description = models .TextField (
18
25
_ ("Description" ),
19
26
blank = True ,
@@ -26,6 +33,7 @@ class Meta:
26
33
model = ContactFormConfig
27
34
fields = "__all__"
28
35
widgets = {
36
+ "title" : CKEditorWidget ,
29
37
"description" : CKEditorWidget ,
30
38
}
31
39
@@ -37,3 +45,26 @@ class ContactFormPlugin(CMSPluginBase):
37
45
name = _ ("Contact form plugin" )
38
46
render_template = "pages/contactform/form.html"
39
47
cache = False
48
+
49
+ fieldsets = ((None , {"fields" : ("title" , "description" )}),)
50
+
51
+ # def get_render_template(self, context, instance, placeholder):
52
+ # request = context["request"]
53
+ # if request.path == "/contactform/":
54
+ # return "pages/contactform/form.html"
55
+ # return ""
56
+
57
+ def render (self , context , instance , placeholder ):
58
+ config = OpenKlantConfig .get_solo ()
59
+ context .update (
60
+ {
61
+ "has_form_configuration" : config .has_form_configuration (),
62
+ "form" : ContactForm (
63
+ user = context ["user" ], request_session = context ["request" ].session
64
+ ),
65
+ "instance" : instance ,
66
+ "title" : instance .title ,
67
+ "description" : instance .description ,
68
+ }
69
+ )
70
+ return context
0 commit comments