Skip to content

Commit

Permalink
WCM-401: Auto area with CP source now also hides dupes of the source CP
Browse files Browse the repository at this point in the history
  • Loading branch information
wosc committed Nov 15, 2024
1 parent 78eec48 commit 9ab9dc8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions core/docs/changelog/WCM-401.change
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
WCM-401: Auto area with CP source now also hides dupes of the source CP
12 changes: 12 additions & 0 deletions core/src/zeit/content/cp/tests/test_automatic.py
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,18 @@ def test_cp_content_query_filters_duplicates(self):
'http://xml.zeit.de/t3', list(IRenderedArea(self.area).values()[0])[0].uniqueId
)

def test_cp_content_query_filters_even_if_source_cp_did_not(self):
source = self.create_and_checkout_centerpage(
name='cp_with_dupes',
contents=[self.repository['t1'], self.repository['t1'], self.repository['t2']],
)
zeit.cms.checkout.interfaces.ICheckinManager(source).checkin()
self.area.referenced_cp = self.repository['cp_with_dupes']
self.assertEqual(
['http://xml.zeit.de/t1', 'http://xml.zeit.de/t2'],
[list(x)[0].uniqueId for x in IRenderedArea(self.area).values()],
)

def test_tms_content_query_filters_duplicates(self):
self.area.automatic_type = 'topicpage'
self.area.referenced_topicpage = 'mytopic'
Expand Down
10 changes: 6 additions & 4 deletions core/src/zeit/contentquery/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,16 +600,18 @@ class CenterpageContentQuery(ContentQuery):

def __call__(self):
teasered = zeit.content.cp.interfaces.ITeaseredContent(self.context.referenced_cp, iter([]))
result = []
result = {}
for content in teasered:
if zeit.content.cp.blocks.rss.IRSSLink.providedBy(content):
continue
if self.context.hide_dupes and content in self.context.existing_teasers:
if self.context.hide_dupes and (
content in self.context.existing_teasers or content in result
):
continue
result.append(content)
result[content] = True
if len(result) >= self.rows:
break
return result
return list(result)


class RSSFeedContentQuery(ContentQuery):
Expand Down

0 comments on commit 9ab9dc8

Please sign in to comment.