Skip to content

Commit a9f80d1

Browse files
authored
fix: Form entries admin compatibility with latest django-entangled (#32)
* fix: Form entries admin compatibility with latest django-entangled * fix: test requirements * fix: flake8 issues * fix: flake8 the second * Update test matrix * fix: Update test settings * add admin tests * Move to ruff * fix ruff issue * fix: pin pre-commits * upgrade github actions * fix imports in tests * ruff format * Updat test action * update readme * remove old badge from readme
1 parent 0b037a0 commit a9f80d1

30 files changed

+687
-364
lines changed

.github/workflows/codecov.yml

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,36 +12,44 @@ jobs:
1212
strategy:
1313
fail-fast: false
1414
matrix:
15-
python-version: [ 3.9, "3.10", "3.11", "3.12"] # latest release minus two
15+
python-version: [ "3.10", "3.11", "3.12", "3.13"] # latest release minus two
1616
requirements-file: [
1717
dj42_cms311.txt,
1818
dj42_cms41.txt,
1919
dj50_cms41.txt,
2020
dj51_cms41.txt,
21+
dj52_cms41.txt,
22+
dj52_cms50.txt,
2123
]
2224
os: [
2325
ubuntu-latest,
2426
]
25-
exclude:
26-
- python-version: 3.9
27-
requirements-file: dj50_cms41.txt
28-
- python-version: 3.9
29-
requirements-file: dj51_cms41.txt
3027

3128
steps:
32-
- uses: actions/checkout@v3
29+
- uses: actions/checkout@v4
3330
with:
3431
fetch-depth: '2'
3532

3633
- name: Setup Python
37-
uses: actions/setup-python@master
34+
uses: actions/setup-python@v5
3835
with:
3936
python-version: ${{ matrix.python-version }}
37+
- name: Install dependencies
38+
run: |
39+
python -m pip install --upgrade pip setuptools wheel
40+
python -m pip install -r tests/requirements/${{ matrix.requirements-file }}
41+
python -m pip install -e .
4042
- name: Generate Report
4143
run: |
42-
pip install -r tests/requirements/${{ matrix.requirements-file }}
43-
pip install -e .
4444
coverage run ./run_tests.py
45-
- name: Upload Coverage to Codecov
46-
uses: codecov/codecov-action@v3
45+
- name: Generate XML report
46+
run: |
47+
coverage xml
48+
- name: Upload coverage artifact (for CI consumption)
49+
uses: actions/upload-artifact@v4
50+
with:
51+
name: coverage-xml-${{ matrix.python-version }}-${{ matrix.requirements-file }}
52+
path: coverage.xml
53+
# If you need to upload to Codecov, prefer their minimal uploader binary or pin the action by SHA.
54+
# Upload to Codecov is intentionally omitted here to avoid unpinned third-party actions.
4755

.github/workflows/codeql-analysis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ jobs:
3838

3939
steps:
4040
- name: Checkout repository
41-
uses: actions/checkout@v3
41+
uses: actions/checkout@v4
4242

4343
# Initializes the CodeQL tools for scanning.
4444
- name: Initialize CodeQL
45-
uses: github/codeql-action/init@v2
45+
uses: github/codeql-action/init@v3
4646
with:
4747
languages: ${{ matrix.language }}
4848
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -53,7 +53,7 @@ jobs:
5353
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5454
# If this step fails, then you should remove it and run the build manually (see below)
5555
- name: Autobuild
56-
uses: github/codeql-action/autobuild@v1
56+
uses: github/codeql-action/autobuild@v3
5757

5858
# ℹ️ Command-line programs to run using the OS shell.
5959
# 📚 https://git.io/JvXDl
@@ -67,4 +67,4 @@ jobs:
6767
# make release
6868

6969
- name: Perform CodeQL Analysis
70-
uses: github/codeql-action/analyze@v2
70+
uses: github/codeql-action/analyze@v3

.github/workflows/docs.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ jobs:
1212
name: build
1313
steps:
1414
- name: Checkout
15-
uses: actions/checkout@v3
15+
uses: actions/checkout@v4
1616
- name: Set up Python
17-
uses: actions/setup-python@v4
17+
uses: actions/setup-python@v5
1818
with:
1919
python-version: '3.9'
2020
cache: 'pip'
2121
- name: Cache dependencies
22-
uses: actions/cache@v3
22+
uses: actions/cache@v4
2323
with:
2424
path: ~/.cache/pip
2525
key: ${{ runner.os }}-pip-${{ hashFiles('docs/requirements.txt') }}
@@ -38,14 +38,14 @@ jobs:
3838
needs: build
3939
steps:
4040
- name: Checkout
41-
uses: actions/checkout@v3
41+
uses: actions/checkout@v4
4242
- name: Set up Python
43-
uses: actions/setup-python@v4
43+
uses: actions/setup-python@v5
4444
with:
4545
python-version: '3.9'
4646
cache: 'pip'
4747
- name: Cache dependencies
48-
uses: actions/cache@v3
48+
uses: actions/cache@v4
4949
with:
5050
path: ~/.cache/pip
5151
key: ${{ runner.os }}-pip-${{ hashFiles('docs/requirements.txt') }}

.github/workflows/lint-pr.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ jobs:
1515
name: Validate PR title
1616
runs-on: ubuntu-latest
1717
steps:
18-
- uses: amannn/action-semantic-pull-request@v4
19-
env:
20-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
- name: Validate PR title (Conventional Commits)
19+
uses: actions/github-script@v7
20+
with:
21+
script: |
22+
const title = context.payload.pull_request && context.payload.pull_request.title;
23+
if (!title) {
24+
core.setFailed('No pull request title found.');
25+
}
26+
// Conventional commit regex (type(scope)?: subject)
27+
const re = /^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\([\w\-\.]+\))?!?:\s.+/;
28+
if (!re.test(title)) {
29+
core.setFailed(`PR title is not a valid Conventional Commit: "${title}"`);
30+
}

