Skip to content

Commit baec343

Browse files
chris-adamducheneangbastienalexnuttincksgeulette
authored
Plone 6.1 gha and tests (#66)
* Fixed an issue in search and replace (#61) * Add test about None filename issue in search and replace * Fixed an issue in search and replace * Fixed issue in DXDocumentGenerationHelperView.check_permission * Next version will be 4.0 * Libreoffice docker image from harbor (#63) Signed-off-by: Alexandre Nuttinck <alexandre.nuttinck@imio.be> * Replaced `six.u()` by safe_unicode() to handle unicode strings * Added plone 6.1 gha * Changed imio.helpers branch to plone61 * Removed plone 6.1 from test coverage step (keeping plone 6.1) * Changed python version from 3.13 to 3.12 * Changed python version from 3.12 to 3.13 * Fixed tests for plone 6 --------- Signed-off-by: Alexandre Nuttinck <alexandre.nuttinck@imio.be> Co-authored-by: Antoine Duchêne <antoine.duchene@imio.be> Co-authored-by: Gauthier Bastien <gauthier.bastien@imio.be> Co-authored-by: Alexandre Nuttinck <alexandre.nuttinck@imio.be> Co-authored-by: Stephan Geulette <s.geulette@imio.be>
1 parent 084608b commit baec343

File tree

20 files changed

+241
-86
lines changed

20 files changed

+241
-86
lines changed

.github/workflows/python-package.yml

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010

1111
jobs:
1212
test:
13-
runs-on: ubuntu-22.04
13+
runs-on: ubuntu-24.04
1414
strategy:
1515
fail-fast: false
1616
matrix:
@@ -21,40 +21,41 @@ jobs:
2121
plone: 5.2
2222
- python: 3.10.11
2323
plone: "6.0"
24+
- python: 3.12.7
25+
plone: "6.1"
2426
services:
2527
libreoffice:
26-
image: imiobe/libreoffice:7.3
28+
image: harbor.imio.be/library/libreoffice:7.3
2729
ports:
2830
- 2002:2002
2931
volumes:
3032
- /tmp:/tmp
3133
- /var/tmp:/var/tmp
3234
steps:
3335
- name: Checkout
34-
uses: actions/checkout@v3
36+
uses: actions/checkout@v4
3537
- name: Setup Env
3638
run: |
3739
mkdir -p -m 777 /tmp/appy/
3840
sudo add-apt-repository ppa:libreoffice/ppa -y
3941
sudo apt update -qq -y
40-
sudo apt-get install -qq -y libreoffice libreoffice-script-provider-python
42+
sudo apt-get install -qq -y libreoffice libreoffice-script-provider-python libjpeg62 libjpeg62-dev libbz2-dev
4143
mkdir -p buildout-cache/{eggs,downloads}
4244
- name: Set up pyenv and Python
43-
uses: "gabrielfalcao/pyenv-action@v14"
45+
uses: "gabrielfalcao/pyenv-action@v18"
4446
with:
4547
default: "${{ matrix.python }}"
4648
- name: Setup Python env
4749
run: |
4850
pip install --upgrade pip
4951
pip install -r requirements-${{ matrix.plone }}.txt
5052
- name: Cache eggs
51-
uses: actions/cache@v2
53+
uses: actions/cache@v4
5254
env:
5355
cache-name: cache-eggs
5456
with:
5557
path: ~/buildout-cache/eggs
56-
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ matrix.plone }}
57-
restore-keys: ${{ runner.os }}-test-${{ env.cache-name }}-${{ matrix.plone }}
58+
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ matrix.python }}-${{ matrix.plone }}
5859
- name: buildout
5960
run: |
6061
sed -ie "s#test.cfg#test-${{matrix.plone}}.cfg#" gha.cfg
@@ -64,24 +65,24 @@ jobs:
6465
run: |
6566
bin/test -t !robot
6667
coverage:
67-
runs-on: ubuntu-22.04
68+
runs-on: ubuntu-24.04
6869
strategy:
6970
fail-fast: false
7071
matrix:
7172
include:
72-
- python: 3.10.11
73-
plone: "6.0"
73+
- python: 3.12.7
74+
plone: "6.1"
7475
services:
7576
libreoffice:
76-
image: imiobe/libreoffice:7.3
77+
image: harbor.imio.be/library/libreoffice:7.3
7778
ports:
7879
- 2002:2002
7980
volumes:
8081
- /tmp:/tmp
8182
- /var/tmp:/var/tmp
8283
steps:
8384
- name: Checkout
84-
uses: actions/checkout@v3
85+
uses: actions/checkout@v4
8586
- name: Setup Env
8687
run: |
8788
mkdir -p -m 777 /tmp/appy/
@@ -90,7 +91,7 @@ jobs:
9091
sudo apt-get install -qq -y libreoffice libreoffice-script-provider-python
9192
mkdir -p buildout-cache/{eggs,downloads}
9293
- name: Set up pyenv and Python
93-
uses: "gabrielfalcao/pyenv-action@v14"
94+
uses: "gabrielfalcao/pyenv-action@v18"
9495
with:
9596
default: "${{ matrix.python }}"
9697
- name: Setup Python env
@@ -99,20 +100,16 @@ jobs:
99100
pip install -r requirements-${{ matrix.plone }}.txt
100101
pip install -U coveralls
101102
- name: Cache eggs
102-
uses: actions/cache@v2
103+
uses: actions/cache@v4
103104
env:
104105
cache-name: cache-eggs
105106
with:
106107
path: ~/buildout-cache/eggs
107-
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ matrix.plone }}
108-
restore-keys: ${{ runner.os }}-test-${{ env.cache-name }}-${{ matrix.plone }}
108+
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ matrix.python }}-${{ matrix.plone }}
109109
- name: buildout
110110
run: |
111111
sed -ie "s#test.cfg#test-${{matrix.plone}}.cfg#" gha.cfg
112112
buildout -c gha.cfg
113-
- name: code-analysis
114-
run: |
115-
bin/code-analysis
116113
- name: test coverage
117114
run: |
118115
bin/coverage run bin/test -t !robot

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,5 @@ nosetests.xml
4949
# Pycharm
5050
/.idea/
5151
/pip-selfcheck.json
52+
53+
CACHEDIR.TAG

