17 from pyams_content.features.checker.interfaces import ERROR_VALUE, IContentChecker |
17 from pyams_content.features.checker.interfaces import ERROR_VALUE, IContentChecker |
18 from pyams_content.features.preview.interfaces import IPreviewTarget |
18 from pyams_content.features.preview.interfaces import IPreviewTarget |
19 from pyams_content.features.review.interfaces import IReviewTarget |
19 from pyams_content.features.review.interfaces import IReviewTarget |
20 from pyams_content.shared.common import IWfSharedContentFactory, SharedContent, WfSharedContent, WfSharedContentChecker, \ |
20 from pyams_content.shared.common import IWfSharedContentFactory, SharedContent, WfSharedContent, WfSharedContentChecker, \ |
21 register_content_type |
21 register_content_type |
22 from pyams_content.shared.form.interfaces import FORM_CONTENT_NAME, FORM_CONTENT_TYPE, IForm, IFormFieldContainer, \ |
22 from pyams_content.shared.form.interfaces import FORM_CONTENT_NAME, FORM_CONTENT_TYPE, IForm, \ |
23 IFormFieldContainerTarget, IFormHandler, IWfForm, IWfFormFactory |
23 IFormFieldContainer, \ |
|
24 IFormFieldContainerTarget, IFormHandler, IWfForm, IWfFormFactory, IFormsManager |
24 from pyams_utils.adapter import adapter_config |
25 from pyams_utils.adapter import adapter_config |
25 from pyams_utils.registry import get_global_registry |
26 from pyams_utils.registry import get_global_registry |
|
27 from pyams_utils.traversing import get_parent |
26 |
28 |
27 |
29 |
28 __docformat__ = 'restructuredtext' |
30 __docformat__ = 'restructuredtext' |
29 |
31 |
30 from pyams_content import _ |
32 from pyams_content import _ |
43 user_title = FieldProperty(IWfForm['user_title']) |
45 user_title = FieldProperty(IWfForm['user_title']) |
44 auth_only = FieldProperty(IWfForm['auth_only']) |
46 auth_only = FieldProperty(IWfForm['auth_only']) |
45 submit_label = FieldProperty(IWfForm['submit_label']) |
47 submit_label = FieldProperty(IWfForm['submit_label']) |
46 submit_message = FieldProperty(IWfForm['submit_message']) |
48 submit_message = FieldProperty(IWfForm['submit_message']) |
47 _handler = FieldProperty(IWfForm['handler']) |
49 _handler = FieldProperty(IWfForm['handler']) |
48 use_captcha = FieldProperty(IWfForm['use_captcha']) |
50 override_captcha = FieldProperty(IWfForm['override_captcha']) |
49 client_captcha_key = FieldProperty(IWfForm['client_captcha_key']) |
51 client_captcha_key = FieldProperty(IWfForm['client_captcha_key']) |
50 server_captcha_key = FieldProperty(IWfForm['server_captcha_key']) |
52 server_captcha_key = FieldProperty(IWfForm['server_captcha_key']) |
51 captcha_proxy = FieldProperty(IWfForm['captcha_proxy']) |
|
52 rgpd_consent = FieldProperty(IWfForm['rgpd_consent']) |
53 rgpd_consent = FieldProperty(IWfForm['rgpd_consent']) |
53 rgpd_warning = FieldProperty(IWfForm['rgpd_warning']) |
54 rgpd_warning = FieldProperty(IWfForm['rgpd_warning']) |
54 rgpd_user_rights = FieldProperty(IWfForm['rgpd_user_rights']) |
55 rgpd_user_rights = FieldProperty(IWfForm['rgpd_user_rights']) |
55 |
56 |
56 def __init__(self): |
57 def __init__(self): |
84 handler = self._handler |
85 handler = self._handler |
85 if handler: |
86 if handler: |
86 registry = get_global_registry() |
87 registry = get_global_registry() |
87 return registry.queryUtility(IFormHandler, name=handler) |
88 return registry.queryUtility(IFormHandler, name=handler) |
88 |
89 |
|
90 def get_captcha_settings(self): |
|
91 if self.override_captcha: |
|
92 return { |
|
93 'use_captcha': bool(self.client_captcha_key), |
|
94 'client_key': self.client_captcha_key, |
|
95 'server_key': self.server_captcha_key |
|
96 } |
|
97 else: |
|
98 manager = get_parent(self, IFormsManager) |
|
99 return manager.get_captcha_settings() |
|
100 |
89 |
101 |
90 register_content_type(WfForm, shared_content=False) |
102 register_content_type(WfForm, shared_content=False) |
91 |
103 |
92 |
104 |
93 @provider(IWfFormFactory) |
105 @provider(IWfFormFactory) |