Skip to content

Commit

Permalink
Merge pull request #19 from collective/maurits-plone61-z3cform
Browse files Browse the repository at this point in the history
Add Plone 6.1 override for plone.app.z3cform.templates.macros.pt
  • Loading branch information
mauritsvanrees authored Jun 16, 2024
2 parents a0104cb + 0937600 commit 3202172
Show file tree
Hide file tree
Showing 14 changed files with 279 additions and 20 deletions.
1 change: 0 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ jobs:
matrix:
config:
# [Python version, tox env]
- ["2.7", "py27-plone52"]
- ["3.7", "py37-plone52"]
- ["3.8", "py38-plone52"]
- ["3.8", "py38-plone60"]
Expand Down
6 changes: 4 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ Changelog
2.2 (unreleasd)
---------------

- Add Plone 6 override for plone.app.z3cform.templates.macros.pt
[szakitibi]
- Drop support for Python older than 3.7. [maurits]

- Add Plone 6.0 and 6.1 override for ``plone.app.z3cform.templates.macros.pt``.
[szakitibi, maurits]


2.1.1 (unreleased)
Expand Down
5 changes: 4 additions & 1 deletion collective/honeypot/fixes.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@

<include package="z3c.jbot" />
<include zcml:condition="not-have plone-60" package=".plone5" />
<include zcml:condition="have plone-60" package=".plone6" />
<configure zcml:condition="have plone-60">
<include zcml:condition="not-have plone-61" package=".plone60" />
<include zcml:condition="have plone-61" package=".plone61" />
</configure>

<adapter
name="honeypot"
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


logger = logging.getLogger("collective.honeypot")
logger.info("Loading plone6 patches.")
logger.info("Loading plone60 patches.")

protected = [
"sendto_form",
Expand Down
1 change: 1 addition & 0 deletions collective/honeypot/plone61/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import patches # noqa
8 changes: 8 additions & 0 deletions collective/honeypot/plone61/configure.zcml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser">

<include package="z3c.jbot" file="meta.zcml" />
<browser:jbot directory="overrides" />

</configure>
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
xmlns:metal="http://xml.zope.org/namespaces/metal"
xmlns:tal="http://xml.zope.org/namespaces/tal"
i18n:domain="plone"
>

<body>

<div class="form"
metal:define-macro="form"
>

<metal:title-slot define-slot="title">
<h3 tal:condition="view/label | nothing"
tal:content="view/label"
></h3>
</metal:title-slot>

<metal:define define-macro="titlelessform"
i18n:domain="plone"
>

<tal:status tal:define="
status view/status;
has_error python:view.widgets.errors or status == getattr(view, 'formErrorsMessage', None);
errors view/widgets/errors;
icons nocall: context/@@iconresolver;
"
tal:condition="python: status"
>
<div class="portalMessage statusmessage statusmessage-info alert alert-info"
role="alert"
tal:condition="python:not (has_error or errors)"
>
<tal:icon tal:replace="structure python:icons.tag('plone-statusmessage-info', tag_alt='Info', tag_class='statusmessage-icon mb-1 me-2')"
i18n:attributes="alt"
/>
<span class="content"
tal:replace="structure status | nothing"
i18n:translate=""
>
The info status message.
</span>
</div>
<div class="portalMessage statusmessage statusmessage-error alert alert-danger"
role="alert"
tal:condition="python:has_error or errors"
>
<tal:icon tal:replace="structure python:icons.tag('plone-statusmessage-error', tag_alt='Error', tag_class='statusmessage-icon mb-1 me-2')"
i18n:attributes="alt"
/>
<span class="content"
tal:replace="structure status | nothing"
i18n:translate=""
>
The error status message.
</span>
<div class="mt-2 field error"
tal:condition="python:[e for e in errors if not getattr(e, 'widget', None)]"
>
<ul>
<tal:loop tal:repeat="error errors">
<li tal:condition="not:nocall:error/widget"
tal:content="structure error/render"
>
Error
</li>
</tal:loop>
</ul>
</div>
</div>
</tal:status>


<form class="rowlike enableUnloadProtection"
action="."
method="post"
data-pat-autotoc="levels: legend; section: fieldset; className: autotabs"
tal:define="
groups view/groups | nothing;
form_name view/form_name | nothing;
form_class view/css_class | string:;
default_fieldset_label view/default_fieldset_label | form_name;
enable_form_tabbing view/enable_form_tabbing | python:True;
enable_unload_protection view/enable_unload_protection|python:True;
unload_protection python:enable_unload_protection and 'pat-formunloadalert';
enable_autofocus view/enable_autofocus|python:True;
autofocus python:enable_autofocus and 'pat-formautofocus';
validation python:'pat-validation' if not view.ignoreRequiredOnExtract else '';
has_groups python:bool(groups);
form_tabbing python:(has_groups and enable_form_tabbing) and 'enableFormTabbing pat-autotoc' or '';
show_default_label python:has_groups and default_fieldset_label and len(view.widgets);
form_view_name_raw python:view.__name__ or request.getURL().split('/')[-1];
form_view_name python:'-'.join(['view', 'name'] + [x for x in form_view_name_raw.split('++') if x]);
"
tal:attributes="
action view/action|request/getURL;
enctype view/enctype;
class string:rowlike $unload_protection $autofocus $validation $form_tabbing $form_class $form_view_name_raw $form_view_name;
id view/id;
name form_name;
method view/method|string:post;
"
>

<metal:block define-slot="formtop" />

<metal:fields-slot define-slot="fields">
<input name="fieldset"
type="hidden"
tal:define="
current_fieldset request/fieldset | python:None;
"
tal:condition="python:has_groups and enable_form_tabbing and current_fieldset is not None"
tal:attributes="
value current_fieldset;
"
/>

<!-- Default fieldset -->
<metal:define define-macro="fields"
tal:define="
show_default_label show_default_label|nothing;
has_groups has_groups|nothing;
"
>

<fieldset id="fieldset-default"
tal:omit-tag="not:show_default_label"
>

<legend tal:condition="show_default_label"
tal:content="default_fieldset_label"
tal:attributes="
id string:fieldsetlegend-default;
"
>Form name</legend>

<metal:define define-macro="widget_rendering">
<div class="row">
<tal:widgets repeat="widget python:view.widgets.values()">
<metal:field-slot define-slot="field">
<metal:field define-macro="field">
<tal:widget tal:replace="structure widget/@@ploneform-render-widget" />
</metal:field>
</metal:field-slot>
</tal:widgets>
</div>
</metal:define>
</fieldset>

<!-- Secondary fieldsets -->
<tal:block condition="has_groups"
tal:repeat="group groups"
>
<fieldset tal:define="
normalizeString nocall:context/@@plone/normalizeString;
fieldset_label group/label;
fieldset_name python:getattr(group, '__name__', False) or getattr(group.label, 'default', False) or fieldset_label;
fieldset_name python:normalizeString(fieldset_name);
"
tal:attributes="
id string:fieldset-${fieldset_name};
class string:kssattr-fieldset-${fieldset_name};
data-fieldset fieldset_name;
"
>

<legend tal:condition="fieldset_label"
tal:content="fieldset_label"
tal:attributes="
id string:fieldsetlegend-${fieldset_name};
"
i18n:translate=""
>Form name</legend>

<p tal:define="
group_description group/description|nothing;
"
tal:condition="group_description"
tal:content="structure group_description"
i18n:translate=""
>
Description
</p>

<tal:block tal:define="
errors group/widgets/errors;
"
tal:condition="errors"
tal:repeat="error errors"
>
<div class="field error"
tal:condition="not:nocall:error/widget"
tal:content="structure error/render"
></div>
</tal:block>

<tal:block define="
view nocall:group;
">
<metal:block use-macro="context/@@ploneform-macros/widget_rendering" />
</tal:block>

</fieldset>
</tal:block>

</metal:define>
</metal:fields-slot>

<metal:block define-slot="belowfields" />

<metal:actions define-slot="actions">
<metal:define define-macro="actions">
<div class="formControls"
tal:condition="view/actions/values|nothing"
>
<tal:block repeat="action view/actions/values">
<input tal:replace="structure action/render" />
</tal:block>
</div>
</metal:define>
</metal:actions>

<tal:honey replace="structure context/@@honeypot_field|nothing" />
<tal:block tal:condition="view/enableCSRFProtection|nothing"
tal:replace="structure context/@@authenticator/authenticator"
/>
<metal:block define-slot="formbottom" />

</form>
</metal:define>
</div>
</body>
</html>
18 changes: 18 additions & 0 deletions collective/honeypot/plone61/patches.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from collective.honeypot import config

import logging


logger = logging.getLogger("collective.honeypot")
logger.info("Loading plone61 patches.")

protected = [
"sendto_form",
"sendto",
"contact-info",
"send_feedback_site",
"register",
]
# Explicitly add the actions that we protect.
config.EXTRA_PROTECTED_ACTIONS.update(protected)
logger.info("Extra protected actions: %r", config.EXTRA_PROTECTED_ACTIONS)
11 changes: 0 additions & 11 deletions requirements-py2.txt

This file was deleted.

6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@
"Development Status :: 5 - Production/Stable",
"Framework :: Plone",
"Framework :: Plone :: 5.2",
"Framework :: Plone :: 6.0",
"Framework :: Plone :: 6.1",
"License :: OSI Approved :: GNU General Public License (GPL)",
"Programming Language :: Python",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
],
keywords="honeypot antispam form protection plone",
author="Maurits van Rees",
Expand All @@ -29,6 +32,7 @@
namespace_packages=["collective"],
include_package_data=True,
zip_safe=False,
python_requires=">=3.7",
install_requires=[
"setuptools",
"z3c.jbot",
Expand Down
5 changes: 2 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
envlist =
py{27,37,38}-plone52,
py{37,38}-plone52,
py{38,39,310}-plone60,
skip_missing_interpreters = True

Expand All @@ -16,5 +16,4 @@ setenv =
version_file=test-5.2.x.cfg
plone60: version_file=test-6.0.x.cfg
deps =
!py27: -rrequirements.txt
py27: -rrequirements-py2.txt
-rrequirements.txt

0 comments on commit 3202172

Please sign in to comment.