Skip to content

Commit

Permalink
Change view title and view expiry icon tooltip value changed (#49)
Browse files Browse the repository at this point in the history
* Change view title and icon tooltips name changed

* Test added for icon tooltip label change

* isort

* Update tests/test_admin.py

Co-authored-by: Adam Murray <[email protected]>

* Update tests/test_admin.py

Co-authored-by: Adam Murray <[email protected]>

* Changed copy icon label to Copy Expiry

* added bs4 for test case to find correct title

* moved import to top

* isort

* Renamed to Additional content settings

Co-authored-by: Adam Murray <[email protected]>
Co-authored-by: Aiky30 <[email protected]>
  • Loading branch information
3 people authored Jun 15, 2022
1 parent 0e33389 commit 8290047
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions djangocms_content_expiry/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
{% load static i18n %}
<a class="btn cms-moderation-action-btn js-moderation-action" id="copy_content_expiry_id_{{ field_id }}" href="{{ url }}" title="{% trans 'View Expiry' %}"><span class="svg-juxtaposed-font"><img src="{% static 'djangocms_content_expiry/svg/calendar_copy.svg' %}" /></span></a>
<a class="btn cms-moderation-action-btn js-moderation-action" id="copy_content_expiry_id_{{ field_id }}" href="{{ url }}" title="{% trans 'Copy Expiry' %}"><span class="svg-juxtaposed-font"><img src="{% static 'djangocms_content_expiry/svg/calendar_copy.svg' %}" /></span></a>
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
{% load static i18n %}
<a class="btn cms-content-expiry-action-btn" href="{{ url }}" title="{% trans 'View Expiry' %}"><span class="svg-juxtaposed-font"><img src="{% static 'djangocms_content_expiry/svg/edit.svg' %}" /></span></a>
<a class="btn cms-content-expiry-action-btn" href="{{ url }}" title="{% trans 'Additional content settings' %}"><span class="svg-juxtaposed-font"><img src="{% static 'djangocms_content_expiry/svg/edit.svg' %}" /></span></a>
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
{% load static i18n %}
<a class="btn cms-moderation-action-btn js-moderation-action related-widget-wrapper-link" id="change_content_expiry_id_{{ field_id }}" href="{{ url }}" title="{% trans 'View Expiry' %}"><span class="svg-juxtaposed-font"><img src="{% static 'djangocms_content_expiry/svg/calendar.svg' %}" /></span></a>
<a class="btn cms-moderation-action-btn js-moderation-action related-widget-wrapper-link" id="change_content_expiry_id_{{ field_id }}" href="{{ url }}" title="{% trans 'Additional content settings' %}"><span class="svg-juxtaposed-font"><img src="{% static 'djangocms_content_expiry/svg/calendar.svg' %}" /></span></a>
2 changes: 2 additions & 0 deletions tests/requirements/requirements_base.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
argparse
beautifulsoup4
coverage<5
dj-database-url
django-admin-rangefilter
Expand All @@ -11,6 +12,7 @@ djangocms-admin-style>=1.5
factory-boy
freezegun
iptools
lxml
mock>=2.0.0
pyenchant
pyflakes==1.1.0
Expand Down
32 changes: 31 additions & 1 deletion tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 8290047

Please sign in to comment.