Skip to content

Commit

Permalink
Merge branch 'master' into portal_checklink
Browse files Browse the repository at this point in the history
  • Loading branch information
mamico committed Jul 9, 2024
2 parents 6340be2 + 867e4b8 commit d853690
Show file tree
Hide file tree
Showing 28 changed files with 553 additions and 62 deletions.
13 changes: 4 additions & 9 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,25 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.8]
python-version: [3.11]

steps:
# git checkout
- uses: actions/checkout@v2
- uses: actions/checkout@v4

# python setup
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

# python cache
- uses: actions/cache@v1
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
# install black
- name: install black
run: pip install black

# run black
- name: run black
run: black src/ --check --diff
13 changes: 4 additions & 9 deletions .github/workflows/flake8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,25 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.8]
python-version: [3.11]

steps:
# git checkout
- uses: actions/checkout@v2
- uses: actions/checkout@v4

# python setup
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

# python cache
- uses: actions/cache@v1
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
# install flake8
- name: install flake8
run: pip install flake8

# run black
- name: run flake8
run: flake8 src/ setup.py
2 changes: 1 addition & 1 deletion .github/workflows/isort.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: isort/isort-action@v1
13 changes: 4 additions & 9 deletions .github/workflows/pyroma.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,25 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.8]
python-version: [3.11]

steps:
# git checkout
- uses: actions/checkout@v2
- uses: actions/checkout@v4

# python setup
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

# python cache
- uses: actions/cache@v1
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
# install pyroma
- name: install pyroma
run: pip install pyroma

# run pyroma
- name: run pyroma
run: pyroma -n 10 -d .
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
__pycache__
.DS_Store
pyvenv.cfg
.coverage
Expand Down
25 changes: 22 additions & 3 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
Changelog
=========

5.4.9 (unreleased)
------------------
5.4.10 (unreleased)
-------------------

- Fixed limit event occurrences to 100.
[eikichi18]

- Nothing changed yet.

5.4.9 (2024-04-22)
------------------

- Limit event occurrences to 100.
[mamico]
- Customize INameChooser adapter to check also alias ids and disallow to create contents that could override aliases.
[cekk]
- Customize also `copy` and `move` endpoints to raise BadRequest if that action will override some aliases.
[cekk]
- Add flag in controlpanel to enable/disable INameChooser customization.
[cekk]
- Exclude bg_color from transformed fields in deserializer.
[cekk]
- Uninstall collective.volto.cookieconsent (deprecated). Will be removed from dependencies in next releases.
[cekk]
- Add dependency to collective.volto.gdprcookie and install it by default.
[cekk]

5.4.8 (2024-03-19)
------------------
Expand Down
3 changes: 3 additions & 0 deletions buildout.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
# use this extend one of the buildout configuration:
extends =
test_plone60.cfg

[versions]
plone.restapi = 9.7.0
6 changes: 4 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

