Skip to content

Commit

Permalink
Merge branch 'master' into remove_image_customization
Browse files Browse the repository at this point in the history
  • Loading branch information
cekk committed Jan 24, 2024
2 parents dc8219f + 2e4f55b commit 3e39746
Show file tree
Hide file tree
Showing 53 changed files with 743 additions and 166 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/isort.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Run isort
on:
- push

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: isort/isort-action@v1
3 changes: 3 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[settings]
profile=black
force_single_line = true
54 changes: 54 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks

default_language_version:
python: python3.9

default_stages: [commit, push]

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black
# args: ["--line-length=88", "--check", "--diff", "--force-exclude=migrations", "src/"]
args: ["--line-length=88", "--force-exclude=migrations", "src/"]
types: [python]
entry: black
- repo: https://github.com/PyCQA/flake8.git
rev: "6.1.0"
hooks:
- id: flake8
name: flake8
entry: flake8
types: [python]
args: ["--max-complexity=30", "--max-line-length=88", "--ignore=DJ01,DJ08,W503,ANN101", "--exclude=docs/*", "src/", "setup.py"]
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
name: isort (python)
# args: ["--multi-line=3", "--lbt=1", "--trailing-comma", "--force-grid-wrap=0", "--use-parentheses", "--ensure-newline-before-comments", "--line-length=88"]
- repo: local
hooks:
- id: python-check-pdb
name: check pdb
description: 'PDB check inside code'
entry: '^\s?[^#]+\.set_trace\(\)'
language: pygrep
types: [python]
- repo: https://github.com/collective/zpretty
rev: 3.1.0
hooks:
- id: zpretty
name: zpretty
- repo: https://github.com/regebro/pyroma
rev: '4.2'
hooks:
- id: pyroma
71 changes: 70 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,76 @@
Changelog
=========

5.2.3 (unreleased)
5.4.3 (unreleased)
------------------

- Nothing changed yet.


5.4.2 (2024-01-11)
------------------

- Fix deserializer for relationfield, add lstrip to path object calculation
[eikichi18]


5.4.1 (2023-12-28)
------------------

- Fix deserializer for relationfield, use UID instead of @id
[eikichi18]

- Isort
[folix-01]

- Add monkeypatch to fix @scadeziario-day endpoint
[eikichi18]


5.4.0 (2023-11-14)
------------------

- Return error instead of raise Excpetion for BadRequest in querystringsearch
[mamico]

- Add upgrade step and setuphandler to fix robots.txt
original rules adding 'Allow: /*?expand*'
[lucabel]

5.3.0 (2023-10-25)
------------------

- Fix: the 'fix-link' view has a bug that corrupts links by replacing
the current external URL with a URL that is always relative to the
site, even when requesting replacement with a link from a different
website.
[lucabel].

- plone.app.redirector.FourOhFourView.search_for_similar patch to enable conditionally
the search for similar
[folix-01]

- Set search/querystring-search limit patch only for anonymous users.
Auth users can need to perform an higher query (in contents view for example).
[cekk]

- Re-apply context UID filter in querystringsearch service (as it is in plone.restapi).
[cekk]

5.2.4 (2023-09-26)
------------------

- Fix the issue in the @translation GET endpoint: If this
endpoint is invoked, possibly by a bot, and plone.app.multilingual
is not installed, the call will result in an empty search query
on the catalog.
[lucabel]

- backport https://github.com/plone/Products.CMFPlone/pull/3845
fix: avoid searching all users when many_users is flagged
[mamico]

5.2.3 (2023-09-21)
------------------

- Max search limit became configurable by env var 'REDTURTLE_VOLTO_MAX_LIMIT_SEARCH', 500 by default.
Expand Down
9 changes: 9 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ There is a monkeypatch for Events recurrences that fix their duration.

If it works well, we can make a pr in p.a.event.

There is another monkeypatch for Events recurrences to change the default behavior of start index serializer.
Now it keeps all dates even if the single date is already passed.


