diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 7689411..dbda223 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,7 @@ Changelog unreleased ========== +* feat: Change view title and icon tooltips name changed * feat: Added compliance number field 1.0.0 (2022-04-25) diff --git a/djangocms_content_expiry/admin.py b/djangocms_content_expiry/admin.py index b4f008c..bb00859 100644 --- a/djangocms_content_expiry/admin.py +++ b/djangocms_content_expiry/admin.py @@ -42,6 +42,10 @@ class Media: ) } + def change_view(self, request, object_id, extra_context=None): + extra_context = {'title': 'Additional content settings'} + return super(ContentExpiryAdmin, self).change_view(request, object_id, extra_context=extra_context) + def get_queryset(self, request): queryset = super().get_queryset(request) diff --git a/djangocms_content_expiry/templates/djangocms_content_expiry/admin/icons/calendar_copy_icon.html b/djangocms_content_expiry/templates/djangocms_content_expiry/admin/icons/calendar_copy_icon.html index 90468dc..2e15c09 100644 --- a/djangocms_content_expiry/templates/djangocms_content_expiry/admin/icons/calendar_copy_icon.html +++ b/djangocms_content_expiry/templates/djangocms_content_expiry/admin/icons/calendar_copy_icon.html @@ -1,2 +1,2 @@ {% load static i18n %} - + diff --git a/djangocms_content_expiry/templates/djangocms_content_expiry/admin/icons/edit_action_icon.html b/djangocms_content_expiry/templates/djangocms_content_expiry/admin/icons/edit_action_icon.html index c86c13b..05dc1c1 100644 --- a/djangocms_content_expiry/templates/djangocms_content_expiry/admin/icons/edit_action_icon.html +++ b/djangocms_content_expiry/templates/djangocms_content_expiry/admin/icons/edit_action_icon.html @@ -1,2 +1,2 @@ {% load static i18n %} - + diff --git a/djangocms_content_expiry/templates/djangocms_content_expiry/calendar_icon.html b/djangocms_content_expiry/templates/djangocms_content_expiry/calendar_icon.html index 75897f6..0ccb7a7 100644 --- a/djangocms_content_expiry/templates/djangocms_content_expiry/calendar_icon.html +++ b/djangocms_content_expiry/templates/djangocms_content_expiry/calendar_icon.html @@ -1,2 +1,2 @@ {% load static i18n %} - + diff --git a/tests/requirements/requirements_base.txt b/tests/requirements/requirements_base.txt index c690a4c..cd7c935 100644 --- a/tests/requirements/requirements_base.txt +++ b/tests/requirements/requirements_base.txt @@ -1,4 +1,5 @@ argparse +beautifulsoup4 coverage<5 dj-database-url django-admin-rangefilter @@ -11,6 +12,7 @@ djangocms-admin-style>=1.5 factory-boy freezegun iptools +lxml mock>=2.0.0 pyenchant pyflakes==1.1.0 diff --git a/tests/test_admin.py b/tests/test_admin.py index 244ce8a..17ff9b2 100644 --- a/tests/test_admin.py +++ b/tests/test_admin.py @@ -3,13 +3,14 @@ from django.contrib import admin from django.contrib.sites.models import Site from django.contrib.sites.shortcuts import get_current_site -from django.test import override_settings +from django.test import RequestFactory, override_settings from django.utils import timezone from cms.api import create_page from cms.models import PageContent from cms.test_utils.testcases import CMSTestCase +from bs4 import BeautifulSoup from djangocms_versioning.constants import DRAFT, PUBLISHED from djangocms_content_expiry.admin import ContentExpiryAdmin @@ -89,6 +90,19 @@ def test_change_form_fields(self): self.assertIn('name="expires_0"', decoded_response) self.assertIn('name="expires_1"', decoded_response) + def test_change_form_title(self): + """ + The change form title is populated with the custom value + """ + content_expiry = PollContentExpiryFactory() + endpoint = self.get_admin_url(ContentExpiry, "change", content_expiry.pk) + + with self.login_user_context(self.get_superuser()): + response = self.client.get(endpoint) + + self.assertEqual(response.status_code, 200) + self.assertEqual(response.context_data['title'], 'Additional content settings') + class ContentExpiryChangelistTestCase(CMSTestCase): def setUp(self): @@ -140,6 +154,22 @@ def test_preview_link_draft_object(self): poll_content.get_preview_url() ) + def test_change_icon_tooltip(self): + """ + The change list presents the correct tooltip when hovering over the change expiry icon + """ + content_expiry = PollContentExpiryFactory(version__state=DRAFT) + request = RequestFactory().get("/admin/djangocms_content_expiry/") + edit_link = self.site._registry[ContentExpiry]._get_edit_link(content_expiry, request) + + soup = BeautifulSoup(str(edit_link), features="lxml") + actual_link = soup.find("a") + link_title_tooltip = actual_link.get("title") + + self.assertEqual( + link_title_tooltip, 'Additional content settings' + ) + class ContentExpiryCsvExportFileTestCase(CMSTestCase): def setUp(self):