-
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fc] Repository: plone.app.discussion
Branch: refs/heads/3.4.x Date: 2024-03-21T15:05:59+01:00 Author: Katja Süss (ksuess) <[email protected]> Commit: plone/plone.app.discussion@f3b50d7 Apply validation for all captchas (version 3.4.x) (#233) Files changed: A news/233.bugfix M plone/app/discussion/browser/validator.py
- Loading branch information
Showing
1 changed file
with
5 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,20 +2,15 @@ Repository: plone.app.discussion | |
|
||
|
||
Branch: refs/heads/3.4.x | ||
Date: 2024-03-18T12:00:02+01:00 | ||
Date: 2024-03-21T15:05:59+01:00 | ||
Author: Katja Süss (ksuess) <[email protected]> | ||
Commit: https://github.com/plone/plone.app.discussion/commit/f610d19f4fcf483c4b9d1ee0d0805dbd2cd77915 | ||
Commit: https://github.com/plone/plone.app.discussion/commit/f3b50d753ffd5cd7da767b9d211bfe2d19360854 | ||
|
||
Support for HCaptcha via plone.formwidget.hcaptcha in plone.app.discussion 3.4.x (#229) | ||
Apply validation for all captchas (version 3.4.x) (#233) | ||
|
||
Files changed: | ||
A news/230.feature | ||
M README.rst | ||
M plone/app/discussion/browser/captcha.py | ||
A news/233.bugfix | ||
M plone/app/discussion/browser/validator.py | ||
M plone/app/discussion/configure.zcml | ||
M plone/app/discussion/interfaces.py | ||
M plone/app/discussion/vocabularies.py | ||
|
||
b'diff --git a/README.rst b/README.rst\nindex 352ae6bf..bf596aed 100644\n--- a/README.rst\n+++ b/README.rst\n@@ -105,6 +105,10 @@ Add-on Products\n <http://pypi.python.org/pypi/collective.z3cform.norobots/1.1/>`_\n (provides a "human" captcha widget based on a list of questions/answers)\n \n+- `plone.formwidget.hcaptcha\n+ <https://pypi.org/project/plone.formwidget.hcaptcha/>`_\n+ (for spam protection by `HCaptcha <https://www.hcaptcha.com/>`_ )\n+\n \n Documentation\n =============\ndiff --git a/news/230.feature b/news/230.feature\nnew file mode 100644\nindex 00000000..72cc6f78\n--- /dev/null\n+++ b/news/230.feature\n@@ -0,0 +1 @@\n+Provide HCaptcha if plone.formwidget.hcaptcha is installed. @ksuess\n\\ No newline at end of file\ndiff --git a/plone/app/discussion/browser/captcha.py b/plone/app/discussion/browser/captcha.py\nindex 090fce95..34c7b61d 100644\n--- a/plone/app/discussion/browser/captcha.py\n+++ b/plone/app/discussion/browser/captcha.py\n@@ -61,6 +61,10 @@ def update(self):\n from plone.formwidget.recaptcha import ReCaptchaFieldWidget\n self.form.fields[\'captcha\'].widgetFactory = \\\n ReCaptchaFieldWidget\n+ elif self.captcha == "hcaptcha":\n+ from plone.formwidget.hcaptcha import HCaptchaFieldWidget\n+\n+ self.form.fields["captcha"].widgetFactory = HCaptchaFieldWidget\n elif self.captcha == \'norobots\':\n from collective.z3cform.norobots import NorobotsFieldWidget\n self.form.fields[\'captcha\'].widgetFactory = NorobotsFieldWidget\ndiff --git a/plone/app/discussion/browser/validator.py b/plone/app/discussion/browser/validator.py\nindex d1582e9a..360616b7 100644\n--- a/plone/app/discussion/browser/validator.py\n+++ b/plone/app/discussion/browser/validator.py\n@@ -31,6 +31,11 @@\n except ImportError:\n pass\n \n+try:\n+ from plone.formwidget.hcaptcha.validator import WrongCaptchaCode # noqa\n+except ImportError:\n+ pass\n+\n \n @implementer(IValidator)\n @adapter(Interface, IDiscussionLayer, Interface, IField, Interface)\ndiff --git a/plone/app/discussion/configure.zcml b/plone/app/discussion/configure.zcml\nindex aabd851d..e4e3147d 100644\n--- a/plone/app/discussion/configure.zcml\n+++ b/plone/app/discussion/configure.zcml\n@@ -27,6 +27,9 @@\n <configure zcml:condition="installed plone.formwidget.recaptcha">\n <include package="plone.formwidget.recaptcha" />\n </configure>\n+ <configure zcml:condition="installed plone.formwidget.hcaptcha">\n+ <include package="plone.formwidget.hcaptcha" />\n+ </configure>\n <configure zcml:condition="installed collective.z3cform.norobots">\n <include package="collective.z3cform.norobots" />\n </configure>\ndiff --git a/plone/app/discussion/interfaces.py b/plone/app/discussion/interfaces.py\nindex 76a0cee5..f8cac445 100644\n--- a/plone/app/discussion/interfaces.py\n+++ b/plone/app/discussion/interfaces.py\n@@ -315,7 +315,9 @@ class IDiscussionSettings(Interface):\n default=u\'Use this setting to enable or disable Captcha \'\n u\'validation for comments. Install \'\n u\'plone.formwidget.captcha, \'\n- u\'plone.formwidget.recaptcha, collective.akismet, or \'\n+ u\'plone.formwidget.recaptcha, \'\n+ u\'plone.formwidget.hcaptcha, \'\n+ u\'collective.akismet, or \'\n u\'collective.z3cform.norobots if there are no options \'\n u\'available.\'),\n required=True,\ndiff --git a/plone/app/discussion/vocabularies.py b/plone/app/discussion/vocabularies.py\nindex b1588667..bfe93e03 100644\n--- a/plone/app/discussion/vocabularies.py\n+++ b/plone/app/discussion/vocabularies.py\n@@ -18,6 +18,14 @@\n except ImportError:\n pass\n \n+HAS_HCAPTCHA = False\n+try:\n+ import plone.formwidget.hcaptcha # noqa\n+\n+ HAS_HCAPTCHA = True # pragma: no cover\n+except ImportError:\n+ pass\n+\n HAS_AKISMET = False\n try:\n import collective.akismet # noqa\n@@ -57,6 +65,13 @@ def captcha_vocabulary(context):\n token=\'recaptcha\',\n title=\'ReCaptcha\'))\n \n+ if HAS_HCAPTCHA: # pragma: no cover\n+ terms.append(\n+ SimpleTerm(\n+ value="hcaptcha",\n+ token="hcaptcha",\n+ title="HCaptcha"))\n+\n if HAS_AKISMET: # pragma: no cover\n terms.append(\n SimpleTerm(\n' | ||
b"diff --git a/news/233.bugfix b/news/233.bugfix\nnew file mode 100644\nindex 00000000..8bfc3559\n--- /dev/null\n+++ b/news/233.bugfix\n@@ -0,0 +1 @@\n+Apply validation for all captchas. @ksuess\n\\ No newline at end of file\ndiff --git a/plone/app/discussion/browser/validator.py b/plone/app/discussion/browser/validator.py\nindex 360616b7..dce3c52b 100644\n--- a/plone/app/discussion/browser/validator.py\n+++ b/plone/app/discussion/browser/validator.py\n@@ -49,7 +49,7 @@ def validate(self, value):\n registry = queryUtility(IRegistry)\n settings = registry.forInterface(IDiscussionSettings, check=False)\n \n- if settings.captcha in ('captcha', 'recaptcha', 'norobots'):\n+ if settings.captcha != 'disabled':\n captcha = getMultiAdapter((aq_inner(self.context), self.request),\n name=settings.captcha)\n if not captcha.verify(input=value):\n" | ||
|