Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Universal snippet for django CMS 3 and 4 #160

Merged
merged 69 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from 62 commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
eeb8072
djangocms-versioning compatibility - Initial Model and cms_config imp…
adam-murray Sep 8, 2021
a441d5a
feat: Snippet CMS 4.0 and djangocms-versioning Data migration (#74)
adam-murray Sep 15, 2021
4fd5662
feat: Moderation compatibility and version copy method implementation…
adam-murray Sep 17, 2021
e215e01
feat: Versioning Compatibility Changes (#79)
adam-murray Oct 14, 2021
d2b1b63
fix: Fixed bug that causes ChangeView not to use SnippetForm (#80)
adam-murray Oct 14, 2021
c3eb8d9
feat: Reworked form fields and added the ability to show draft snippe…
adam-murray Oct 20, 2021
5a3323c
fix: Adding valid HTML to the add snippet form throws an error (#82)
adam-murray Oct 21, 2021
98ddf0c
fix: form initialisation error in read-only mode (#83)
adam-murray Oct 22, 2021
aa450b3
fix: History URL button broken link on the Snippets change form (#84)
adam-murray Oct 26, 2021
7d752e6
fix: Draft snippet render error due to draft snippets (#86)
Aiky30 Nov 29, 2021
55abe67
feat: Default versioning import user id setting can be set via enviro…
Aiky30 Nov 30, 2021
20e5ca6
Release 4.0.0.dev1 (#91)
Aiky30 Dec 14, 2021
903be6f
fix: django-cms 4.0.x - Remove breaking django-treebeard pinning issu…
Aiky30 Dec 22, 2021
b0a0559
Release 4.0.0.dev2 (#95)
Aiky30 Dec 23, 2021
fdc9f49
feat: Removing slug field and hyperlink from list display when versio…
Bernardvdv Jan 10, 2022
90b1171
fix: Snippet plugin showing ID instead of name(#100)
Bernardvdv Jan 10, 2022
a31c8e3
Fix: Compare view removed unnecessary template logic (#101)
adam-murray Jan 11, 2022
60746af
Release 4.0.0.dev3 (#103)
Bernardvdv Jan 11, 2022
3c5af57
feat: Preview icon renders content in read only (#102)
Bernardvdv Feb 3, 2022
c25b365
Release 4.0.0.dev4 (#109)
Aiky30 Feb 3, 2022
59c22af
fix: Added test coverage to admin preview view (#96)
adam-murray Feb 14, 2022
c8562f0
port-feat: pre-commit config added from the v3 workstream (#117)
Aiky30 May 10, 2022
dbd61f5
feat: django-cms 4.0.x - django 3.2 and Python 3.9 compatibility (#92)
Aiky30 May 10, 2022
5f7ff3e
Release 4.0.1.dev1 (#119)
Aiky30 May 11, 2022
c9c4d25
feat: Enable add button on the SnippetPluginForm (#127)
michaeljcollinsuk Nov 15, 2022
1cd77a8
Release 4.0.1.dev2 (#128)
michaeljcollinsuk Nov 15, 2022
1fb6fca
init support for django4.2 (#150)
FreemanPancake Mar 14, 2024
aaec619
fix pyproject.toml config error (#151)
FreemanPancake Apr 1, 2024
eabef47
Added site field in models n site filter in admin (#159)
vipulnarang95 May 14, 2024
48daa6a
Release/4.1.0 (#155)
FreemanPancake May 16, 2024
f9147e5
Update README.rst
NicolaiRidani Oct 15, 2021
27610d9
Update README.rst
NicolaiRidani Oct 27, 2021
3252fc9
Create PULL_REQUEST_TEMPLATE.md (#85)
Kaushal-Dhungel Nov 9, 2021
17db789
Only include badges at the top to avoid confusion & removed old badge…
marksweb Jan 23, 2022
893ed0b
Added pypi github actions (#108)
marksweb Jan 23, 2022
de97346
FEATURE: adjust setup metadata (#110)
Feb 13, 2022
a26c443
correct doc about default value of DJANGOCMS_SNIPPET_CACHE (#120)
eagleoflqj Jun 19, 2022
cbff022
Update to ace 1.9.6, load ace editor from static files if djangocms_s…
fsbraun Aug 29, 2022
6163086
ci: Update pypi action branch names (#125)
marksweb Aug 31, 2022
1402265
Bump version: 3.0.0 → 3.1.0 (#126)
marksweb Sep 1, 2022
40602ba
fix: django-cms 3.x - Remove breaking django-treebeard pinning issue …
Aiky30 Jul 27, 2023
afca2a0
fix: add noop django 4 migration (#134)
LuckyType Jul 27, 2023
58fba22
ci: Prepare release of version 3.1.1 (#139)
fsbraun Sep 7, 2023
0f65aa8
chore: Package overhaul (#140)
marksweb Oct 26, 2023
30371e4
fix: Test pypi workflow
marksweb Oct 26, 2023
948f70c
Bump actions/setup-python from 4 to 5 (#148)
dependabot[bot] Jan 1, 2024
8dfec44
fix: Test only for migrations within package
fsbraun May 7, 2024
5d67ff2
Update tests
fsbraun May 19, 2024
1209437
run tests on all branches
fsbraun May 19, 2024
56a2557
fix tests
fsbraun May 19, 2024
35da1da
Update readme, changelog
fsbraun May 19, 2024
d161417
Fix common test suite for django CMS 3.11, 4.0, and 4.1
fsbraun May 19, 2024
fff7f64
Update CHANGELOG
fsbraun May 22, 2024
ba7c8ed
Merge branch 'master' into feat/universal
fsbraun May 22, 2024
10b5e32
Merge branches together
fsbraun May 22, 2024
5d73d27
Update precommit-config
fsbraun May 22, 2024
ec4515f
fix: ruff precommit
fsbraun May 22, 2024
aa2505b
ci: auto fixes from pre-commit hooks
pre-commit-ci[bot] May 22, 2024
789480d
fix: ruff issues
fsbraun May 22, 2024
70e50f1
Merge branch 'feat/universal' of github.com:django-cms/djangocms-snip…
fsbraun May 22, 2024
470152d
More ruff fixes
fsbraun May 22, 2024
8eedef5
Update pyproject.toml
fsbraun May 22, 2024
cdf3bfa
Merge branch 'master' into feat/universal
fsbraun Jun 20, 2024
da34c01
ci: auto fixes from pre-commit hooks
pre-commit-ci[bot] Jun 20, 2024
112f0a7
fix: Remove isort and flake8 from setup.cfg
fsbraun Jun 20, 2024
6b1968a
ci: auto fixes from pre-commit hooks
pre-commit-ci[bot] Jun 20, 2024
a152bdf
Update setup.cfg
fsbraun Jun 20, 2024
f7d298e
Fix: universal branch (#167)
joshyu Aug 20, 2024
d86e6c4
Update lint workflow
fsbraun Aug 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ Use 'x' to check each item: [x] I have ...
* [ ] I have opened this pull request against ``master``
* [ ] I have added or modified the tests when changing logic
* [ ] I have followed [the conventional commits guidelines](https://www.conventionalcommits.org/) to add meaningful information into the changelog
* [ ] 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
[Slack](https://www.django-cms.org/slack) to find a “pr review buddy” who is going to review my pull request.
* [ ] I have read the [contribution guidelines ](https://github.com/django-cms/django-cms/blob/develop/CONTRIBUTING.rst) and I have joined #pr-review on
[Discord](https://discord-pr-review-channel.django-cms.org/) to find a “pr review buddy” who is
going to review my pull request.
2 changes: 0 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ name: CodeCov

on:
push:
branches:
- master
pull_request:

concurrency:
Expand Down
27 changes: 5 additions & 22 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,18 @@ ci:
autoupdate_schedule: monthly

repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.2
hooks:
- id: pyupgrade
args: ["--py38-plus"]

- repo: https://github.com/adamchainz/django-upgrade
rev: '1.16.0'
- repo: https://github.com/asottile/pyupgrade
rev: v2.31.0
hooks:
- id: django-upgrade
marksweb marked this conversation as resolved.
Show resolved Hide resolved
args: [--target-version, "3.2"]
- id: pyupgrade
args: ["--py38-plus"]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.4.3"
rev: v0.4.4
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.4.3
hooks:
- id: ruff-format

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
Expand All @@ -43,8 +31,3 @@ repos:
- id: check-toml
- id: end-of-file-fixer
- id: trailing-whitespace

# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: v1.3.0
# hooks:
# - id: mypy
60 changes: 58 additions & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,64 @@ Changelog
Unreleased
==========

* Drop support for Django < 3.2
* Drop support for Python < 3.9
* feat: Universal support for django CMS 3.11 and 4.x


4.1.0 (2024-05-16)
==================

* feat: Added sites support for Snippets
* add support for python 3.10
* add support for django >= 4.2
* drop support for django < 3.2
* drop support python < 3.8


4.0.1.dev2 (2022-11-15)
=======================

* feat: Enable add button to create a snippet when adding a SnippetPlugin


4.0.1.dev1 (2022-05-10)
=======================

* Python 3.8, 3.9 support added
* Django 3.0, 3.1 and 3.2 support added
* Python 3.5 and 3.6 support removed
* Django 1.11 support removed
* port-feat: pre-commit config added from the v3 workstream
* fix: Added test coverage to admin preview view


4.0.0.dev4 (2022-02-03)
=======================

* feat: Preview icon renders form in read only mode


4.0.0.dev3 (2022-01-11)
=======================

* fix: Snippet plugin added to a page now displays name instead of ID
* fix: Slug field on list display for admin should only be displayed when versioning is not available
* 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.


4.0.0.dev2 (2021-12-22)
=======================

* 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.


4.0.0.dev1 (2021-12-14)
=======================

* feat: Exposed the setting DJANGOCMS_SNIPPET_VERSIONING_MIGRATION_USER_ID as an environment variable for the Divio addon
* fix: Error when rendering a Draft Snippet plugin on a Published page
* fix: Publish snippets by default as they were already in that state pre-versioning and cleanup unnecessary migration files before release!
* feat: djangocms-versioning support added, including model restructure and configuration
* feat: django-cms v4.0.x support added

3.1.1
=====
Expand Down
14 changes: 11 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
django CMS Snippet
==================

|pypi| |coverage| |python| |django| |djangocms|
|pypi| |coverage| |python| |django| |djangocms| |django-cms4|


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

DJANGOCMS_SNIPPET_CACHE = False # default value is False

Migration 0010 requires the use of a user in order to create versions for existing snippets (if djangocms_versioning is installed and enabled),
a user can be chosen with the setting ``DJANGOCMS_SNIPPET_VERSIONING_MIGRATION_USER_ID``, the default is 1.
This setting is also exposed as an Environment variable for Divio projects using the Divio addon.

DJANGOCMS_SNIPPET_VERSIONING_MIGRATION_USER_ID = 2 # Will use user with id: 2

Template tag
------------

Expand Down Expand Up @@ -125,9 +131,11 @@ You can run tests by executing::
:target: http://badge.fury.io/py/djangocms-snippet
.. |coverage| image:: https://codecov.io/gh/django-cms/djangocms-snippet/branch/master/graph/badge.svg
:target: https://codecov.io/gh/django-cms/djangocms-snippet
.. |python| image:: https://img.shields.io/badge/python-3.5+-blue.svg
.. |python| image:: https://img.shields.io/badge/python-3.9+-blue.svg
:target: https://pypi.org/project/djangocms-snippet/
.. |django| image:: https://img.shields.io/badge/django-2.2,%203.0,%203.1-blue.svg
.. |django| image:: https://img.shields.io/badge/django-3.2+-blue.svg
:target: https://www.djangoproject.com/
.. |djangocms| image:: https://img.shields.io/badge/django%20CMS-3.7%2B-blue.svg
:target: https://www.django-cms.org/
.. |djangocms4| image:: https://img.shields.io/badge/django%20CMS-4-blue.svg
:target: https://www.django-cms.org/
26 changes: 20 additions & 6 deletions aldryn_config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from functools import partial

from aldryn_client import forms


Expand All @@ -17,10 +19,22 @@ class Form(forms.BaseForm):
)

def to_settings(self, data, settings):
if data["editor_theme"]:
settings["DJANGOCMS_SNIPPET_THEME"] = data["editor_theme"]
if data["editor_mode"]:
settings["DJANGOCMS_SNIPPET_MODE"] = data["editor_mode"]
if data["enable_search"]:
settings["DJANGOCMS_SNIPPET_SEARCH"] = data["enable_search"]
from aldryn_addons.utils import djsenv

env = partial(djsenv, settings=settings)

# Get a migration user if the env setting has been added
migration_user_id = env(
'DJANGOCMS_SNIPPET_VERSIONING_MIGRATION_USER_ID',
default=False
)
if migration_user_id:
settings['DJANGOCMS_SNIPPET_VERSIONING_MIGRATION_USER_ID'] = int(migration_user_id)

if data['editor_theme']:
settings['DJANGOCMS_SNIPPET_THEME'] = data['editor_theme']
if data['editor_mode']:
settings['DJANGOCMS_SNIPPET_MODE'] = data['editor_mode']
if data['enable_search']:
settings['DJANGOCMS_SNIPPET_SEARCH'] = data['enable_search']
return settings
19 changes: 12 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "djangocms-snippet"
version = "3.1.1"
dynamic = ["version"]
authors = [
{name = "Divio AG", email = "[email protected]"},
]
Expand All @@ -26,9 +26,9 @@ classifiers=[
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Framework :: Django",
"Framework :: Django :: 3.2",
"Framework :: Django :: 4.2",
Expand All @@ -37,6 +37,8 @@ classifiers=[
"Framework :: Django CMS :: 3.9",
"Framework :: Django CMS :: 3.10",
"Framework :: Django CMS :: 3.11",
"Framework :: Django CMS :: 4.0",
"Framework :: Django CMS :: 4.1",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
"Topic :: Software Development",
Expand Down Expand Up @@ -91,8 +93,8 @@ allow_untyped_defs = true

[tool.ruff]
# https://beta.ruff.rs/docs/configuration/
line-length = 79
select = [
line-length = 120
lint.select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # pyflakes
Expand Down Expand Up @@ -126,17 +128,20 @@ exclude = [
"venv",
]

ignore = [
lint.ignore = [
"E501", # line-too-long
"W191", # tab-indentation
]

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"__init__.py" = [
"F401" # unused-import
]
"test_plugins.py" = [
"FBT003", # Boolean positional value in function call
]

[tool.ruff.isort]
[tool.ruff.lint.isort]
combine-as-imports = true
known-first-party = [
"djangocms_snippet",
Expand Down
2 changes: 1 addition & 1 deletion requirements.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
bump2version
django-cms>=3.7
django-treebeard>=4.3,<4.5
django-treebeard
pip-tools
pre-commit
wheel
75 changes: 44 additions & 31 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,72 +1,85 @@
#
# This file is autogenerated by pip-compile with python 3.9
# To update, run:
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# pip-compile
# pip-compile --output-file=requirements.txt requirements.in
#
asgiref==3.6.0
asgiref==3.8.1
# via django
build==1.2.1
# via pip-tools
bump2version==1.0.1
# via -r requirements.in
cfgv==3.3.1
cfgv==3.4.0
# via pre-commit
click==8.0.3
click==8.1.7
# via pip-tools
distlib==0.3.4
distlib==0.3.8
# via virtualenv
django==4.1.10
django==4.2.13
# via
# django-classy-tags
# django-cms
# django-formtools
# django-sekizai
# django-treebeard
django-classy-tags==3.0.0
# djangocms-admin-style
django-classy-tags==4.1.0
# via
# django-cms
# django-sekizai
django-cms==3.9.0
django-cms==4.1.1
# via -r requirements.in
django-formtools==2.3
django-formtools==2.5.1
# via django-cms
django-sekizai==3.0.0
django-sekizai==4.1.0
# via django-cms
django-treebeard==4.4
django-treebeard==4.7.1
# via
# -r requirements.in
# django-cms
djangocms-admin-style==3.0.0
djangocms-admin-style==3.3.1
# via django-cms
filelock==3.4.2
filelock==3.14.0
# via virtualenv
identify==2.4.4
identify==2.5.36
# via pre-commit
nodeenv==1.6.0
importlib-metadata==7.1.0
# via build
nodeenv==1.8.0
# via pre-commit
pep517==0.12.0
# via pip-tools
pip-tools==6.4.0
packaging==24.0
# via
# build
# django-cms
pip-tools==7.4.1
# via -r requirements.in
platformdirs==2.4.1
platformdirs==4.2.2
# via virtualenv
pre-commit==2.17.0
pre-commit==3.7.1
# via -r requirements.in
pyyaml==6.0
pyproject-hooks==1.1.0
# via
# build
# pip-tools
pyyaml==6.0.1
# via pre-commit
six==1.16.0
# via virtualenv
sqlparse==0.5.0
# via django
toml==0.10.2
# via pre-commit
tomli==2.0.0
# via pep517
virtualenv==20.13.0
tomli==2.0.1
# via
# build
# pip-tools
typing-extensions==4.11.0
# via asgiref
virtualenv==20.26.2
# via pre-commit
wheel==0.38.1
wheel==0.43.0
# via
# -r requirements.in
# pip-tools
zipp==3.18.2
# via importlib-metadata

# The following packages are considered to be unsafe in a requirements file:
# pip
Expand Down
Loading
Loading