Skip to content

Commit

Permalink
feat: Universal snippet for django CMS 3 and 4 (#160)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>

* 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] <[email protected]>
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] <[email protected]>
Co-authored-by: Adam Murray <[email protected]>
Co-authored-by: Aiky30 <[email protected]>
Co-authored-by: Bernard Van Der Vyver <[email protected]>
Co-authored-by: Michael Collins <[email protected]>
Co-authored-by: 傅瑞曼 <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Josh Peng Yu <[email protected]>
Co-authored-by: Vipul Narang <[email protected]>
Co-authored-by: Mark Walker <[email protected]>
Co-authored-by: Nicolai <[email protected]>
Co-authored-by: Kaushal Dhungel <[email protected]>
Co-authored-by: Simon Krull <[email protected]>
Co-authored-by: Liumeo <[email protected]>
Co-authored-by: Mark Walker <[email protected]>
Co-authored-by: Patrik <[email protected]>
Co-authored-by: Mark Walker <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Josh Yu <[email protected]>
  • Loading branch information
19 people authored Aug 20, 2024
1 parent 9351c0a commit 5069d82
Show file tree
Hide file tree
Showing 49 changed files with 1,880 additions and 212 deletions.
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: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ jobs:
pip install ruff
- name: Run Ruff
working-directory: ./src
run: ruff djangocms_snippet
run: ruff check djangocms_snippet
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
5 changes: 0 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,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
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ include CHANGELOG.rst
include LICENSE
include pyproject.toml
include README.rst
include src/*/py.typed
recursive-include src/djangocms_snippet *
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/
11 changes: 11 additions & 0 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,6 +19,15 @@ class Form(forms.BaseForm):
)

def to_settings(self, data, settings):
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"]:
Expand Down
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
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 3.1.0
current_version = 5.0.0a
commit = True
tag = False

Expand Down
2 changes: 1 addition & 1 deletion src/djangocms_snippet/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "3.1.1"
__version__ = "5.0.0a1"
Loading

0 comments on commit 5069d82

Please sign in to comment.