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

[WIP] django-cms 4.1 compatible for version locking #85

Draft
wants to merge 31 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
25c946b
initial change made for djangocms 4.1 compatible
Aug 8, 2024
6e42193
add testcases changes
Aug 8, 2024
e12fa57
removed model patch from locking
Aug 12, 2024
6d9d4eb
remove Version.admin.locked monkeypatch.
FreemanPancake Aug 14, 2024
152e980
make state indicator readonly, and add more function to alias action …
FreemanPancake Aug 29, 2024
ee2835b
remove edit link and code format
FreemanPancake Aug 29, 2024
4fb1d10
hide delete button for alias, as this will take over by unpublish/arc…
FreemanPancake Aug 29, 2024
c3a2d27
Add 'Manage versions' action to versioned admin's action list, State …
FreemanPancake Oct 22, 2024
abbad0d
add alias edit btn
FreemanPancake Oct 25, 2024
acd9871
fix Alias language filer selector UI issue.
FreemanPancake Oct 25, 2024
e96aa25
chore: update djangocms-versioning to 2.1.0 in `dj42_cms41`
Oct 31, 2024
a7241fa
fix: flake8 & isort issues
Oct 31, 2024
9a18bf4
chore: remove python 3.8 support
Oct 31, 2024
bb454b2
docs: update changelog
Oct 31, 2024
9b50f0a
fix: duplicated manage-version link & update version icon
Nov 4, 2024
c448c9a
fix: flake8 & isort issue
Nov 4, 2024
09e62ad
fix empty date issue if the alias has legacy empty date.
FreemanPancake Nov 4, 2024
80e68fe
fix empty date issue if the alias has legacy empty data, code refact.
FreemanPancake Nov 4, 2024
c45768e
add locked_by data migration file.
FreemanPancake Nov 7, 2024
99acc78
fix: refine 0002 migration file
Nov 7, 2024
e8bf295
chore: delete `VersionLock` model and generate migration file
Nov 7, 2024
9275657
chore: comment models
Nov 8, 2024
17260f6
add AdminActionListMixin to support action list burger menu.
FreemanPancake Nov 18, 2024
6367dd8
monkeypatch ChangeListActionsMixin in cms.admin.utils to support acti…
FreemanPancake Nov 19, 2024
005cda9
code format
FreemanPancake Nov 19, 2024
4e19abf
fix: actions.js get img tag.
FreemanPancake Nov 19, 2024
6d89ce1
fix: get the correct base admin class of djangocms_alias
Nov 19, 2024
25dddce
fix: remove duplicated media js from monkeypatch.
FreemanPancake Nov 19, 2024
6913e0c
fix: isort issue
Nov 19, 2024
64affce
fix: action list layout issue.
FreemanPancake Nov 20, 2024
34e9d01
fix: migration file
Nov 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: 2 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [ 3.8, 3.9, '3.10' ]
python-version: [ 3.9, '3.10', '3.11' ]
requirements-file: [
dj32_cms40.txt,
dj42_cms40.txt,
dj42_cms41.txt,
]

steps:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ Changelog

Unreleased
==========
* Dropped Support for Python 3.8
* Dropped Support for Django CMS < 4.1
* Introduced Django CMS 4.1 support.
* delete `VersionLock` as It's moved to Version.locked_by field.
* monkeypatch `ChangeListActionsMixin` in cms.admin.utils to support action list burger menu.


1.3.0 (2024-05-16)
==================
Expand Down
25 changes: 0 additions & 25 deletions djangocms_version_locking/admin.py

This file was deleted.

2 changes: 1 addition & 1 deletion djangocms_version_locking/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ class VersionLockingConfig(AppConfig):
verbose_name = _("django CMS Version Locking")

def ready(self):
from .monkeypatch import checks, cms_toolbars, models # noqa: F401
from .monkeypatch import cms_toolbars # noqa: F401
22 changes: 14 additions & 8 deletions djangocms_version_locking/cms_config.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
from django.template.loader import render_to_string
from django.utils.html import format_html
from django.utils.safestring import mark_safe

from cms.app_base import CMSAppConfig, CMSAppExtension

from djangocms_alias.models import AliasContent
from djangocms_versioning.constants import DRAFT

from djangocms_version_locking.helpers import version_is_locked
from djangocms_versioning.helpers import version_is_locked


def add_alias_version_lock(obj, field):
version = obj.versions.all()[0]
# add None obj check, if the legacy data has empty value.
lock_icon = ""
if version.state == DRAFT and version_is_locked(version):
lock_icon = render_to_string("djangocms_version_locking/admin/locked_mixin_icon.html")
if obj:
version = obj.versions.all()[0]
if version.state == DRAFT and version_is_locked(version):
lock_icon = mark_safe('<span class="cms-icon cms-icon-lock"></span>')
return format_html(
"{is_locked}{field_value}",
is_locked=lock_icon,
field_value=getattr(obj, field),
field_value=getattr(obj, field, '-'),
)


Expand All @@ -27,7 +28,12 @@ def __init__(self):
# is registered and can be overriden without requiring a strict load order
# in the INSTALLED_APPS setting in a projects settings.py. This is why this patch
# Isn't loaded from: VersionLockingConfig.ready
from .monkeypatch import admin as monkeypatch_admin # noqa: F401
from .monkeypatch import ( # noqa: F401
admin as monkeypatched_version_admin,
)
from .monkeypatch.djangocms_alias import ( # noqa: F401
admin as monkeypatched_alias_admin,
)

def configure_app(self, cms_config):
pass
Expand Down
6 changes: 0 additions & 6 deletions djangocms_version_locking/conf.py

This file was deleted.

40 changes: 0 additions & 40 deletions djangocms_version_locking/emails.py

This file was deleted.

168 changes: 0 additions & 168 deletions djangocms_version_locking/helpers.py

This file was deleted.

28 changes: 28 additions & 0 deletions djangocms_version_locking/migrations/0002_migrate_locked_by.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 4.2.8 on 2024-11-07 07:21

from django.db import migrations


def forwards(apps, schema_editor):
db_alias = schema_editor.connection.alias
Version = apps.get_model("djangocms_versioning", "Version")
VersionLock = apps.get_model("djangocms_version_locking", "VersionLock")

version_lock_qs = VersionLock.objects.using(db_alias).all()
versions = set(Version.objects.using(db_alias).filter(pk__in=version_lock_qs.values('version')))

for version in versions:
version.locked_by = version.versionlock.created_by
Version.objects.using(db_alias).bulk_update(versions, ['locked_by'])


class Migration(migrations.Migration):

dependencies = [
('djangocms_version_locking', '0001_initial'),
('djangocms_versioning', '0017_merge_20230514_1027'),
]

operations = [
migrations.RunPython(forwards, reverse_code=migrations.RunPython.noop)
]
16 changes: 16 additions & 0 deletions djangocms_version_locking/migrations/0003_delete_versionlock.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Generated by Django 4.2.16 on 2024-11-07 14:33

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('djangocms_version_locking', '0002_migrate_locked_by'),
]

operations = [
migrations.DeleteModel(
name='VersionLock',
),
]
Loading
Loading