From eb706d70e85a6e31b8344b3d222a7193fef8c017 Mon Sep 17 00:00:00 2001 From: Navin Karkera Date: Mon, 20 Jan 2025 10:15:47 +0530 Subject: [PATCH] feat: simple api to update learning context links status --- openedx_learning/apps/authoring/linking/api.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/openedx_learning/apps/authoring/linking/api.py b/openedx_learning/apps/authoring/linking/api.py index 2a6d87ff..0f04d648 100644 --- a/openedx_learning/apps/authoring/linking/api.py +++ b/openedx_learning/apps/authoring/linking/api.py @@ -20,6 +20,7 @@ 'get_entity_links', 'get_or_create_learning_context_link_status', 'update_or_create_entity_link', + 'update_learning_context_link_status', ] @@ -48,6 +49,23 @@ def get_or_create_learning_context_link_status( return status +def update_learning_context_link_status( + context_key: str, + status: LearningContextLinksStatusChoices, + updated: datetime | None = None +) -> LearningContextLinksStatus: + """ + Updates entity links processing status of given learning context. + """ + if not updated: + updated = datetime.now(tz=timezone.utc) + status = LearningContextLinksStatus.objects.filter(context_key=context_key).update( + status=status, + updated=updated, + ) + return status + + def get_entity_links(filters: dict[str, Any]) -> QuerySet[PublishableEntityLink]: """ Get entity links based on passed filters.