CHANGES.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@ Changelog
66

77
- Python 3, Plone 5.2 and Plone 6.0 compatible.
88
[aduchene]
9-
9+
- Added Plone 6.1 version in buildout.
10+
[chris-adam]
11+
- Fixed an issue when odt_file.filename could be None when searching and replacing.
12+
[aduchene]
13+
- Fixed an issue with `helper.dexterity.DXDocumentGenerationHelperView.check_permission` raising when it should not.
14+
[aduchene]
15+
- Replaced `six.u()` by safe_unicode() to handle unicode strings.
16+
[sgeulette]
1017

1118
3.43 (2024-04-10)
1219
-----------------

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ startlibreoffice:
4242
--name="oo_server" \
4343
-v /tmp:/tmp \
4444
-v /var/tmp:/var/tmp \
45-
imiobe/libreoffice:$(lo_version)
45+
harbor.imio.be/library/libreoffice:$(lo_version)
4646
docker ps
4747

4848
stoplibreoffice:

base.cfg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ extensions +=
1515

1616
always-checkout = force
1717
sources = sources
18-
auto-checkout =
18+
auto-checkout +=
19+
imio.helpers
1920

2021
sources-dir = devel
2122

development.cfg

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,19 @@ eggs =
9494
${test:eggs}
9595
plone.app.robotframework[reload]
9696

97-
[code-analysis]
98-
flake8-max-complexity = 50
99-
flake8-ignore = E501, W503, W504, E203, Q000, C812
97+
[coverage]
98+
recipe = zc.recipe.egg
99+
eggs = coverage
100+
101+
[test-coverage]
102+
recipe = collective.recipe.template
103+
input = inline:
104+
#!/bin/bash
105+
export TZ=UTC
106+
${buildout:directory}/bin/coverage run bin/test $*
107+
${buildout:directory}/bin/coverage html
108+
${buildout:directory}/bin/coverage report -m --fail-under=90
109+
# Fail (exit status 1) if coverage returns exit status 2 (this happens
110+
# when test coverage is below 100%.
111+
output = ${buildout:directory}/bin/test-coverage
112+
mode = 755

