Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plone 6 override for plone.app.z3cform.templates.macros.pt #17

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Changelog
=========

2.2 (unreleasd)
---------------

- Add Plone 6 override for plone.app.z3cform.templates.macros.pt
[szakitibi]


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

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

<adapter
name="honeypot"
Expand Down
1 change: 1 addition & 0 deletions collective/honeypot/plone6/__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/plone6/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,234 @@
<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">
<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>
</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/plone6/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 plone6 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)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

setup(
name="collective.honeypot",
version="2.1.1.dev0",
version="2.2.dev0",
description="Anti-spam honeypot for Plone",
long_description=(open("README.rst").read() + "\n" + open("CHANGES.rst").read()),
# Get more strings from https://pypi.org/classifiers
Expand Down