Skip to content

Commit

Permalink
Barceloneta LTS (#3244)
Browse files Browse the repository at this point in the history
* Fix TTW Bundle compilation broken.
Fixes #2969

* Add plone.staticresources to list of addons which are automatically upgraded if upgrade steps are available.

* Fix #1318: Always install default content types on Plone site creation (#2971)

* Fix #1318: Always install default content types on Plone site creation

* Update changelog entry

* Correctly fire events when user auto login after the password has been reset (#2994)

* Test if events fired after auto login have the correct principal

* At this point the user is not logged in yet, so we get it from the membership_tool.

* Update changelog

* Remove adapter registration for IUserLoggedInEvent

* Fix unregistering of adapter

* Deal with cases where username/email were not the userid

* Create FUNDING.yml

* Improve tests for the workflow tool method listWFStatesByTitle

Refs #3032

* require Zope wsgi extra (because of Paste) depending on Python version

* add changelog entry

* Make setup.py reflect to be Plone 6 and Py3 only

* Include changelog of 5.2.1.

Removed related news snippets.
There are now no differences between master and 5.2.x, except basically in setup.py.

[ci skip]

* Password strength checks were not always checked

Include Hotfix 20200121 with tests

* Merge isURLInPortal patch from Hotfix20200121.

The isURLInPortal check that is done to avoid linking to an external
site could be tricked into accepting malicious links.

* Fix typo

causes double translation text. Same message is on line 350

* enable custom format string i18n/l10n

* fix/add suggestions from review

* Use time.process_time always.

Available in all relevant Python 3 versions.

* add viewlet manager below content description

* structure cleanup

* fix card markup for footer

* fix footer and colophon card classes

* Add changelog entry

* Fix TTW Bundle compilation broken.
Fixes #2969

* Add plone.staticresources to list of addons which are automatically upgraded if upgrade steps are available.

* Fix #1318: Always install default content types on Plone site creation (#2971)

* Fix #1318: Always install default content types on Plone site creation

* Update changelog entry

* Correctly fire events when user auto login after the password has been reset (#2994)

* Test if events fired after auto login have the correct principal

* At this point the user is not logged in yet, so we get it from the membership_tool.

* Update changelog

* Remove adapter registration for IUserLoggedInEvent

* Fix unregistering of adapter

* Deal with cases where username/email were not the userid

* changelog

* Create FUNDING.yml

* require Zope wsgi extra (because of Paste) depending on Python version

* add changelog entry

* Make setup.py reflect to be Plone 6 and Py3 only

* Include changelog of 5.2.1.

Removed related news snippets.
There are now no differences between master and 5.2.x, except basically in setup.py.

[ci skip]

* Password strength checks were not always checked

Include Hotfix 20200121 with tests

* Merge isURLInPortal patch from Hotfix20200121.

The isURLInPortal check that is done to avoid linking to an external
site could be tricked into accepting malicious links.

* Improve tests for the workflow tool method listWFStatesByTitle

Refs #3032

* Fix typo

causes double translation text. Same message is on line 350

* enable custom format string i18n/l10n

* fix/add suggestions from review

* Use time.process_time always.

Available in all relevant Python 3 versions.

* Add custom.css resource after diazo bundle

* Add changelog entry

* Add issue number to changelog entry

* set GS version to 6000

* Add zcml-condition plone-60 for conditional configuration.

* update HTMLFilter defaults to enable TinyMCE layout features

* Removed a few news snippets that are already in latest 5.2.2 rc.

* Add links to official resources

* The http://plone.org/products/plone page is no longer current.

* Fix rebase aftermath: Missing merge

* Merge isURLInPortal patch from Hotfix20200121.

The isURLInPortal check that is done to avoid linking to an external
site could be tricked into accepting malicious links.

* add viewlet manager below content description

* structure cleanup

* fix card markup for footer

* fix footer and colophon card classes

* simplify login form and fix login action pattern-options

* Styled content and usergroups in Site Setup

* fix primary button css class

* fix tests to match bootstrap form markup

* fix broken/incomplete merge from rebase

* fix broken/incomplete merge from rebase (2)

* Fix issue with @@search view when filtering by creation date

(cherry picked from commit 4dbed04)

* remove six - we are Python 3 only

* Remove portal_utf8 and it twin utf8_portal from utils and PloneTool since its never used nowhere.

* Renamed wrongly named news snippets.

[ci skip]

* Removed folder_publish.cpy script.

Moved it to a new browser view in plone.app.content.
Removed deprecated transitionObjectsByPaths.
It was only used by this script, and I have now put it in the view.

* No longer consider calling len(batch) as deprecated.

The deprecation warning is unvoidable with current `Products.PageTemplates` code.
Fixes #3176

(cherry picked from commit 52a3267)

* find . -name "*.py" |xargs pyupgrade --py36-plus

* Fixed news snippet extension.

[ci skip]

* Removed our CMFQuickInstallerTool code completely.

* Removed QuickInstallerTool.py

With the Products.CMFQuickInstallerTool package gone,
the bare bones fallback in this file did not work correctly.
You get an error like this when viewing the Plone Site in the ZMI,
or even just loading the root ZMI:

```
2020-04-24 23:29:39,113 ERROR   [ZODB.Connection:809][waitress] Couldn't load state for Products.CMFPlone.Portal.PloneSite 0x9f8a
Traceback (most recent call last):
  File "/Users/maurits/shared-eggs/cp37m/ZODB-5.5.1-py3.7.egg/ZODB/Connection.py", line 795, in setstate
    self._reader.setGhostState(obj, p)
  File "/Users/maurits/shared-eggs/cp37m/ZODB-5.5.1-py3.7.egg/ZODB/serialize.py", line 637, in setGhostState
    state = self.getState(pickle)
  File "/Users/maurits/shared-eggs/cp37m/ZODB-5.5.1-py3.7.egg/ZODB/serialize.py", line 630, in getState
    return unpickler.load()
  File "/Users/maurits/shared-eggs/cp37m/ZODB-5.5.1-py3.7.egg/ZODB/serialize.py", line 492, in _persistent_load
    return self.load_persistent(*reference)
  File "/Users/maurits/shared-eggs/cp37m/ZODB-5.5.1-py3.7.egg/ZODB/serialize.py", line 535, in load_persistent
    self._cache.new_ghost(oid, obj)
TypeError: Cache values must be persistent objects.
```

I am creating an alias in plone.app.upgrade.

* Removed outdated test for QuickInstallerTool.

* Removed unused quickinstaller test zcml files.

These were already copied to controlpanel/tests/ and adapted.

* On Python 3 in testMigrationTool only test upgrade from Plone 5.2.

You cannot upgrade a Plone 4.0 or 5.1 site to 5.2 or higher when you are on Python 3.
You must first migrate to 5.2 with Python 2.7.
Also, this avoids a test failure on 6.0 because the 5.0alpha upgrade calls qi.isProductInstalled, which has been removed.

* Remove Python 2 code from testMigrationTool.py.

* Merge isURLInPortal patch from Hotfix20200121.

The isURLInPortal check that is done to avoid linking to an external
site could be tricked into accepting malicious links.

* add viewlet manager below content description

* structure cleanup

* fix card markup for footer

* fix footer and colophon card classes

* simplify login form and fix login action pattern-options

* Styled content and usergroups in Site Setup

* fix primary button css class

* fix tests to match bootstrap form markup

* fix broken/incomplete merge from rebase

* fix broken/incomplete merge from rebase (2)

* add test rendering as view, add basic example

* bootstrap markup update for login

* add icon retriever as view

* add changelog entry

* changed due to feedback

* re-add init method, add fallback for icon lookup

* update registration, refactor icons.py, add tests

* shorten icon prefix

* use iconresolver as name

* update markup

* sync ajax_main_template defines with main_template

* fix outdated pull classes

* lookup fallback trial for mimetypes

* simplify debugging

* better error handling with non-existig icons

* catch specific Exception

* bs5 form updates

* overhaul the admin-ui templates to have a modern bootstrap 5 look

* forgotten test condition removed

* ensure installation of "default_extension_profiles"

* update markup for bootstrap

* updated viewlets for barceloneta-lts

* remove deprecated old controlpanel

* get rid of kss traces

* better var name

* use plone icon names

* move image handling controlpanel to default profile

* use icons from icon resolver

* use icons from resolver

* fallback for icon_expr with urls

* add icons from icon resolver

* cleanup

* update button classes for bootstrap

* update classes for bootstrap

* add SVG modifier

* liberated prefs_main_temaplte from skins

* turn configlet portlets into menu

* manage spaces in add site

* update icon fallback for explicit icon names

* update controlpanel icons to explicit icon names

* fix ajax load: Compilation failed b/c of typo

* controlpanel icon tweaks

* bs5-b1 update - prefixed data attributes

* Cool URLs do not change

* bootstrap b1 changes

* bootstrap b1 changes

* fix alert margin

* Display the path to have a better hint of were the site is

* Fix problem to remove username and password if there was already one set

(cherry picked from commit 0499b63)

* fixes in usergroups controlpanel

* fixes in group member administration

* again some polishing in user/groups admin

* and again some polishing in user/groups admin

* another alert statusmessage

* always allow to set timezone

* fix action controlpanel robot tests

* use different text to check, since breadcrumbs have changed

* fix robot test: no documentFirstheading in this place

* fix checkboxes in usergroups

* register test rendering page as test_rendering and test-rendering

* fix selector for warning alert

* Start fixing search page

* fix search.js -> new selectors

* ajax pagination and sane result numbering

* fix cite tag

* fix searchterm in title

* convert tal:attributes expressions

* reset batch start when filtering

* one more batch fix

* fix controlpanel tests

* remove outdated test - portal_skins doesn't exist anymore

* fix resource url

* fix authenticator test

* fix selector

* add Sleep 0.5s

* fix usergroups robot tests

* refactor usergroups settings description

* fix selector in security_controlpanel test

* Link modal has no input field "title"

* fix overlay tests

* Fix create new action in action control panel

* update icon_expr for actions

Co-authored-by: Johannes Raggam <thetetet@gmail.com>
Co-authored-by: Érico Andrei <ericof@gmail.com>
Co-authored-by: Thomas Massmann <thomas.massmann@it-spir.it>
Co-authored-by: Jens W. Klein <jk@kleinundpartner.at>
Co-authored-by: T. Kim Nguyen <tkimnguyen@users.noreply.github.com>
Co-authored-by: ale-rt <alessandro.pisa@gmail.com>
Co-authored-by: tschorr <t_schorr@gmx.de>
Co-authored-by: Maurits van Rees <maurits@vanrees.org>
Co-authored-by: Maurits van Rees <m.van.rees@zestsoftware.nl>
Co-authored-by: Fred van Dijk <fredvd@gmail.com>
Co-authored-by: agitator <agitator@users.noreply.github.com>
Co-authored-by: Stefan Antonelli <stefan.antonelli@operun.de>
Co-authored-by: Peter Holzer <peter.holzer@agitator.com>
Co-authored-by: MrTango <md@derico.de>
Co-authored-by: Kristin Kuche <kuche@hrz.uni-marburg.de>
Co-authored-by: Mikel Larreategi <mlarreategi@codesyntax.com>
Co-authored-by: Fulvio Casali <fulviocasali@gmail.com>
Co-authored-by: Nils Hofer <niho2001@gmail.com>
Co-authored-by: Franco Pellegrini <frapell@gmail.com>
Co-authored-by: Robert Kuzma <robert@balavec.com>
  • Loading branch information
21 people committed Feb 13, 2021
1 parent 36a66a8 commit 954942a
Show file tree
Hide file tree
Showing 83 changed files with 3,227 additions and 3,219 deletions.
1 change: 0 additions & 1 deletion Products/CMFPlone/CatalogTool.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
'OFS.interfaces.IZopeObject',
'persistent.interfaces.IPersistent',
'plone.app.iterate.interfaces.IIterateAware',
'plone.app.kss.interfaces.IPortalObject',
'plone.contentrules.engine.interfaces.IRuleAssignable',
'plone.folder.interfaces.IFolder',
'plone.folder.interfaces.IOrderableFolder',
Expand Down
7 changes: 0 additions & 7 deletions Products/CMFPlone/browser/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,15 +308,8 @@ def __call__(self):
REQUEST=self.request,
dry_run=form.get('dry_run', False),
)
qi = get_installer(self.context, self.request)
pac_installed = qi.is_product_installed('plone.app.contenttypes')
pac_installable = qi.is_product_installable(
'plone.app.contenttypes')
advertise_dx_migration = pac_installable and not pac_installed

return self.index(
report=report,
advertise_dx_migration=advertise_dx_migration
)

return self.index()
21 changes: 21 additions & 0 deletions Products/CMFPlone/browser/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -256,4 +256,25 @@
layer="zope.interface.Interface"
/>

<browser:page
name="test_rendering"
for="*"
class=".test_rendering.TestRenderingView"
permission="zope2.View"
/>

<browser:page
name="test-rendering"
for="*"
class=".test_rendering.TestRenderingView"
permission="zope2.View"
/>

<browser:page
for="*"
name="iconresolver"
class=".icons.IconsView"
permission="zope.Public"
/>

</configure>
131 changes: 131 additions & 0 deletions Products/CMFPlone/browser/icons.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# -*- coding: utf-8 -*-
from lxml import etree
from OFS.Image import File
from plone.registry.interfaces import IRegistry
from Products.Five.browser import BrowserView
from Products.CMFCore.interfaces import ISiteRoot
from zExceptions import NotFound
from zope.component import adapter
from zope.component import getUtility
from zope.component.hooks import getSite
from zope.interface import implementer
from zope.interface import Interface
from zope.location.interfaces import LocationError
from zope.traversing.interfaces import ITraversable
from zope.publisher.interfaces import IPublishTraverse
from zExceptions import NotFound

import logging

logger = logging.getLogger(__name__)


SVG_MODIFER = {}

def _add_aria_title(svgtree, cfg):
if not "title" in cfg:
return
root = svgtree.getroot()
ns = root.nsmap.get(None, "")
# set title tag
title = root.find(f'{{{ns}}}title')
if title is None:
title = etree.Element("title")
root.append(title)
title.text = cfg['title']
# add aria attr
root.attrib["aria-labelledby"] = "title"


SVG_MODIFER['add_aria_title'] = _add_aria_title


def _add_css_class(svgtree, cfg):
if not cfg.get('cssclass', False):
return
root = svgtree.getroot()
current = root.attrib.get('class', '')
root.attrib['class'] = f"{cfg['cssclass']} {current}"

SVG_MODIFER['add_css_class'] = _add_css_class

def _strip_id(svgtree, cfg):
for el in svgtree.getroot().xpath("//*[@id]"):
del el.attrib["id"]

SVG_MODIFER['strip_id'] = _strip_id


@implementer(IPublishTraverse)
class IconsView(BrowserView):

prefix = "plone.icon."
defaulticon = "++plone++icons/plone.svg"

def publishTraverse(self, request, name):
self.name = name
return self

def __call__(self):
name = getattr(self, "name", None)
if name is None:
raise NotFound("No name were given as subpath.")
fileobj = self._iconfile(self.lookup(self.name))
return fileobj(REQUEST=self.request, RESPONSE=self.request.response)

def _iconfile(self, icon):
site = getSite()
try:
return site.restrictedTraverse(icon)
except NotFound:
logger.exception(
f"Icon resolver lookup of '{icon}' failed, fallback to Plone icon."
)
return site.restrictedTraverse(self.defaulticon)

def lookup(self, name):
__traceback_info__ = name
registry = getUtility(IRegistry)
regkey = self.prefix + name
try:
return registry[regkey]
except KeyError:
if "/" in name:
main, tail = name.rsplit("/", 1)
return self.lookup(main)
logger.exception(
f"Icon resolver lookup of '{name}' failed, fallback to Plone icon."
)
return self.defaulticon

def url(self, name):
url = getSite().absolute_url() + "/" + self.lookup(name)
return url

def tag(self, name, tag_class="", tag_alt=""):
icon = self.lookup(name)
if not icon.endswith(".svg"):
return f'<img src="{self.url(name)}" class="{tag_class}" alt="{tag_alt}" />'

iconfile = self._iconfile(icon)
if isinstance(iconfile, File):
raise NotImplementedError(
"Resolve icons stored in database is not yet implemented."
)
try:
with open(iconfile.path, "rb") as fh:
svgtree = etree.parse(fh)
except etree.XMLSyntaxError:
logger.exception(f"SVG File: {iconfile.path}")
with open(iconfile.path, "rb") as fh:
return fh.read()
if svgtree.docinfo.root_name.lower() != 'svg':
raise ValueError(f"SVG file content root tag mismatch (not svg but {svgtree.docinfo.root_name}): {iconfile.path}")
modifier_cfg = {
'cssclass': tag_class,
'title': tag_alt,
}
for name, modifier in SVG_MODIFER.items():
__traceback_info__ = name
modifier(svgtree, modifier_cfg)
return etree.tostring(svgtree)
2 changes: 1 addition & 1 deletion Products/CMFPlone/browser/login/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def get_came_from(self):

def updateActions(self):
super().updateActions()
self.actions['login'].addClass('context')
self.actions['login'].addClass('btn-primary')

def _post_login(self):
membership_tool = getToolByName(self.context, 'portal_membership')
Expand Down
8 changes: 8 additions & 0 deletions Products/CMFPlone/browser/login/login_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ class RequestResetPassword(form.Form):

render = ViewPageTemplateFile('templates/subform_render.pt')

def updateActions(self):
super(RequestResetPassword, self).updateActions()
self.actions['reset'].addClass('btn-primary')

def updateWidgets(self):
super().updateWidgets()
if self.use_email_as_login():
Expand Down Expand Up @@ -102,6 +106,10 @@ class RequestUsername(form.Form):

render = ViewPageTemplateFile('templates/subform_render.pt')

def updateActions(self):
super(RequestUsername, self).updateActions()
self.actions['get_username'].addClass('btn-primary')

@button.buttonAndHandler(
_('button_pwreset_get_username', default='Get your username'),
name='get_username'
Expand Down
112 changes: 34 additions & 78 deletions Products/CMFPlone/browser/login/templates/login.pt
Original file line number Diff line number Diff line change
Expand Up @@ -10,90 +10,46 @@
<metal:main fill-slot="main">
<metal:main-macro define-macro="main">

<div id="login-form">

<div class="portalMessage error pat-cookietrigger" style="display:none">
<strong i18n:translate="">
Error
</strong>
<span tal:omit-tag=""
i18n:translate="enable_cookies_message_before_login">
Cookies are not enabled. You must enable cookies before you can log in.
</span>
</div>

<form action="." method="post"
tal:attributes="action view/action; enctype view/enctype">

<tal:widgets repeat="widget view/widgets/values">

<tal:block tal:define="hidden python:widget.mode == 'hidden'">
<div tal:condition="not:hidden">

<div class="field"
tal:define="error widget/error"
tal:attributes="class python:'field' + (error and ' error' or '')">

<label for=""
tal:attributes="for widget/id"
tal:condition="not:hidden">
<span i18n:translate=""
tal:content="widget/label">label</span>
<span class="required horizontal" title="Required"
tal:condition="python:widget.required and not hidden"
i18n:attributes="title title_required;">&nbsp;</span>
</label>

<div class="formHelp"
tal:define="description widget/field/description"
i18n:translate=""
tal:content="description"
tal:condition="description">
field description
</div>

<div tal:condition="error"
tal:content="structure error/render">
Error
</div>

<div class="widget">
<input type="text" tal:replace="structure widget/render" />
</div>

</div>

<article id="content" class="login-wrapper">

<div class="card">
<div class="card-body">
<h1 class="card-title h5"
tal:content="view/label | nothing" />

<div id="login-form">

<div class="alert alert-danger pat-cookietrigger" style="display:none">
<strong i18n:translate="">
Error
</strong>
<span tal:omit-tag=""
i18n:translate="enable_cookies_message_before_login">
Cookies are not enabled. You must enable cookies before you can log in.
</span>
</div>
<metal:form use-macro="context/@@ploneform-macros/titlelessform" />

<div class="footer mt-4"
tal:define="portal_state context/@@plone_portal_state;
portal_url portal_state/portal_url">
<div>
<span i18n:translate="trouble_logging_in" tal:omit-tag="">Trouble logging in?</span>
<a href="@@login-help" tal:attributes="href string:${portal_url}/@@login-help" i18n:translate="footer_login_link_get_help">Get help</a>.
</div>
<div tal:condition="python:view.self_registration_enabled()">
<span i18n:translate="need_an_account" tal:omit-tag="">Need an account?</span>
<a href="@@register" tal:attributes="href string:${portal_url}/@@register" class="emph" i18n:translate="footer_login_link_signup">Sign up here</a>.
</div>
</div>

<input type="hidden"
tal:condition="hidden"
tal:replace="structure widget/render" />
</tal:block>

</tal:widgets>
<span tal:replace="structure context/@@authenticator/authenticator"/>

<div class="formControls">
<tal:actions tal:repeat="action view/actions/values|nothing">
<input type="submit" tal:replace="structure action/render" />
</tal:actions>
</div>
</form>

<div class="footer"
tal:define="portal_state context/@@plone_portal_state;
portal_url portal_state/portal_url">
<p>
<span i18n:translate="trouble_logging_in" tal:omit-tag="">Trouble logging in?</span>
<a href="@@login-help" tal:attributes="href string:${portal_url}/@@login-help" i18n:translate="footer_login_link_get_help">Get help</a>.
</p>
<p tal:condition="python:view.self_registration_enabled()">
<span i18n:translate="need_an_account" tal:omit-tag="">Need an account?</span>
<a href="@@register" tal:attributes="href string:${portal_url}/@@register" class="emph" i18n:translate="footer_login_link_signup">Sign up here</a>.
</p>
</div>
</div>

</div>
</article>

</metal:main-macro>
</metal:main>
</body>
Expand Down
8 changes: 4 additions & 4 deletions Products/CMFPlone/browser/login/templates/login_failsafe.pt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<h1 i18n:translate="">Failsafe Login</h1>

<div class="portalMessage error pat-cookietrigger" style="display:none">
<div class="alert alert-danger pat-cookietrigger" style="display:none">
<strong i18n:translate="">
Error
</strong>
Expand All @@ -29,11 +29,11 @@
<tal:block tal:define="hidden python:widget.mode == 'hidden'">
<div tal:condition="not:hidden">

<div class="field"
<div class="mb-3 field"
tal:define="error widget/error"
tal:attributes="class python:'field' + (error and ' error' or '')">
tal:attributes="class python:'mb-3 field' + (error and ' error' or '')">

<label for=""
<label class="form-label" for=""
tal:attributes="for widget/id"
tal:condition="not:hidden">
<span i18n:translate=""
Expand Down

0 comments on commit 954942a

Please sign in to comment.