.github/workflows/lint.yml

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,19 @@ concurrency:
77
cancel-in-progress: true
88

99
jobs:
10-
flake8:
11-
name: flake8
10+
ruff:
11+
name: Ruff
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Checkout
15-
uses: actions/checkout@v3
15+
uses: actions/checkout@v4
1616
- name: Set up Python
17-
uses: actions/setup-python@v4
17+
uses: actions/setup-python@v5
1818
with:
19-
python-version: 3.9
20-
- name: Install flake8
21-
run: pip install --upgrade flake8
22-
- name: Run flake8
23-
uses: liskin/gh-problem-matcher-wrap@v1
24-
with:
25-
linters: flake8
26-
run: flake8
27-
28-
isort:
29-
runs-on: ubuntu-latest
30-
steps:
31-
- name: Checkout
32-
uses: actions/checkout@v3
33-
- name: Set up Python
34-
uses: actions/setup-python@v4
35-
with:
36-
python-version: 3.9
37-
- run: python -m pip install isort
38-
- name: isort
39-
uses: liskin/gh-problem-matcher-wrap@v1
40-
with:
41-
linters: isort
42-
run: isort --check --diff djangocms_form_builder
19+
python-version: '3.x'
20+
- name: Install Ruff
21+
run: python -m pip install --upgrade ruff
22+
- name: Ruff check
23+
run: ruff check .
24+
- name: Ruff format (check only)
25+
run: ruff format --check

.github/workflows/publish-to-live-pypi.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ jobs:
1010
name: Build and publish Python 🐍 distributions 📦 to pypi
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@master
13+
- uses: actions/checkout@v4
1414
- name: Set up Python 3.10
15-
uses: actions/setup-python@v4
15+
uses: actions/setup-python@v5
1616
with:
1717
python-version: '3.10'
1818

