Skip to content

Commit

Permalink
feat: option to include deleted drafts while fetching unpublished ent…
Browse files Browse the repository at this point in the history
…ities

By default, this is set to False.
  • Loading branch information
navinkarkera committed Aug 14, 2024
1 parent 835c9a1 commit 46da6c8
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions openedx_learning/apps/authoring/publishing/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,20 @@ 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'))
def get_entities_with_unpublished_changes(
learning_package_id: int,
/,
include_deleted_drafts: bool = False
) -> QuerySet[PublishableEntity]:
"""
Fetch entities that have unpublished changes.
By default, this excludes soft-deleted drafts but can be included using include_deleted_drafts option.
"""
query_filters = {"learning_package_id": learning_package_id}
if not include_deleted_drafts:
query_filters['draft__version__isnull'] = False
return PublishableEntity.objects.filter(**query_filters).exclude(draft__version=F('published__version'))


def get_entities_with_unpublished_deletes(learning_package_id: int, /) -> QuerySet[PublishableEntity]:
Expand Down

0 comments on commit 46da6c8

Please sign in to comment.