Skip to content

Support for sticky items, basic article content in the item payload#3222

Open
IvanJelicSF wants to merge 7 commits into
superdesk:feature/content-lists-with-developfrom
IvanJelicSF:SDESK-7929-SDESK-7935-Sticky-article-content
Open

Support for sticky items, basic article content in the item payload#3222
IvanJelicSF wants to merge 7 commits into
superdesk:feature/content-lists-with-developfrom
IvanJelicSF:SDESK-7929-SDESK-7935-Sticky-article-content

Conversation

@IvanJelicSF
Copy link
Copy Markdown

@IvanJelicSF IvanJelicSF commented May 20, 2026

Summary

Adds three related capabilities to the content-lists bulk-patch flow:

  1. Sticky flag on move. The move action now reads and writes the sticky field, so items can be pinned or unpinned in the same call that repositions them. When sticky is omitted the existing value is preserved.
  2. Article content in list-item responses. GET responses for /content_lists/<id>/items are enriched with an article_content object (title, state, thumbnail) for every item. The thumbnail prefers the feature-media thumbnail rendition and falls back to the first <img> in body_html.
  3. Unique positions after every batch. A new _renumber step runs after each bulk patch and re-assigns positions so that every item has a unique slot. Sticky items and items touched by the current batch (add / move) anchor at their declared position; untouched non-sticky items fill the lowest free slots in their previous order. If two anchors collide, sticky wins, then the most recently touched within a group, with the loser spilling to the next free slot.

Files changed

File Change
apps/content_lists/article_content.py New. Async enrichment helpers (attach_article_content, enrich_fetched_response, enrich_fetched_item) and thumbnail extraction.
apps/content_lists/rest_endpoints.py Wires on_fetched / on_fetched_item to the new enrichment hooks.
apps/content_lists/service.py move reads/writes sticky; tracks touched items; calls new _renumber to keep positions unique via a single bulk UpdateOne write.
features/content_lists.feature Six new BDD scenarios covering sticky toggling, sticky preservation, position shifting on move/add, position shifting on delete, and the higher-position move case.

Diffstat: 4 files changed, 397 insertions(+), 2 deletions(-)

Commits

Behaviour notes

  • _renumber is a no-op when nothing needs to change — only positions that actually shift are written, via a single bulk_write(ordered=False).
  • move without an explicit sticky keeps the previous value (verified by Move action preserves sticky flag when not provided).
  • article_content is None for items whose archive document cannot be found, so the field is always present in responses.
  • Thumbnail lookup never raises — parse_html failures degrade silently to None.

Test plan

  • Run features/content_lists.feature — all six new scenarios should pass alongside the existing ones.
  • GET /content_lists/<id>/items returns article_content for items whose archive document exists, and null otherwise.
  • move with sticky: true pins an item; subsequent move with sticky: false unpins it.
  • Adding/moving items into occupied positions shifts neighbours so positions remain unique and contiguous from 0.
  • Deleting an item closes the gap (no holes in the position sequence).
  • Sticky items keep their declared position when other items are added, moved, or deleted around them.

Resolves: SDESK-7929 SDESK-7935

@IvanJelicSF IvanJelicSF changed the title Sdesk 7929 sdesk 7935 sticky article content Support for sticky items, basic article content in the item payload May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant