From 030965ef5b9ab8b67c4edc3af38ab16dc80e6e58 Mon Sep 17 00:00:00 2001 From: Yusuf Musleh Date: Sun, 25 Aug 2024 08:39:02 +0300 Subject: [PATCH] feat: Add Content Library Collections signals --- CHANGELOG.rst | 4 +++ openedx_events/__init__.py | 2 +- openedx_events/content_authoring/data.py | 14 ++++++++ openedx_events/content_authoring/signals.py | 34 +++++++++++++++++++ ...+library+collection+created+v1_schema.avsc | 25 ++++++++++++++ ...+library+collection+deleted+v1_schema.avsc | 25 ++++++++++++++ ...+library+collection+updated+v1_schema.avsc | 25 ++++++++++++++ 7 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 openedx_events/event_bus/avro/tests/schemas/org+openedx+content_authoring+content+library+collection+created+v1_schema.avsc create mode 100644 openedx_events/event_bus/avro/tests/schemas/org+openedx+content_authoring+content+library+collection+deleted+v1_schema.avsc create mode 100644 openedx_events/event_bus/avro/tests/schemas/org+openedx+content_authoring+content+library+collection+updated+v1_schema.avsc diff --git a/CHANGELOG.rst b/CHANGELOG.rst index c49ab2c7..6f22ea47 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -14,6 +14,10 @@ Change Log Unreleased ---------- +Added +~~~~~ +* Added new ``LIBRARY_COLLECTION_CREATED``, ``LIBRARY_COLLECTION_UPDATED`` and ``LIBRARY_COLLECTION_DELETED`` events in content_authoring. + [9.12.0] - 2024-07-31 --------------------- diff --git a/openedx_events/__init__.py b/openedx_events/__init__.py index 434522ad..445806a0 100644 --- a/openedx_events/__init__.py +++ b/openedx_events/__init__.py @@ -5,4 +5,4 @@ more information about the project. """ -__version__ = "9.12.0" +__version__ = "9.13.0" diff --git a/openedx_events/content_authoring/data.py b/openedx_events/content_authoring/data.py index 1483ddbc..c48a0b5a 100644 --- a/openedx_events/content_authoring/data.py +++ b/openedx_events/content_authoring/data.py @@ -194,3 +194,17 @@ class ContentObjectData: """ object_id = attr.ib(type=str) + + +@attr.s(frozen=True) +class LibraryCollectionData: + """ + Data about changed content library Collection. + + Arguments: + library_key (LibraryLocatorV2): a key that represents a Blockstore-based content library. + collection_id (int): an id (pk) that represents a collection associated with the content library. + """ + + library_key = attr.ib(type=LibraryLocatorV2) + collection_id = attr.ib(type=int) diff --git a/openedx_events/content_authoring/signals.py b/openedx_events/content_authoring/signals.py index 495d14d9..2b00ea15 100644 --- a/openedx_events/content_authoring/signals.py +++ b/openedx_events/content_authoring/signals.py @@ -15,6 +15,7 @@ CourseData, DuplicatedXBlockData, LibraryBlockData, + LibraryCollectionData, XBlockData, ) from openedx_events.tooling import OpenEdxPublicSignal @@ -210,3 +211,36 @@ "content_object": ContentObjectData } ) + +# .. event_type: org.openedx.content_authoring.content.library.collection.created.v1 +# .. event_name: LIBRARY_COLLECTION_CREATED +# .. event_description: emitted when a content library collection is created +# .. event_data: LibraryCollectionData +LIBRARY_COLLECTION_CREATED = OpenEdxPublicSignal( + event_type="org.openedx.content_authoring.content.library.collection.created.v1", + data={ + "library_collection": LibraryCollectionData + } +) + +# .. event_type: org.openedx.content_authoring.content.library.collection.updated.v1 +# .. event_name: LIBRARY_COLLECTION_UPDATED +# .. event_description: emitted when when a content library collection is updated +# .. event_data: LibraryCollectionData +LIBRARY_COLLECTION_UPDATED = OpenEdxPublicSignal( + event_type="org.openedx.content_authoring.content.library.collection.updated.v1", + data={ + "library_collection": LibraryCollectionData + } +) + +# .. event_type: org.openedx.content_authoring.content.library.collection.deleted.v1 +# .. event_name: LIBRARY_COLLECTION_DELETED +# .. event_description: emitted when an when a content library collection is deleted +# .. event_data: LibraryCollectionData +LIBRARY_COLLECTION_DELETED = OpenEdxPublicSignal( + event_type="org.openedx.content_authoring.content.library.collection.deleted.v1", + data={ + "library_collection": LibraryCollectionData + } +) diff --git a/openedx_events/event_bus/avro/tests/schemas/org+openedx+content_authoring+content+library+collection+created+v1_schema.avsc b/openedx_events/event_bus/avro/tests/schemas/org+openedx+content_authoring+content+library+collection+created+v1_schema.avsc new file mode 100644 index 00000000..02f40c3d --- /dev/null +++ b/openedx_events/event_bus/avro/tests/schemas/org+openedx+content_authoring+content+library+collection+created+v1_schema.avsc @@ -0,0 +1,25 @@ +{ + "name": "CloudEvent", + "type": "record", + "doc": "Avro Event Format for CloudEvents created with openedx_events/schema", + "fields": [ + { + "name": "library_collection", + "type": { + "name": "LibraryCollectionData", + "type": "record", + "fields": [ + { + "name": "library_key", + "type": "string" + }, + { + "name": "collection_id", + "type": "integer" + } + ] + } + } + ], + "namespace": "org.openedx.content_authoring.content.library.collection.created.v1" +} \ No newline at end of file diff --git a/openedx_events/event_bus/avro/tests/schemas/org+openedx+content_authoring+content+library+collection+deleted+v1_schema.avsc b/openedx_events/event_bus/avro/tests/schemas/org+openedx+content_authoring+content+library+collection+deleted+v1_schema.avsc new file mode 100644 index 00000000..fc77e499 --- /dev/null +++ b/openedx_events/event_bus/avro/tests/schemas/org+openedx+content_authoring+content+library+collection+deleted+v1_schema.avsc @@ -0,0 +1,25 @@ +{ + "name": "CloudEvent", + "type": "record", + "doc": "Avro Event Format for CloudEvents created with openedx_events/schema", + "fields": [ + { + "name": "library_collection", + "type": { + "name": "LibraryCollectionData", + "type": "record", + "fields": [ + { + "name": "library_key", + "type": "string" + }, + { + "name": "collection_id", + "type": "integer" + } + ] + } + } + ], + "namespace": "org.openedx.content_authoring.content.library.collection.deleted.v1" +} \ No newline at end of file diff --git a/openedx_events/event_bus/avro/tests/schemas/org+openedx+content_authoring+content+library+collection+updated+v1_schema.avsc b/openedx_events/event_bus/avro/tests/schemas/org+openedx+content_authoring+content+library+collection+updated+v1_schema.avsc new file mode 100644 index 00000000..33ab69ea --- /dev/null +++ b/openedx_events/event_bus/avro/tests/schemas/org+openedx+content_authoring+content+library+collection+updated+v1_schema.avsc @@ -0,0 +1,25 @@ +{ + "name": "CloudEvent", + "type": "record", + "doc": "Avro Event Format for CloudEvents created with openedx_events/schema", + "fields": [ + { + "name": "library_collection", + "type": { + "name": "LibraryCollectionData", + "type": "record", + "fields": [ + { + "name": "library_key", + "type": "string" + }, + { + "name": "collection_id", + "type": "integer" + } + ] + } + } + ], + "namespace": "org.openedx.content_authoring.content.library.collection.updated.v1" +} \ No newline at end of file