Skip to content

Commit

Permalink
fix: monkeypatch script & update filter label
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Yu committed Aug 27, 2024
1 parent fc94160 commit 8d18942
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 19 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Changelog

unreleased
==========
* add support for Django CMS 4.1
* fix `Expiry Date Range` filter label
* fix monkeypatch scripts


1.6.1 (2024-05-31)
Expand Down
2 changes: 1 addition & 1 deletion djangocms_content_expiry/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def get_rangefilter_expires_default(self, *args, **kwargs):
return get_rangefilter_expires_default()

def get_rangefilter_expires_title(self, *args, **kwargs):
return _("By Expiry Date Range")
return _("Expiry Date Range")

@admin.display(
description=_('Title')
Expand Down
40 changes: 22 additions & 18 deletions djangocms_content_expiry/monkeypatch/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

from djangocms_moderation import admin as moderation_admin
from djangocms_moderation.models import ModerationCollection, ModerationRequest
from djangocms_versioning import admin
from djangocms_versioning import admin as versioning_admin
from djangocms_versioning.models import Version

from djangocms_content_expiry.constants import CONTENT_EXPIRY_COMPLIANCE_FIELD_LABEL
from djangocms_content_expiry.models import ContentExpiry
Expand All @@ -14,22 +15,25 @@ def _get_expiry_link(self, obj, request):
"""
Generate a content expiry link for the Versioning Admin
"""
expiry_url = reverse(
"admin:{app}_{model}_change".format(
app=ContentExpiry._meta.app_label, model=ContentExpiry._meta.model_name
),
args=(obj.contentexpiry.pk,),
)
return render_to_string(
'djangocms_content_expiry/admin/icons/additional_content_settings_icon.html',
{
"url": f"{expiry_url}?_to_field=id&_popup=1",
"field_id": f"contentexpiry_{obj.pk}",
}
)
try:
expiry_url = reverse(
"admin:{app}_{model}_change".format(
app=ContentExpiry._meta.app_label, model=ContentExpiry._meta.model_name
),
args=(obj.contentexpiry.pk,),
)
return render_to_string(
'djangocms_content_expiry/admin/icons/additional_content_settings_icon.html',
{
"url": f"{expiry_url}?_to_field=id&_popup=1",
"field_id": f"contentexpiry_{obj.pk}",
}
)
except Version.contentexpiry.RelatedObjectDoesNotExist:
return ''


admin.VersionAdmin._get_expiry_link = _get_expiry_link
versioning_admin.VersionAdmin._get_expiry_link = _get_expiry_link


def get_state_actions(func):
Expand All @@ -43,7 +47,7 @@ def inner(self, *args, **kwargs):
return inner


admin.VersionAdmin.get_state_actions = get_state_actions(admin.VersionAdmin.get_state_actions)
versioning_admin.VersionAdmin.get_state_actions = get_state_actions(versioning_admin.VersionAdmin.get_state_actions)


def compliance_number(self, obj):
Expand All @@ -54,7 +58,7 @@ def compliance_number(self, obj):


compliance_number.short_description = CONTENT_EXPIRY_COMPLIANCE_FIELD_LABEL
admin.VersionAdmin.compliance_number = compliance_number
versioning_admin.VersionAdmin.compliance_number = compliance_number


def get_list_display(func):
Expand All @@ -69,7 +73,7 @@ def inner(self, request):
return inner


admin.VersionAdmin.get_list_display = get_list_display(admin.VersionAdmin.get_list_display)
versioning_admin.VersionAdmin.get_list_display = get_list_display(versioning_admin.VersionAdmin.get_list_display)


def _get_urls(func):
Expand Down

0 comments on commit 8d18942

Please sign in to comment.