Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Content Library Collections signals [FC-0062] #386

4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
---------------------

Expand Down
2 changes: 1 addition & 1 deletion openedx_events/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
more information about the project.
"""

__version__ = "9.12.0"
__version__ = "9.13.0"
14 changes: 14 additions & 0 deletions openedx_events/content_authoring/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
34 changes: 34 additions & 0 deletions openedx_events/content_authoring/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
CourseData,
DuplicatedXBlockData,
LibraryBlockData,
LibraryCollectionData,
XBlockData,
)
from openedx_events.tooling import OpenEdxPublicSignal
Expand Down Expand Up @@ -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(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bradenmacdonald Are we allowed to put new signals in this repo? Or are we supposed to put them in https://github.com/openedx/openedx-events ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm actually not sure. Maybe @mariajgrimaldi can answer? What's the difference between this signals.py and that signals.py?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I follow. This repo es openedx-events and both signals.py files are the same.

You are definitely allowed to propose new signal definitions in this repository and the location is correct. The idea of having the signal here instead of in the edx-platform code is that plugins that will listen for the signal can include this lightweight library in their dependencies instead of requiring edx-platform all the time.

Copy link

@bradenmacdonald bradenmacdonald Aug 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol whoops, please ignore my confusion. I thought this was edx-platform :/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries. Happy to address this in depth. As before, if you are planning to add a signal into edx-platform, then it would be better to write it here so plugins can use that without the large import.
However, other pattern we have seen is when a plugin defines a new signal and uses it in its own code. In that case if reuse of said signal is not a goal from the devs, then the definition can be left in the plugin as you could import that plugin as a library if you are writing a second level library/plugin.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My apologies for the noise! I could have sworn there was a signals.py file in openedx-learning, but it's not there now, so not sure what I was on about :)

Copy link
Contributor

@pomegranited pomegranited Aug 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, it was here in this closed PR! signals.py. I'm not going nuts.. 😊

event_type="org.openedx.content_authoring.content.library.collection.created.v1",
navinkarkera marked this conversation as resolved.
Show resolved Hide resolved
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",
navinkarkera marked this conversation as resolved.
Show resolved Hide resolved
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",
navinkarkera marked this conversation as resolved.
Show resolved Hide resolved
data={
"library_collection": LibraryCollectionData
}
)
Original file line number Diff line number Diff line change
@@ -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": "long"
}
]
}
}
],
"namespace": "org.openedx.content_authoring.content.library.collection.created.v1"
}
Original file line number Diff line number Diff line change
@@ -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": "long"
}
]
}
}
],
"namespace": "org.openedx.content_authoring.content.library.collection.deleted.v1"
}
Original file line number Diff line number Diff line change
@@ -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": "long"
}
]
}
}
],
"namespace": "org.openedx.content_authoring.content.library.collection.updated.v1"
}