requirements-6.1.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-c https://dist.plone.org/release/6.1-latest/requirements.txt
2+
setuptools
3+
zc.buildout

setup.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
setup(
1313
name='collective.documentgenerator',
14-
version='3.44.dev0',
14+
version='4.0.dev0',
1515
description="Desktop document generation (.odt, .pdf, .doc, ...) based on appy framework (https://appyframe.work/tool/public) and OpenOffice/LibreOffice",
1616
long_description=long_description,
1717
# Get more from https://pypi.org/pypi?%3Aaction=list_classifiers
@@ -22,10 +22,14 @@
2222
"Framework :: Plone :: 4.3",
2323
"Framework :: Plone :: 5.0",
2424
"Framework :: Plone :: 5.1",
25+
"Framework :: Plone :: 6.0",
26+
"Framework :: Plone :: 6.1",
2527
"Framework :: Plone :: Addon",
2628
"License :: OSI Approved :: GNU General Public License (GPL)",
2729
"Programming Language :: Python",
2830
"Programming Language :: Python :: 2.7",
31+
"Programming Language :: Python :: 3.10",
32+
"Programming Language :: Python :: 3.13",
2933
],
3034
keywords='plone document generation generator odt word pdf libreoffice template',
3135
author='Simon Delcourt',
@@ -53,7 +57,7 @@
5357
'z3c.table',
5458
# fix about orderedselect
5559
'z3c.form>=3.2.4',
56-
'imio.helpers>=0.57',
60+
'imio.helpers>=1.0',
5761
'imio.migrator>=1.11'
5862
],
5963
extras_require={

src/collective/documentgenerator/browser/controlpanel.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from plone.app.registry.browser.controlpanel import RegistryEditForm
1212
from Products.CMFPlone.utils import safe_unicode
1313
from Products.statusmessages.interfaces import IStatusMessage
14-
from six import u
1514
from z3c.form import button
1615
from zope import schema
1716
from zope.interface import implementer
@@ -61,7 +60,7 @@ class IDocumentGeneratorControlPanelSchema(Interface):
6160
title=_(u"oo_port_list"),
6261
description=_(u'Port Number(s) of OO.'),
6362
required=False,
64-
default=u(os.getenv('OO_PORT', DEFAULT_OO_PORT))
63+
default=safe_unicode(os.getenv('OO_PORT', DEFAULT_OO_PORT))
6564
)
6665

6766
uno_path = schema.TextLine(

src/collective/documentgenerator/helper/dexterity.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# -*- coding: utf-8 -*-
22
"""Helper view for dexterity content types."""
3-
43
from ..interfaces import IFieldRendererForDocument
54
from .base import DisplayProxyObject
65
from .base import DocumentGenerationHelperView
6+
from AccessControl import getSecurityManager
77
from bs4 import BeautifulSoup as Soup
88
from collective.excelexport.exportables.dexterityfields import get_ordered_fields
99
from imio.helpers.content import get_relations as ih_get_relations
@@ -81,8 +81,10 @@ def check_permission(self, field_name):
8181
if permission is None:
8282
return True
8383

84-
user = api.user.get_current()
85-
return api.user.has_permission(permission, user=user, obj=self.real_context)
84+
# We can't use plone.api.user.has_permission anymore since
85+
# https://github.com/plone/plone.api/pull/526 as we pass a permission id and if
86+
# we don't have the perm, it raises now
87+
return bool(getSecurityManager().checkPermission(permission, self.real_context))
8688

8789
def get_value(self, field_name, obj=None, default=None, as_utf8=False, strict=True):
8890
"""Get value of field_name for obj

0 commit comments

Comments
 (0)