Skip to content

Commit 105dbe2

Browse files
committed
Robust solution for filtering unpublishable changes on frontend
1 parent f18cdf8 commit 105dbe2

4 files changed

Lines changed: 9 additions & 1 deletion

File tree

contentcuration/contentcuration/frontend/shared/data/serverSync.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,12 @@ function handleMaxRevs(response, userId) {
175175
maxRevs[`${MAX_REV_KEY}.${channelId}`] = channelChanges[0].server_rev;
176176
const lastChannelEditIndex = findLastIndex(
177177
channelChanges,
178-
c => !c.errors && !c.user_id && c.created_by_id && c.type !== CHANGE_TYPES.PUBLISHED,
178+
c =>
179+
!c.errors &&
180+
!c.user_id &&
181+
c.created_by_id &&
182+
c.type !== CHANGE_TYPES.PUBLISHED &&
183+
!c.unpublishable,
179184
);
180185
const lastPublishIndex = findLastIndex(
181186
channelChanges,

contentcuration/contentcuration/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3817,6 +3817,7 @@ def serialize(cls, change):
38173817
"channel_id": get_attribute(change, ["channel_id"]),
38183818
"user_id": get_attribute(change, ["user_id"]),
38193819
"created_by_id": get_attribute(change, ["created_by_id"]),
3820+
"unpublishable": get_attribute(change, ["unpublishable"]),
38203821
}
38213822
)
38223823
return datum

contentcuration/contentcuration/viewsets/community_library_submission.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ def _add_to_community_library(self, submission):
320320
categories=submission.categories,
321321
country_codes=country_codes,
322322
),
323+
created_by_id=submission.resolved_by_id,
323324
# This change is not publishable and should not trigger publish-related logic
324325
unpublishable=True,
325326
)

contentcuration/contentcuration/viewsets/sync/endpoint.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ def return_changes(self, request, channel_revs):
155155
"table",
156156
"change_type",
157157
"kwargs",
158+
"unpublishable",
158159
)
159160
.order_by("server_rev")[:CHANGE_RETURN_LIMIT]
160161
)

0 commit comments

Comments
 (0)