Skip to content

Commit

Permalink
Merge branch 'main' into facet_count
Browse files Browse the repository at this point in the history
  • Loading branch information
avoinea authored Mar 19, 2024
2 parents 59090a4 + e62bea2 commit 4fb6df2
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 19 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.8]
python-version: [3.12]

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

# python setup
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/flake8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.8]
python-version: [3.11]

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

# python setup
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pyroma.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.8]
python-version: [3.12]

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

# python setup
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ jobs:
plone-version: "6.0"
steps:
# git checkout
- uses: actions/checkout@v3
- uses: actions/checkout@v4

# python setup
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
Expand Down Expand Up @@ -54,7 +54,7 @@ jobs:

# build sphinx
- name: sphinx
run: if [ "${{ matrix.plone-version }}" == "6.0" ] && [ ${{ matrix.python-version }} == '3.9' ]; then make docs-html; fi
run: if [ "${{ matrix.plone-version }}" == "6.0" ] && [ ${{ matrix.python-version }} == '3.12' ]; then make docs-html; fi

# test
- name: test
Expand All @@ -69,4 +69,4 @@ jobs:

# test for broken links
- name: linkcheck
run: if [ "${{ matrix.plone-version }}" == "6.0" ] && [ ${{ matrix.python-version }} == '3.9' ]; then make docs-linkcheckbroken; fi
run: if [ "${{ matrix.plone-version }}" == "6.0" ] && [ ${{ matrix.python-version }} == '3.12' ]; then make docs-linkcheckbroken; fi
6 changes: 3 additions & 3 deletions .github/workflows/zpretty.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.8]
python-version: [3.12]

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

# python setup
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
Expand Down
1 change: 1 addition & 0 deletions news/1758.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use the ``mode`` parameter instead of ``direction`` when calling the ``scale`` method. Also change value to ``scale`. @wesleybl
1 change: 1 addition & 0 deletions news/1762.internal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Bump all the versions in GitHub workflows. @stevepiercy
7 changes: 7 additions & 0 deletions src/plone/restapi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
from . import patches # noqa: ignore=F401
from AccessControl import allow_module
from AccessControl.Permissions import add_user_folders
from importlib import import_module
from plone.restapi.pas import plugin
from Products.PluggableAuthService.PluggableAuthService import registerMultiPlugin
from zope.i18nmessageid import MessageFactory

import pkg_resources


try:
pkg_resources.get_distribution("plone.app.multilingual")
HAS_MULTILINGUAL = True
Expand All @@ -19,6 +21,11 @@

allow_module("json")

# BBB: Plone 5.2
HAS_PLONE_6 = getattr(
import_module("Products.CMFPlone.factory"), "PLONE60MARKER", False
)


def initialize(context):
registerMultiPlugin(plugin.JWTAuthenticationPlugin.meta_type)
Expand Down
14 changes: 11 additions & 3 deletions src/plone/restapi/imaging.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
from plone.restapi import HAS_PLONE_6
from zope.component import getMultiAdapter
from zope.component import getUtility
from zope.globalrequest import getRequest


if HAS_PLONE_6:
# In Plone 6.0+, we must use the mode parameter
scale_parameter = {"mode": "scale"}
else:
# BBB: In Plone 5.2, it is necessary to use the direction parameter.
scale_parameter = {"direction": "thumbnail"}


def get_scales(context, field, width, height):
"""Get a dictionary of available scales for a particular image field,
with the actual dimensions (aspect ratio of the original image).
Expand Down Expand Up @@ -51,9 +60,8 @@ def get_original_image_url(context, fieldname, width, height):
scale_flags = {}
if hasattr(images_view, "picture"):
scale_flags["pre"] = True
scale = images_view.scale(
fieldname, width=width, height=height, direction="thumbnail", **scale_flags
)
parameters = {**scale_flags, **scale_parameter}
scale = images_view.scale(fieldname, width=width, height=height, **parameters)
if scale:
return scale.url
# Corrupt images may not have a scale.
Expand Down

0 comments on commit 4fb6df2

Please sign in to comment.