11 # |
11 # |
12 |
12 |
13 from zope.annotation.interfaces import IAttributeAnnotatable |
13 from zope.annotation.interfaces import IAttributeAnnotatable |
14 from zope.container.constraints import containers, contains |
14 from zope.container.constraints import containers, contains |
15 from zope.container.interfaces import IContained, IContainer |
15 from zope.container.interfaces import IContained, IContainer |
16 from zope.interface import Attribute, Interface |
16 from zope.interface import Attribute, Interface, invariant |
17 from zope.schema import Bool, Choice, TextLine |
17 from zope.interface.interfaces import Invalid |
|
18 from zope.schema import Bool, Choice, TextLine, Int, Password |
18 |
19 |
19 from pyams_content.component.paragraph import IBaseParagraph |
20 from pyams_content.component.paragraph import IBaseParagraph |
20 from pyams_content.shared.common.interfaces import ISharedContent, ISharedToolPortalContext, \ |
21 from pyams_content.shared.common.interfaces import ISharedContent, ISharedToolPortalContext, \ |
21 IWfSharedContentPortalContext |
22 IWfSharedContentPortalContext |
22 from pyams_i18n.schema import I18nHTMLField, I18nTextField, I18nTextLineField |
23 from pyams_i18n.schema import I18nHTMLField, I18nTextField, I18nTextLineField |
35 |
36 |
36 |
37 |
37 class IFormsManager(ISharedToolPortalContext): |
38 class IFormsManager(ISharedToolPortalContext): |
38 """Forms manager interface""" |
39 """Forms manager interface""" |
39 |
40 |
|
41 use_captcha = Bool(title=_("Use captcha?"), |
|
42 description=_("Set default captcha settings"), |
|
43 required=True, |
|
44 default=False) |
|
45 |
|
46 default_captcha_client_key = TextLine(title=_("Default captcha site key"), |
|
47 description=_("This key is included into HTML code and " |
|
48 "submitted with form data"), |
|
49 required=False) |
|
50 |
|
51 default_captcha_server_key = TextLine(title=_("Default captcha secret key"), |
|
52 description=_("This key is used to communicate with " |
|
53 "Google's reCaptcha services"), |
|
54 required=False) |
|
55 |
|
56 def get_captcha_settings(self): |
|
57 """Get default captcha settings""" |
|
58 |
|
59 use_proxy = Bool(title=_("Use proxy server?"), |
|
60 description=_("If a proxy server is required to access recaptcha services, " |
|
61 "please set them here"), |
|
62 required=True, |
|
63 default=False) |
|
64 |
|
65 proxy_proto = Choice(title=_("Protocol"), |
|
66 description=_("If your server is behind a proxy, please set it's " |
|
67 "protocol here; HTTPS support is required for reCaptcha"), |
|
68 required=False, |
|
69 values=('http', 'https'), |
|
70 default='http') |
|
71 |
|
72 proxy_host = TextLine(title=_("Host name"), |
|
73 description=_("If your server is behind a proxy, please set it's " |
|
74 "address here; captcha verification requires HTTPS " |
|
75 "support..."), |
|
76 required=False) |
|
77 |
|
78 proxy_port = Int(title=_("Port number"), |
|
79 description=_("If your server is behind a proxy, plase set it's port " |
|
80 "number here"), |
|
81 required=False, |
|
82 default=8080) |
|
83 |
|
84 proxy_username = TextLine(title=_("Username"), |
|
85 description=_("If your proxy server requires authentication, " |
|
86 "please set username here"), |
|
87 required=False) |
|
88 |
|
89 proxy_password = Password(title=_("Password"), |
|
90 description=_("If your proxy server requires authentication, " |
|
91 "please set password here"), |
|
92 required=False) |
|
93 |
|
94 proxy_only_from = TextLine(title=_("Use proxy only from"), |
|
95 description=_("If proxy usage is restricted to several domains " |
|
96 "names, you can set them here, separated by comas"), |
|
97 required=False) |
|
98 |
|
99 def get_proxy_url(self, request): |
|
100 """Get proxy server URL""" |
|
101 |
40 |
102 |
41 class IFormsManagerFactory(Interface): |
103 class IFormsManagerFactory(Interface): |
42 """Forms manager factory interface""" |
104 """Forms manager factory interface""" |
43 |
105 |
44 |
106 |
173 |
235 |
174 handler = Choice(title=_("Form handler"), |
236 handler = Choice(title=_("Form handler"), |
175 description=_("Select how form data is transmitted"), |
237 description=_("Select how form data is transmitted"), |
176 vocabulary='PyAMS form handlers') |
238 vocabulary='PyAMS form handlers') |
177 |
239 |
178 use_captcha = Bool(title=_("Use captcha?"), |
240 override_captcha = Bool(title=_("Override captcha settings?"), |
179 description=_("If 'yes', a captcha will be added automatically to the form"), |
241 description=_("If 'yes', you can define custom captcha keys here"), |
180 required=False, |
242 required=False, |
181 default=True) |
243 default=True) |
182 |
244 |
183 client_captcha_key = TextLine(title=_("Site key"), |
245 client_captcha_key = TextLine(title=_("Site key"), |
184 description=_("This key is included into HTML code and submitted " |
246 description=_("This key is included into HTML code and submitted " |
185 "with form data"), |
247 "with form data"), |
186 required=False) |
248 required=False) |
188 server_captcha_key = TextLine(title=_("Secret key"), |
250 server_captcha_key = TextLine(title=_("Secret key"), |
189 description=_("This key is used to communicate with Google's " |
251 description=_("This key is used to communicate with Google's " |
190 "reCaptcha services"), |
252 "reCaptcha services"), |
191 required=False) |
253 required=False) |
192 |
254 |
193 captcha_proxy = TextLine(title=_("Recaptcha proxy"), |
255 def get_captcha_settings(self): |
194 description=_("If your server is behind a proxy, please set it's " |
256 """Get form captcha settings""" |
195 "address here; captcha verification requires HTTPS " |
|
196 "support..."), |
|
197 required=False) |
|
198 |
257 |
199 rgpd_consent = Bool(title=_("Required RGPD consent?"), |
258 rgpd_consent = Bool(title=_("Required RGPD consent?"), |
200 description=_("If 'yes', an RGPD compliance warning will be displayed " |
259 description=_("If 'yes', an RGPD compliance warning will be displayed " |
201 "above form's submit button; form can't be submitted as long " |
260 "above form's submit button; form can't be submitted as long " |
202 "as the associated checkbox will not be checked explicitly " |
261 "as the associated checkbox will not be checked explicitly " |