setup(
name="redturtle.volto",
version="5.4.9.dev0",
version="5.4.10.dev0",
description="Helper package to setup a RedTurtle's Plone site ready to work with Volto.",
long_description=long_description,
# Get more from https://pypi.org/classifiers/
Expand Down Expand Up @@ -54,13 +54,15 @@
python_requires=">=3.7",
install_requires=[
"setuptools",
"collective.volto.cookieconsent",
"collective.volto.cookieconsent", # this will be uninstalled and removed soon.
"collective.volto.gdprcookie",
"collective.monkeypatcher",
"collective.purgebyid",
"kitconcept.seo>=2.0.0",
"plone.volto>=4.0.0",
"plone.restapi>=9.6.0",
"Products.PortalTransforms>=3.2.0",
"z3c.jbot",
],
extras_require={
"advancedquery": [
Expand Down
11 changes: 11 additions & 0 deletions src/redturtle/volto/adapters/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,15 @@
zcml:condition="not-have plone-60"
/>

<!-- namechooser adapters -->
<adapter
factory=".namechooser.NormalizingNameChooser"
provides="zope.container.interfaces.INameChooser"
for="plone.dexterity.interfaces.IDexterityContainer"
/>
<adapter
factory=".namechooser.NormalizingNameChooser"
provides="zope.container.interfaces.INameChooser"
for="Products.CMFCore.interfaces.ISiteRoot"
/>
</configure>
47 changes: 47 additions & 0 deletions src/redturtle/volto/adapters/namechooser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from Acquisition import aq_inner
from plone import api
from plone.app.content.namechooser import (
NormalizingNameChooser as BaseNormalizingNameChooser,
)
from plone.app.redirector.interfaces import IRedirectionStorage
from redturtle.volto import _
from redturtle.volto.interfaces import IRedTurtleVoltoSettings
from zExceptions import BadRequest
from zope.component import getUtility


def check_alias(context, id):
context = aq_inner(context)
try:
if not api.portal.get_registry_record(
"check_aliases_in_namechooser",
interface=IRedTurtleVoltoSettings,
default=False,
):
return
except KeyError:
return
storage = getUtility(IRedirectionStorage)
path = "/".join(context.getPhysicalPath()) + "/" + id
if storage.get(path):
portal_path = "/".join(api.portal.get().getPhysicalPath())
fixed_path = path.replace(portal_path, "")
msg = _(
"name_chooser_alias_error",
default='The id "${id}" is invalid because there is already an alias for that path. '
'Change its id or ask site administrators to remove "${fixed_path}" in aliases management.',
mapping={"id": id, "fixed_path": fixed_path},
)
raise BadRequest(api.portal.translate(msg))


class NormalizingNameChooser(BaseNormalizingNameChooser):
def chooseName(self, name, obj):
"""
Additional check: the id should not be in redirection tool.
"""
id = super().chooseName(name=name, obj=obj)

# this raise BadRequest if there is an override with aliases
check_alias(context=self.context, id=id)
return id
13 changes: 13 additions & 0 deletions src/redturtle/volto/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,16 @@ class IRedTurtleVoltoSettings(Interface):
default=False,
required=False,
)

check_aliases_in_namechooser = Bool(
title=_(
"check_aliases_in_namechooser_label",
default="Disallow ids used in aliases",
),
description=_(
"check_aliases_in_namechooser_help",
default="If enabled, users can't create contents with ids that are already used as aliases.",
),
default=False,
required=False,
)
33 changes: 24 additions & 9 deletions src/redturtle/volto/locales/it/LC_MESSAGES/redturtle.volto.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2023-03-16 14:54+0000\n"
"POT-Creation-Date: 2024-03-28 10:20+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand All @@ -14,7 +14,7 @@ msgstr ""
"Preferred-Encodings: utf-8 latin1\n"
"Domain: DOMAIN\n"

#: redturtle/volto/configure.zcml:28
#: redturtle/volto/configure.zcml:29
msgid "Installs the redturtle.volto add-on."
msgstr ""

Expand All @@ -27,11 +27,11 @@ msgstr ""
msgid "RedTurtle Volto Settings"
msgstr "Impostazioni RedTurtle Volto"

#: redturtle/volto/configure.zcml:28
#: redturtle/volto/configure.zcml:29
msgid "RedTurtle: Volto"
msgstr ""

#: redturtle/volto/configure.zcml:37
#: redturtle/volto/configure.zcml:38
msgid "RedTurtle: Volto (uninstall)"
msgstr ""

Expand All @@ -43,31 +43,46 @@ msgstr "Seleziona False per mostrare solo gli elementi non omessi dalla navigazi
msgid "Show elements excluded from navigation"
msgstr "Elementi omessi dalla navigazione"

#: redturtle/volto/configure.zcml:37
#: redturtle/volto/configure.zcml:38
msgid "Uninstalls the redturtle.volto add-on."
msgstr ""

#. Default: "If enabled, users can't create contents with ids that are already used as aliases."
#: redturtle/volto/interfaces.py:36
msgid "check_aliases_in_namechooser_help"
msgstr "Se attivato, alla creazione o rinomina di un contenuto, verrà eseguito anche un controllo su eventuali alias presenti (quelli visibili in Gestione URL), ed eventualmente viene impedita la creazione con quell'id."

#. Default: "Disallow ids used in aliases"
#: redturtle/volto/interfaces.py:32
msgid "check_aliases_in_namechooser_label"
msgstr "Controllo degli id anche sugli alias"

#. Default: "If enabled, a custom ranking for SearchableText searches will be used."
#: redturtle/volto/interfaces.py:24
#: redturtle/volto/interfaces.py:23
msgid "enable_advanced_query_ranking_help"
msgstr "Se abilitato, verrà utilizzato un ranking custom per la ricerca testuale."

#. Default: "Enable AdvancedQuery ranking"
#: redturtle/volto/interfaces.py:20
#: redturtle/volto/interfaces.py:19
msgid "enable_advanced_query_ranking_label"
msgstr "Abilita ranking custom con AdvancedQuery"

#. Default: "The id \"${id}\" is invalid because there is already an alias for that path. Change its id or ask site administrators to remove \"${fixed_path}\" in aliases management."
#: redturtle/volto/adapters/namechooser.py:29
msgid "name_chooser_alias_error"
msgstr "L'id \"${id}\" non è valido perché già utilizzato per un alias. Modifca l'id oppure rivolgiti agli amministratori per cancellare l'alias esistente: \"${fixed_path}\"."

#. Default: "Insert an external link directly into the field,or select an internal link clicking on the icon."
#: redturtle/volto/types/adapters.py:25
msgid "remoteUrl_restapi_label"
msgstr "Inserisci un link esterno direttamente nel campo, oppure seleziona un collegamento ad un contenuto del sito cliccando sull'icona accanto."

#. Default: "Volto Parent URL: Content url without \"/api\"."
#: redturtle/volto/adapters/stringinterp.py:31
#: redturtle/volto/adapters/stringinterp.py:35
msgid "stringinterp_volto_parent_url"
msgstr ""

#. Default: "Volto URL: Content url without \"/api\"."
#: redturtle/volto/adapters/stringinterp.py:13
#: redturtle/volto/adapters/stringinterp.py:18
msgid "stringinterp_volto_url"
msgstr "Volto URL: URL del contenuto Plone senza \"/api\"."
Loading

0 comments on commit d853690

Please sign in to comment.