Skip to content

Commit

Permalink
fix: exclude deleted drafts while publishing
Browse files Browse the repository at this point in the history
Exclude draft entities with `null` version while publishing.
  • Loading branch information
navinkarkera committed Aug 7, 2024
1 parent be6a6de commit 682f73d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions openedx_learning/apps/authoring/publishing/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,10 @@ def get_all_drafts(learning_package_id: int, /) -> QuerySet[Draft]:

def get_entities_with_unpublished_changes(learning_package_id: int, /) -> QuerySet[PublishableEntity]:
return PublishableEntity.objects \
.filter(learning_package_id=learning_package_id) \
.exclude(draft__version=F('published__version'))
.filter(
learning_package_id=learning_package_id,
draft__version__isnull=False,
).exclude(draft__version=F('published__version'))


def get_entities_with_unpublished_deletes(learning_package_id: int, /) -> QuerySet[PublishableEntity]:
Expand Down Expand Up @@ -247,7 +249,7 @@ def publish_all_drafts(
"""
draft_qset = Draft.objects \
.select_related("entity__published") \
.filter(entity__learning_package_id=learning_package_id) \
.filter(entity__learning_package_id=learning_package_id, version__isnull=False) \
.exclude(entity__published__version_id=F("version_id"))
return publish_from_drafts(
learning_package_id, draft_qset, message, published_at, published_by
Expand Down

0 comments on commit 682f73d

Please sign in to comment.