Skip to content

Commit 5069d82

Browse files
fsbraunadam-murrayAiky30Bernardvdvmichaeljcollinsuk
authored
feat: Universal snippet for django CMS 3 and 4 (#160)
* djangocms-versioning compatibility - Initial Model and cms_config implementation (#75) * feat: Snippet CMS 4.0 and djangocms-versioning Data migration (#74) * feat: Moderation compatibility and version copy method implementation (#77) * feat: Versioning Compatibility Changes (#79) * fix: Fixed bug that causes ChangeView not to use SnippetForm (#80) * feat: Reworked form fields and added the ability to show draft snippets (#81) * fix: Adding valid HTML to the add snippet form throws an error (#82) * fix: form initialisation error in read-only mode (#83) * fix: History URL button broken link on the Snippets change form (#84) * fix: Draft snippet render error due to draft snippets (#86) * feat: Default versioning import user id setting can be set via environment variable (#89) * Release 4.0.0.dev1 (#91) * fix: django-cms 4.0.x - Remove breaking django-treebeard pinning issue (#93) * Release 4.0.0.dev2 (#95) * feat: Removing slug field and hyperlink from list display when versioning is enabled (#98) * fix: Snippet plugin showing ID instead of name(#100) * Fix: Compare view removed unnecessary template logic (#101) * Release 4.0.0.dev3 (#103) * feat: Preview icon renders content in read only (#102) * Release 4.0.0.dev4 (#109) * fix: Added test coverage to admin preview view (#96) * port-feat: pre-commit config added from the v3 workstream (#117) Changes partially taken from this change: a56091c Requires additional work when the django-cms 4.0 workstream is official, the version bump code has been ignored because it would generate official releases only: #116 * feat: django-cms 4.0.x - django 3.2 and Python 3.9 compatibility (#92) * Release 4.0.1.dev1 (#119) * feat: Enable add button on the SnippetPluginForm (#127) * Release 4.0.1.dev2 (#128) * init support for django4.2 (#150) * init support for django4.2 * add change log for add compatiable for django 4.2 and python 3.10 * Update CHANGELOG.rst * Update .pre-commit-config.yaml * fix lint config issue * remove test code * add blackline for flake8 * add pyproject.toml file * add requirement files * fix ci failed issue * format setup.py import section * upgrade isort version to fix pre commit ci issue * upgrade the django-upgrade package to pass through the pre commit ci test * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * upgrade packages in pre commit * resort init file changes * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * comment the django-upgrade from ci * fix: add missing migration file * fix: update previous file instead of creating new file --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Josh Peng Yu <joshyupeng@gmail.com> * fix pyproject.toml config error (#151) * Added site field in models n site filter in admin (#159) * Added site field in models n site filter in admin * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * updated versioning branch * Add test cases and updated the implementation * Update CHANGELOG.rst Co-authored-by: Mark Walker <theshow@gmail.com> * corrected formatting * fixed flake8 issues * removed list_filter --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Mark Walker <theshow@gmail.com> * Release/4.1.0 (#155) * bump version to 4.1.0 * bump version to 4.1.0 pyproject.toml * replace test requirement url * update changelog date * update release date. * Update README.rst * Update README.rst * Create PULL_REQUEST_TEMPLATE.md (#85) Add PR template * Only include badges at the top to avoid confusion & removed old badges like travis. (#106) * Added pypi github actions (#108) * FEATURE: adjust setup metadata (#110) * correct doc about default value of DJANGOCMS_SNIPPET_CACHE (#120) * Update to ace 1.9.6, load ace editor from static files if djangocms_static_ace is installed, add dark mode (#123) Fix: Load ace editor from static files if `djangocms-static-ace` is installed Fix: Respect if user has set dark mode Add: Weak dependency on djangocms-static-ace Doc: optional static-ace dependency * ci: Update pypi action branch names (#125) * Bump version: 3.0.0 → 3.1.0 (#126) * fix: django-cms 3.x - Remove breaking django-treebeard pinning issue (#94) * Removed pinning. * Update setup.py --------- Co-authored-by: Fabian Braun <fsbraun@gmx.de> * fix: add noop django 4 migration (#134) * fix: add noop django 4 migration * fix: isort * ci: Prepare release of version 3.1.1 (#139) * Update CHANGELOG.rst * Bump version * Pin treebeard for Django CMS 3.7 tests * Update dj30_cms37.txt * chore: Package overhaul (#140) * ci: Update pre-commit * ci: Run ruff formatter * build: Move package in to src dir * test: Update requirements building * chore: Keeping git happy after moving to src * ci: Add dependabot config * ci: Update tests to run tox * build: Project config * test: Update tox setup * build: Update setup to build_meta * ci: Update pypi workflows * ci: Update linter to ruff * chore: Fix RUF012 * ci: Update linter trigger * chore: Drop python 3.8 * chore: Drop python 3.8 * chore: Adjust coverage config * fix: Test pypi workflow * Bump actions/setup-python from 4 to 5 (#148) Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4 to 5. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](actions/setup-python@v4...v5) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * fix: Test only for migrations within package * Update tests * run tests on all branches * fix tests * Update readme, changelog * Fix common test suite for django CMS 3.11, 4.0, and 4.1 * Update CHANGELOG * Merge branches together * Update precommit-config * fix: ruff precommit * ci: auto fixes from pre-commit hooks for more information, see https://pre-commit.ci * fix: ruff issues * More ruff fixes * Update pyproject.toml * ci: auto fixes from pre-commit hooks for more information, see https://pre-commit.ci * fix: Remove isort and flake8 from setup.cfg * ci: auto fixes from pre-commit hooks for more information, see https://pre-commit.ci * Update setup.cfg * Fix: universal branch (#167) * fix: manifest.in * fix: SnippetAdmin use overrdden change_form_template * ci: auto fixes from pre-commit hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * Update lint workflow --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Adam Murray <adam-murray@hotmail.co.uk> Co-authored-by: Aiky30 <Aiky30@users.noreply.github.com> Co-authored-by: Bernard Van Der Vyver <Bvdv9075@gmail.com> Co-authored-by: Michael Collins <15347726+michaeljcollinsuk@users.noreply.github.com> Co-authored-by: 傅瑞曼 <yxzfreeman@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Josh Peng Yu <joshyupeng@gmail.com> Co-authored-by: Vipul Narang <61502917+vipulnarang95@users.noreply.github.com> Co-authored-by: Mark Walker <theshow@gmail.com> Co-authored-by: Nicolai <69975577+NicolaiRidani@users.noreply.github.com> Co-authored-by: Kaushal Dhungel <57295839+Kaushal-Dhungel@users.noreply.github.com> Co-authored-by: Simon Krull <simondotunix@gmail.com> Co-authored-by: Liumeo <liumeo@pku.edu.cn> Co-authored-by: Mark Walker <mark.walker@realbuzz.com> Co-authored-by: Patrik <LuckyType@users.noreply.github.com> Co-authored-by: Mark Walker <mark@django-cms.org> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Josh Yu <joshyu@users.noreply.github.com>
1 parent 9351c0a commit 5069d82

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1880
-212
lines changed

.github/PULL_REQUEST_TEMPLATE.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@ Use 'x' to check each item: [x] I have ...
2626
* [ ] I have opened this pull request against ``master``
2727
* [ ] I have added or modified the tests when changing logic
2828
* [ ] I have followed [the conventional commits guidelines](https://www.conventionalcommits.org/) to add meaningful information into the changelog
29-
* [ ] I have read the [contribution guidelines ](https://github.com/django-cms/django-cms/blob/develop/CONTRIBUTING.rst) and I have joined #workgroup-pr-review on
30-
[Slack](https://www.django-cms.org/slack) to find a “pr review buddy” who is going to review my pull request.
29+
* [ ] I have read the [contribution guidelines ](https://github.com/django-cms/django-cms/blob/develop/CONTRIBUTING.rst) and I have joined #pr-review on
30+
[Discord](https://discord-pr-review-channel.django-cms.org/) to find a “pr review buddy” who is
31+
going to review my pull request.

.github/workflows/lint.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ jobs:
2727
pip install ruff
2828
- name: Run Ruff
2929
working-directory: ./src
30-
run: ruff djangocms_snippet
30+
run: ruff check djangocms_snippet

.github/workflows/test.yml

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ name: CodeCov
22

33
on:
44
push:
5-
branches:
6-
- master
75
pull_request:
86

97
concurrency:

.pre-commit-config.yaml

-5
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,3 @@ repos:
4343
- id: check-toml
4444
- id: end-of-file-fixer
4545
- id: trailing-whitespace
46-
47-
# - repo: https://github.com/pre-commit/mirrors-mypy
48-
# rev: v1.3.0
49-
# hooks:
50-
# - id: mypy

CHANGELOG.rst

+58-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,64 @@ Changelog
55
Unreleased
66
==========
77

8-
* Drop support for Django < 3.2
9-
* Drop support for Python < 3.9
8+
* feat: Universal support for django CMS 3.11 and 4.x
9+
10+
11+
4.1.0 (2024-05-16)
12+
==================
13+
14+
* feat: Added sites support for Snippets
15+
* add support for python 3.10
16+
* add support for django >= 4.2
17+
* drop support for django < 3.2
18+
* drop support python < 3.8
19+
20+
21+
4.0.1.dev2 (2022-11-15)
22+
=======================
23+
24+
* feat: Enable add button to create a snippet when adding a SnippetPlugin
25+
26+
27+
4.0.1.dev1 (2022-05-10)
28+
=======================
29+
30+
* Python 3.8, 3.9 support added
31+
* Django 3.0, 3.1 and 3.2 support added
32+
* Python 3.5 and 3.6 support removed
33+
* Django 1.11 support removed
34+
* port-feat: pre-commit config added from the v3 workstream
35+
* fix: Added test coverage to admin preview view
36+
37+
38+
4.0.0.dev4 (2022-02-03)
39+
=======================
40+
41+
* feat: Preview icon renders form in read only mode
42+
43+
44+
4.0.0.dev3 (2022-01-11)
45+
=======================
46+
47+
* fix: Snippet plugin added to a page now displays name instead of ID
48+
* fix: Slug field on list display for admin should only be displayed when versioning is not available
49+
* fix: Removed unused contents within templates, reducing the clutter within version compare views. Previously this was causing a lot of junk to be included in the version comparison, this will now be reduced.
50+
51+
52+
4.0.0.dev2 (2021-12-22)
53+
=======================
54+
55+
* fix: Removed tight django-treebeard restriction added when 4.5.0 contained breaking changes. The core CMS and django-treebeard have since been patched to resolve the issue.
56+
57+
58+
4.0.0.dev1 (2021-12-14)
59+
=======================
60+
61+
* feat: Exposed the setting DJANGOCMS_SNIPPET_VERSIONING_MIGRATION_USER_ID as an environment variable for the Divio addon
62+
* fix: Error when rendering a Draft Snippet plugin on a Published page
63+
* fix: Publish snippets by default as they were already in that state pre-versioning and cleanup unnecessary migration files before release!
64+
* feat: djangocms-versioning support added, including model restructure and configuration
65+
* feat: django-cms v4.0.x support added
1066

1167
3.1.1
1268
=====

MANIFEST.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ include CHANGELOG.rst
33
include LICENSE
44
include pyproject.toml
55
include README.rst
6-
include src/*/py.typed
6+
recursive-include src/djangocms_snippet *

README.rst

+11-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
django CMS Snippet
33
==================
44

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

77

88
**django CMS Snippet** provides a plugin for `django CMS <http://django-cms.org>`_
@@ -89,6 +89,12 @@ please set ``DJANGOCMS_SNIPPET_CACHE`` to ``False`` in your settings::
8989

9090
DJANGOCMS_SNIPPET_CACHE = False # default value is False
9191

92+
Migration 0010 requires the use of a user in order to create versions for existing snippets (if djangocms_versioning is installed and enabled),
93+
a user can be chosen with the setting ``DJANGOCMS_SNIPPET_VERSIONING_MIGRATION_USER_ID``, the default is 1.
94+
This setting is also exposed as an Environment variable for Divio projects using the Divio addon.
95+
96+
DJANGOCMS_SNIPPET_VERSIONING_MIGRATION_USER_ID = 2 # Will use user with id: 2
97+
9298
Template tag
9399
------------
94100

@@ -125,9 +131,11 @@ You can run tests by executing::
125131
:target: http://badge.fury.io/py/djangocms-snippet
126132
.. |coverage| image:: https://codecov.io/gh/django-cms/djangocms-snippet/branch/master/graph/badge.svg
127133
:target: https://codecov.io/gh/django-cms/djangocms-snippet
128-
.. |python| image:: https://img.shields.io/badge/python-3.5+-blue.svg
134+
.. |python| image:: https://img.shields.io/badge/python-3.9+-blue.svg
129135
:target: https://pypi.org/project/djangocms-snippet/
130-
.. |django| image:: https://img.shields.io/badge/django-2.2,%203.0,%203.1-blue.svg
136+
.. |django| image:: https://img.shields.io/badge/django-3.2+-blue.svg
131137
:target: https://www.djangoproject.com/
132138
.. |djangocms| image:: https://img.shields.io/badge/django%20CMS-3.7%2B-blue.svg
133139
:target: https://www.django-cms.org/
140+
.. |djangocms4| image:: https://img.shields.io/badge/django%20CMS-4-blue.svg
141+
:target: https://www.django-cms.org/

aldryn_config.py

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from functools import partial
2+
13
from aldryn_client import forms
24

35

@@ -17,6 +19,15 @@ class Form(forms.BaseForm):
1719
)
1820

1921
def to_settings(self, data, settings):
22+
from aldryn_addons.utils import djsenv
23+
24+
env = partial(djsenv, settings=settings)
25+
26+
# Get a migration user if the env setting has been added
27+
migration_user_id = env("DJANGOCMS_SNIPPET_VERSIONING_MIGRATION_USER_ID", default=False)
28+
if migration_user_id:
29+
settings["DJANGOCMS_SNIPPET_VERSIONING_MIGRATION_USER_ID"] = int(migration_user_id)
30+
2031
if data["editor_theme"]:
2132
settings["DJANGOCMS_SNIPPET_THEME"] = data["editor_theme"]
2233
if data["editor_mode"]:

pyproject.toml

+12-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "djangocms-snippet"
7-
version = "3.1.1"
7+
dynamic = ["version"]
88
authors = [
99
{name = "Divio AG", email = "info@divio.ch"},
1010
]
@@ -26,9 +26,9 @@ classifiers=[
2626
"Operating System :: OS Independent",
2727
"Programming Language :: Python",
2828
"Programming Language :: Python :: 3",
29+
"Programming Language :: Python :: 3.8",
2930
"Programming Language :: Python :: 3.9",
3031
"Programming Language :: Python :: 3.10",
31-
"Programming Language :: Python :: 3.11",
3232
"Framework :: Django",
3333
"Framework :: Django :: 3.2",
3434
"Framework :: Django :: 4.2",
@@ -37,6 +37,8 @@ classifiers=[
3737
"Framework :: Django CMS :: 3.9",
3838
"Framework :: Django CMS :: 3.10",
3939
"Framework :: Django CMS :: 3.11",
40+
"Framework :: Django CMS :: 4.0",
41+
"Framework :: Django CMS :: 4.1",
4042
"Topic :: Internet :: WWW/HTTP",
4143
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
4244
"Topic :: Software Development",
@@ -91,8 +93,8 @@ allow_untyped_defs = true
9193

9294
[tool.ruff]
9395
# https://beta.ruff.rs/docs/configuration/
94-
line-length = 79
95-
select = [
96+
line-length = 120
97+
lint.select = [
9698
"E", # pycodestyle errors
9799
"W", # pycodestyle warnings
98100
"F", # pyflakes
@@ -126,17 +128,20 @@ exclude = [
126128
"venv",
127129
]
128130

129-
ignore = [
131+
lint.ignore = [
130132
"E501", # line-too-long
131133
"W191", # tab-indentation
132134
]
133135

134-
[tool.ruff.per-file-ignores]
136+
[tool.ruff.lint.per-file-ignores]
135137
"__init__.py" = [
136138
"F401" # unused-import
137139
]
140+
"test_plugins.py" = [
141+
"FBT003", # Boolean positional value in function call
142+
]
138143

139-
[tool.ruff.isort]
144+
[tool.ruff.lint.isort]
140145
combine-as-imports = true
141146
known-first-party = [
142147
"djangocms_snippet",

requirements.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
bump2version
22
django-cms>=3.7
3-
django-treebeard>=4.3,<4.5
3+
django-treebeard
44
pip-tools
55
pre-commit
66
wheel

requirements.txt

+44-31
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,85 @@
11
#
2-
# This file is autogenerated by pip-compile with python 3.9
3-
# To update, run:
2+
# This file is autogenerated by pip-compile with Python 3.9
3+
# by the following command:
44
#
5-
# pip-compile
5+
# pip-compile --output-file=requirements.txt requirements.in
66
#
7-
asgiref==3.6.0
7+
asgiref==3.8.1
88
# via django
9+
build==1.2.1
10+
# via pip-tools
911
bump2version==1.0.1
1012
# via -r requirements.in
11-
cfgv==3.3.1
13+
cfgv==3.4.0
1214
# via pre-commit
13-
click==8.0.3
15+
click==8.1.7
1416
# via pip-tools
15-
distlib==0.3.4
17+
distlib==0.3.8
1618
# via virtualenv
17-
django==4.1.10
19+
django==4.2.13
1820
# via
1921
# django-classy-tags
2022
# django-cms
2123
# django-formtools
2224
# django-sekizai
2325
# django-treebeard
24-
django-classy-tags==3.0.0
26+
# djangocms-admin-style
27+
django-classy-tags==4.1.0
2528
# via
2629
# django-cms
2730
# django-sekizai
28-
django-cms==3.9.0
31+
django-cms==4.1.1
2932
# via -r requirements.in
30-
django-formtools==2.3
33+
django-formtools==2.5.1
3134
# via django-cms
32-
django-sekizai==3.0.0
35+
django-sekizai==4.1.0
3336
# via django-cms
34-
django-treebeard==4.4
37+
django-treebeard==4.7.1
3538
# via
3639
# -r requirements.in
3740
# django-cms
38-
djangocms-admin-style==3.0.0
41+
djangocms-admin-style==3.3.1
3942
# via django-cms
40-
filelock==3.4.2
43+
filelock==3.14.0
4144
# via virtualenv
42-
identify==2.4.4
45+
identify==2.5.36
4346
# via pre-commit
44-
nodeenv==1.6.0
47+
importlib-metadata==7.1.0
48+
# via build
49+
nodeenv==1.8.0
4550
# via pre-commit
46-
pep517==0.12.0
47-
# via pip-tools
48-
pip-tools==6.4.0
51+
packaging==24.0
52+
# via
53+
# build
54+
# django-cms
55+
pip-tools==7.4.1
4956
# via -r requirements.in
50-
platformdirs==2.4.1
57+
platformdirs==4.2.2
5158
# via virtualenv
52-
pre-commit==2.17.0
59+
pre-commit==3.7.1
5360
# via -r requirements.in
54-
pyyaml==6.0
61+
pyproject-hooks==1.1.0
62+
# via
63+
# build
64+
# pip-tools
65+
pyyaml==6.0.1
5566
# via pre-commit
56-
six==1.16.0
57-
# via virtualenv
5867
sqlparse==0.5.0
5968
# via django
60-
toml==0.10.2
61-
# via pre-commit
62-
tomli==2.0.0
63-
# via pep517
64-
virtualenv==20.13.0
69+
tomli==2.0.1
70+
# via
71+
# build
72+
# pip-tools
73+
typing-extensions==4.11.0
74+
# via asgiref
75+
virtualenv==20.26.2
6576
# via pre-commit
66-
wheel==0.38.1
77+
wheel==0.43.0
6778
# via
6879
# -r requirements.in
6980
# pip-tools
81+
zipp==3.18.2
82+
# via importlib-metadata
7083

7184
# The following packages are considered to be unsafe in a requirements file:
7285
# pip

setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 3.1.0
2+
current_version = 5.0.0a
33
commit = True
44
tag = False
55

src/djangocms_snippet/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "3.1.1"
1+
__version__ = "5.0.0a1"

0 commit comments

Comments
 (0)