File tree Expand file tree Collapse file tree 3 files changed +24
-1
lines changed Expand file tree Collapse file tree 3 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ Changelog
5
5
Unreleased
6
6
==========
7
7
8
+ * fix: Snippet plugin added to a page now displays name instead of ID
8
9
* fix: Slug field on list display for admin should only be displayed when versioning is not available
9
10
10
11
4.0.0.dev2 (2021-12-22)
Original file line number Diff line number Diff line change @@ -106,6 +106,10 @@ class SnippetPtr(CMSPlugin):
106
106
107
107
search_fields = ['snippet__html' ] if SEARCH_ENABLED else []
108
108
109
+ def get_short_description (self ):
110
+ snippet_label = SnippetGrouper .objects .filter (pk = self .snippet_grouper .pk ).first ()
111
+ return snippet_label
112
+
109
113
class Meta :
110
114
verbose_name = _ ('Snippet Ptr' )
111
115
verbose_name_plural = _ ('Snippet Ptrs' )
Original file line number Diff line number Diff line change 3
3
from cms .api import add_plugin , create_page
4
4
from cms .models import PageContent
5
5
from cms .test_utils .testcases import CMSTestCase
6
- from cms .toolbar .utils import get_object_edit_url
6
+ from cms .toolbar .utils import get_object_edit_url , get_object_structure_url
7
7
8
8
from djangocms_snippet .models import Snippet , SnippetGrouper
9
9
from djangocms_versioning .models import Version
@@ -290,3 +290,21 @@ def test_published_snippet_and_page_live_url_rendering(self):
290
290
291
291
self .assertContains (response , "<p>Published snippet</p>" )
292
292
self .assertNotIn ("Draft snippet" , str (response .content ))
293
+
294
+ def test_correct_name_is_displayed_for_snippet_component_on_page (self ):
295
+ """
296
+ If a component is added to the page, it should show the snippet name and not ID
297
+ """
298
+ add_plugin (
299
+ self .draft_pagecontent .placeholders .get (slot = "content" ),
300
+ "SnippetPlugin" ,
301
+ self .language ,
302
+ snippet_grouper = self .draft_snippet .snippet_grouper ,
303
+ )
304
+
305
+ # Request structure endpoint on page
306
+ request_url = get_object_structure_url (self .draft_pagecontent , "en" )
307
+ with self .login_user_context (self .superuser ):
308
+ response = self .client .get (request_url )
309
+
310
+ self .assertContains (response , "<strong>Snippet</strong> plugin_snippet</span>" )
You can’t perform that action at this time.
0 commit comments