src/pyams_content/shared/form/interfaces.py
changeset 1370 87bcbf37ad6d
parent 1346 88b5ce31afdc
--- a/src/pyams_content/shared/form/interfaces.py	Mon Oct 07 14:04:31 2019 +0200
+++ b/src/pyams_content/shared/form/interfaces.py	Wed Oct 16 18:41:45 2019 +0200
@@ -13,8 +13,9 @@
 from zope.annotation.interfaces import IAttributeAnnotatable
 from zope.container.constraints import containers, contains
 from zope.container.interfaces import IContained, IContainer
-from zope.interface import Attribute, Interface
-from zope.schema import Bool, Choice, TextLine
+from zope.interface import Attribute, Interface, invariant
+from zope.interface.interfaces import Invalid
+from zope.schema import Bool, Choice, TextLine, Int, Password
 
 from pyams_content.component.paragraph import IBaseParagraph
 from pyams_content.shared.common.interfaces import ISharedContent, ISharedToolPortalContext, \
@@ -37,6 +38,67 @@
 class IFormsManager(ISharedToolPortalContext):
     """Forms manager interface"""
 
+    use_captcha = Bool(title=_("Use captcha?"),
+                       description=_("Set default captcha settings"),
+                       required=True,
+                       default=False)
+
+    default_captcha_client_key = TextLine(title=_("Default captcha site key"),
+                                          description=_("This key is included into HTML code and "
+                                                        "submitted with form data"),
+                                          required=False)
+
+    default_captcha_server_key = TextLine(title=_("Default captcha secret key"),
+                                          description=_("This key is used to communicate with "
+                                                        "Google's reCaptcha services"),
+                                          required=False)
+
+    def get_captcha_settings(self):
+        """Get default captcha settings"""
+
+    use_proxy = Bool(title=_("Use proxy server?"),
+                     description=_("If a proxy server is required to access recaptcha services, "
+                                   "please set them here"),
+                     required=True,
+                     default=False)
+
+    proxy_proto = Choice(title=_("Protocol"),
+                         description=_("If your server is behind a proxy, please set it's "
+                                       "protocol here; HTTPS support is required for reCaptcha"),
+                         required=False,
+                         values=('http', 'https'),
+                         default='http')
+
+    proxy_host = TextLine(title=_("Host name"),
+                          description=_("If your server is behind a proxy, please set it's "
+                                        "address here; captcha verification requires HTTPS "
+                                        "support..."),
+                          required=False)
+
+    proxy_port = Int(title=_("Port number"),
+                     description=_("If your server is behind a proxy, plase set it's port "
+                                   "number here"),
+                     required=False,
+                     default=8080)
+
+    proxy_username = TextLine(title=_("Username"),
+                              description=_("If your proxy server requires authentication, "
+                                            "please set username here"),
+                              required=False)
+
+    proxy_password = Password(title=_("Password"),
+                              description=_("If your proxy server requires authentication, "
+                                            "please set password here"),
+                              required=False)
+
+    proxy_only_from = TextLine(title=_("Use proxy only from"),
+                               description=_("If proxy usage is restricted to several domains "
+                                             "names, you can set them here, separated by comas"),
+                               required=False)
+
+    def get_proxy_url(self, request):
+        """Get proxy server URL"""
+
 
 class IFormsManagerFactory(Interface):
     """Forms manager factory interface"""
@@ -175,10 +237,10 @@
                      description=_("Select how form data is transmitted"),
                      vocabulary='PyAMS form handlers')
 
-    use_captcha = Bool(title=_("Use captcha?"),
-                       description=_("If 'yes', a captcha will be added automatically to the form"),
-                       required=False,
-                       default=True)
+    override_captcha = Bool(title=_("Override captcha settings?"),
+                            description=_("If 'yes', you can define custom captcha keys here"),
+                            required=False,
+                            default=True)
 
     client_captcha_key = TextLine(title=_("Site key"),
                                   description=_("This key is included into HTML code and submitted "
@@ -190,11 +252,8 @@
                                                 "reCaptcha services"),
                                   required=False)
 
-    captcha_proxy = TextLine(title=_("Recaptcha proxy"),
-                             description=_("If your server is behind a proxy, please set it's "
-                                           "address here; captcha verification requires HTTPS "
-                                           "support..."),
-                             required=False)
+    def get_captcha_settings(self):
+        """Get form captcha settings"""
 
     rgpd_consent = Bool(title=_("Required RGPD consent?"),
                         description=_("If 'yes', an RGPD compliance warning will be displayed "