Respect locally allowed types on paste
--------------------------------------
Expand Down Expand Up @@ -220,6 +223,12 @@ For details see the `pull-request <https://github.com/RedTurtle/redturtle.volto/

This patch is not enabled by default. You need to set an environment variable to `true`: *PROXY_BEARER_AUTH*.

Conditionally search for similar if nonexistent site path passed
----------------------------------------------------------------

plone.app.redirector.FourOhFourView.search_for_similar method patched to return an empty list if
the `REDTURTLE_VOLTO_ENABLE_SEARCH_FOR_SIMILAR` environment variable is set.

New Criteria
============

Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys
import os
import sys

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from setuptools import find_packages
from setuptools import setup


long_description = "\n\n".join(
[
open("README.rst").read(),
Expand All @@ -16,7 +15,7 @@

setup(
name="redturtle.volto",
version="5.2.3.dev0",
version="5.4.3.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
8 changes: 4 additions & 4 deletions src/redturtle/volto/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# -*- coding: utf-8 -*-
"""Init and utils."""
import logging
import re

from plone.app.content.browser.vocabulary import PERMISSIONS
from plone.folder.nogopip import GopipIndex
from plone.restapi.serializer import utils
from Products.ZCatalog.Catalog import Catalog
from redturtle.volto.catalogplan import Catalog_sorted_search_indexes
from zope.i18nmessageid import MessageFactory
from ZTUtils.Lazy import LazyCat
from ZTUtils.Lazy import LazyMap

import logging
import re

from redturtle.volto.catalogplan import Catalog_sorted_search_indexes

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion src/redturtle/volto/adapters/stringinterp.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
from plone.stringinterp.adapters import BaseSubstitution
from Products.CMFCore.interfaces import IContentish
from redturtle.volto import _
from zope.component import adapter

from redturtle.volto import _

try:
from plone.stringinterp import _ as stringinterp_mf
Expand Down
1 change: 1 addition & 0 deletions src/redturtle/volto/browser/controlpanel.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from plone.app.registry.browser.controlpanel import ControlPanelFormWrapper
from plone.app.registry.browser.controlpanel import RegistryEditForm

from redturtle.volto import _
from redturtle.volto.interfaces import IRedTurtleVoltoSettings

Expand Down
9 changes: 4 additions & 5 deletions src/redturtle/volto/browser/find_blocks.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# -*- coding: utf-8 -*-
from Acquisition import aq_base
import json
import logging
from copy import deepcopy

from Acquisition import aq_base
from plone import api
from plone.dexterity.utils import iterSchemata
from Products.Five import BrowserView
from zope.schema import getFieldsInOrder

import json
import logging


logger = logging.getLogger(__name__)

BLOCKS = [
Expand Down
22 changes: 16 additions & 6 deletions src/redturtle/volto/browser/fix_links.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# -*- coding: utf-8 -*-
import json
import logging
import re
from urllib.parse import urlparse
from urllib.parse import urlunparse

from Acquisition import aq_base
from plone import api
from plone.dexterity.utils import iterSchemata
Expand All @@ -7,11 +13,6 @@
from zope.component import queryMultiAdapter
from zope.schema import getFieldsInOrder

import json
import logging
import re


logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -68,6 +69,7 @@ def __call__(self):
# set the new value anyway because some values could not be transformed,
# but they now have the right url anyway.
setattr(item, name, res["new_value"])
item.reindexObject()
i += 1
logger.info("### END ###")
logger.info("### {} items fixed ###".format(len(fixed_objects)))
Expand All @@ -94,6 +96,10 @@ def check_pattern(self, value):
return True

def replace_pattern(self, value, is_link=False):
# obtain data to make link sub evaluation
current_host = urlparse(self.request.URL).netloc
destination_host = urlparse(self.portal_url).netloc

for url in self.request.form.get("to_replace", "").split():
match = re.search(r"(?<={}).*".format(url), value)
if match:
Expand All @@ -106,7 +112,11 @@ def replace_pattern(self, value, is_link=False):
return value
if obj:
if is_link:
return "${portal_url}/resolveuid/" + obj.UID()
if current_host != destination_host:
new_url = urlparse(value)._replace(netloc=destination_host)
return urlunparse(new_url)
else:
return "${portal_url}/resolveuid/" + obj.UID()
else:
return obj.UID()
return value
Expand Down
4 changes: 2 additions & 2 deletions src/redturtle/volto/browser/sitemap.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# -*- coding: utf-8 -*-
import datetime

from BTrees.OOBTree import OOBTree
from plone.app.layout.sitemap.sitemap import SiteMapView as LayoutSiteMapView
from plone.registry.interfaces import IRegistry
from Products.CMFCore.utils import getToolByName
from Products.CMFPlone.interfaces import IPloneSiteRoot
from zope.component import getUtility

import datetime


class SiteMapView(LayoutSiteMapView):
def objects(self):
Expand Down
1 change: 0 additions & 1 deletion src/redturtle/volto/config/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os


MAX_LIMIT = int(os.environ.get("REDTURTLE_VOLTO_MAX_LIMIT_SEARCH") or 500)
3 changes: 2 additions & 1 deletion src/redturtle/volto/interfaces.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# -*- coding: utf-8 -*-
from plone.restapi.controlpanels.interfaces import IControlpanel
from redturtle.volto import _
from zope.interface import Interface
from zope.publisher.interfaces.browser import IDefaultBrowserLayer
from zope.schema import Bool

from redturtle.volto import _


class IRedturtleVoltoLayer(IDefaultBrowserLayer):
"""Marker interface that defines a browser layer."""
Expand Down
2 changes: 1 addition & 1 deletion src/redturtle/volto/locales/update.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-

import os
import pkg_resources
import subprocess

import pkg_resources

domain = "redturtle.volto"
os.chdir(pkg_resources.resource_filename(domain, ""))
Expand Down
Loading

0 comments on commit 3e39746

Please sign in to comment.