@@ -31,9 +31,12 @@ jobs:
3131
--outdir dist/
3232
.
3333
34+
- name: Install twine
35+
run: python -m pip install --upgrade twine
3436
- name: Publish distribution 📦 to PyPI
3537
if: startsWith(github.ref, 'refs/tags')
36-
uses: pypa/gh-action-pypi-publish@release/v1
37-
with:
38-
user: __token__
39-
password: ${{ secrets.PYPI_API_TOKEN }}
38+
env:
39+
TWINE_USERNAME: __token__
40+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
41+
run: >-
42+
python -m twine upload dist/*

.github/workflows/publish-to-test-pypi.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ jobs:
1313
name: Build and publish Python 🐍 distributions 📦 to TestPyPI
1414
runs-on: ubuntu-latest
1515
steps:
16-
- uses: actions/checkout@master
16+
- uses: actions/checkout@v4
1717
- name: Set up Python 3.10
18-
uses: actions/setup-python@v4
18+
uses: actions/setup-python@v5
1919
with:
2020
python-version: '3.10'
2121

@@ -34,11 +34,11 @@ jobs:
3434
--outdir dist/
3535
.
3636
37+
- name: Install twine
38+
run: python -m pip install --upgrade twine
3739
- name: Publish distribution 📦 to Test PyPI
38-
uses: pypa/gh-action-pypi-publish@release/v1
39-
with:
40-
user: __token__
41-
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
42-
repository_url: https://test.pypi.org/legacy/
43-
skip_existing: true
44-
verbose: true
40+
env:
41+
TWINE_USERNAME: __token__
42+
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
43+
run: >-
44+
python -m twine upload --repository-url https://test.pypi.org/legacy/ --skip-existing dist/*

.pre-commit-config.yaml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,17 @@ ci:
33

44
repos:
55
- repo: https://github.com/asottile/pyupgrade
6-
rev: v2.32.1
6+
rev: f90119b1b8bd9e46949d9592972b2c4c27d62a97 # frozen: v3.21.0
77
hooks:
88
- id: pyupgrade
9-
args: [ "--py38-plus" ]
9+
args: [ "--py310-plus" ]
1010
- repo: https://github.com/adamchainz/django-upgrade
11-
rev: '1.16.0'
11+
rev: '553731fe59437e0bd2cf18b10144116422bed259' # frozen: 1.29.1
1212
hooks:
1313
- id: django-upgrade
1414
args: [ --target-version, "4.2" ]
15+
- repo: https://github.com/astral-sh/ruff-pre-commit
16+
rev: aad66557af3b56ba6d4d69cd1b6cba87cef50cbb # frozen: v0.14.3
17+
hooks:
18+
- id: ruff
19+
- id: ruff-format

README.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
django CMS form builder
33
########################
44

5-
|pypi| |coverage| |python| |django| |djangocms| |djangocms4|
5+
|pypi| |coverage| |python| |django| |djangocms|
66

77
**djangocms-form-builder** supports rendering of styled forms. The objective is to tightly integrate forms in the website design. **djangocms-form-builder** allows as many forms as you wish on one page. All forms are **xhr-based**. To this end, **djangocms-form-builder** extends the django CMS plugin model allowing a form plugin to receive xhr post requests.
88

@@ -175,14 +175,14 @@ Actions are not available for Django forms. Any actions to be performed upon sub
175175
.. |coverage| image:: https://codecov.io/gh/django-cms/djangocms-form-builder/branch/main/graph/badge.svg
176176
:target: https://codecov.io/gh/django-cms/djangocms-form-builder
177177

178-
.. |python| image:: https://img.shields.io/badge/python-3.7+-blue.svg
179-
:target: https://pypi.org/project/djangocms-form-builder/
178+
.. |python| image:: https://img.shields.io/pypi/pyversions/djangocms-form-builder
179+
:alt: PyPI - Python Version
180+
:target: https://pypi.org/project/djangocms-form-builder/
180181

181-
.. |django| image:: https://img.shields.io/badge/django-3.2-blue.svg
182-
:target: https://www.djangoproject.com/
182+
.. |django| image:: https://img.shields.io/pypi/frameworkversions/django/djangocms-form-builder
183+
:alt: PyPI - Django Versions from Framework Classifiers
184+
:target: https://www.djangoproject.com/
183185

184-
.. |djangocms| image:: https://img.shields.io/badge/django%20CMS-3.8%2B-blue.svg
185-
:target: https://www.django-cms.org/
186-
187-
.. |djangocms4| image:: https://img.shields.io/badge/django%20CMS-4-blue.svg
188-
:target: https://www.django-cms.org/
186+
.. |djangocms| image:: https://img.shields.io/pypi/frameworkversions/django-cms/djangocms-form-builder
187+
:alt: PyPI - django CMS Versions from Framework Classifiers
188+
:target: https://www.django-cms.org/

djangocms_form_builder/actions.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,9 @@ class Meta:
290290
def __init__(self, *args, **kwargs):
291291
super().__init__(*args, **kwargs)
292292
if args:
293-
self.fields["redirect_link"].required = get_hash(RedirectAction) in args[0].get("form_actions", [])
293+
self.fields["redirect_link"].required = get_hash(
294+
RedirectAction
295+
) in args[0].get("form_actions", [])
294296

295297
def execute(self, form, request):
296298
form.Meta.options["redirect"] = get_link(

0 commit comments

Comments
 (0)