Skip to content

Commit

Permalink
Merge branch 'main' into MJG/upgrade-ci-matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
mariajgrimaldi authored Sep 9, 2024
2 parents 0a8d69b + eb17e03 commit f0849dc
Show file tree
Hide file tree
Showing 20 changed files with 876 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ updates:
directory: "/"
schedule:
# Check for updates to GitHub Actions every week
interval: "weekly"
interval: "weekly"
38 changes: 37 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,44 @@ Change Log

.. There should always be an "Unreleased" section for changes pending release.
Unreleased
----------
__________



[9.14.0] - 2024-09-12
---------------------

Added
~~~~~

* Adds event ``CONTENT_OBJECT_ASSOCIATIONS_CHANGED``
* Added new ``LIBRARY_COLLECTION_CREATED``, ``LIBRARY_COLLECTION_UPDATED`` and ``LIBRARY_COLLECTION_DELETED`` events in content_authoring.
* Adds ``ContentObjectChangedData``, which inherits from ContentObjectData and adds an optional list of string ``changes``.

Deprecated
~~~~~~~~~~

* Deprecated event ``CONTENT_OBJECT_TAGS_CHANGED`` in favor of ``CONTENT_OBJECT_ASSOCIATIONS_CHANGED``
Plan to remove after Sumac.

[9.13.0] - 2024-09-05
---------------------

Added
~~~~~~~

* Added new IDV events ``LEARNER_CREDIT_COURSE_ENROLLMENT_REVOKED``, ``IDV_ATTEMPT_CREATED``, ``IDV_ATTEMPT_PENDING``, ``IDV_ATTEMPT_APPROVED``, and ``IDV_ATTEMPT_DENIED`` in learning.

[9.12.0] - 2024-07-31
---------------------

Added
~~~~~~~

* Added new enterprise signal ``LEARNER_CREDIT_COURSE_ENROLLMENT_REVOKED``.

[9.11.0] - 2024-05-15
---------------------
Expand Down
2 changes: 1 addition & 1 deletion docs/concepts/hooks-extension-framework.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ are meant to be extended using Open edX plugins and configuration.

Hooks can be of two types, events and filters. Events are in essence signals, in
that they are sent in specific application places and whose listeners can extend
functionality. functionality. On the other hand Filters can be used to act on data before
functionality. On the other hand Filters can be used to act on data before
it is put back in the original application flow. In order to allow
extension developers to use the Events and Filters definitions on their plugins,
both kinds of hooks are defined in lightweight external libraries.
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.11.0"
__version__ = "9.14.0"
33 changes: 32 additions & 1 deletion openedx_events/content_authoring/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class LibraryBlockData:
@attr.s(frozen=True)
class ContentObjectData:
"""
Data about changed content object.
Data about a content object.
Arguments:
object_id (str): identifier of the Content object. This represents the id of the course or library block
Expand All @@ -194,3 +194,34 @@ class ContentObjectData:
"""

object_id = attr.ib(type=str)


@attr.s(frozen=True)
class ContentObjectChangedData(ContentObjectData):
"""
Data about a changed content object.
Arguments:
object_id (str): identifier of the Content object. This represents the id of the course or library block
as a string. For example:
block-v1:SampleTaxonomyOrg2+STC1+2023_1+type@vertical+block@f8de78f0897049ce997777a3a31b6ea0
changes: list of changes made to this ContentObject, e.g. "tags", "collections"
If list is empty, assume everything has changed.
"""

changes = attr.ib(type=List[str], factory=list)


@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_key (str): identifies the collection within the library's learning package
"""

library_key = attr.ib(type=LibraryLocatorV2)
collection_key = attr.ib(type=str)
47 changes: 47 additions & 0 deletions openedx_events/content_authoring/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
from openedx_events.content_authoring.data import (
CertificateConfigData,
ContentLibraryData,
ContentObjectChangedData,
ContentObjectData,
CourseCatalogData,
CourseData,
DuplicatedXBlockData,
LibraryBlockData,
LibraryCollectionData,
XBlockData,
)
from openedx_events.tooling import OpenEdxPublicSignal
Expand Down Expand Up @@ -200,13 +202,58 @@
}
)

# .. event_type: org.openedx.content_authoring.content.object.associations.changed.v1
# .. event_name: CONTENT_OBJECT_ASSOCIATIONS_CHANGED
# .. event_description: emitted when an object's associations are changed, e.g tags, collections
# .. event_data: ContentObjectData
CONTENT_OBJECT_ASSOCIATIONS_CHANGED = OpenEdxPublicSignal(
event_type="org.openedx.content_authoring.content.object.associations.changed.v1",
data={
"content_object": ContentObjectChangedData
}
)

# .. event_type: org.openedx.content_authoring.content.object.tags.changed.v1
# .. event_name: CONTENT_OBJECT_TAGS_CHANGED
# .. event_description: emitted when an object's tags are changed
# DEPRECATED: please use CONTENT_OBJECT_ASSOCIATIONS_CHANGED instead.
# .. event_data: ContentObjectData
CONTENT_OBJECT_TAGS_CHANGED = OpenEdxPublicSignal(
event_type="org.openedx.content_authoring.content.object.tags.changed.v1",
data={
"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
}
)
119 changes: 119 additions & 0 deletions openedx_events/enterprise/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,122 @@ class LedgerTransaction(BaseLedgerTransaction):
parent_content_key = attr.ib(type=str, default=None)
fulfillment_identifier = attr.ib(type=str, default=None)
reversal = attr.ib(type=LedgerTransactionReversal, default=None)


@attr.s(frozen=True)
class EnterpriseCustomerUser:
"""
Attributes of an ``enterprise.EnterpriseCustomerUser`` record.
Django model definition: https://github.com/openedx/edx-enterprise/blob/cc873d6/enterprise/models.py#L1036
Arguments:
id (int): Primary identifier of the record.
created (datetime): When the record was created.
modified (datetime): When the record was last modified.
enterprise_customer_uuid (UUID): The enterprise customer to which the user is linked.
user_id (int): The LMS user ID corresponding to this enterprise user.
active (bool): The active enterprise user for the given LMS user.
linked (bool): This enterprise user has been linked to an enterprise customer.
is_relinkable (bool): When set to False, the user cannot be relinked to the enterprise.
invite_key (UUID): Invite key used to link a learner to an enterprise.
should_inactivate_other_customers (bool): When enabled along with `active`, all other linked enterprise
customers for this user will be marked as inactive upon save.
"""

id = attr.ib(type=int)
created = attr.ib(type=datetime)
modified = attr.ib(type=datetime)
enterprise_customer_uuid = attr.ib(type=UUID)
user_id = attr.ib(type=int)
active = attr.ib(type=bool)
linked = attr.ib(type=bool)
is_relinkable = attr.ib(type=bool)
invite_key = attr.ib(type=UUID)
should_inactivate_other_customers = attr.ib(type=bool)


@attr.s(frozen=True)
class EnterpriseCourseEnrollment:
"""
Attributes of an ``enterprise.EnterpriseCourseEnrollment`` record.
Django model definition: https://github.com/openedx/edx-enterprise/blob/cc873d6/enterprise/models.py#L1983
Arguments:
id (int): Primary identifier of the record.
created (datetime): When the record was created.
modified (datetime): When the record was last modified.
enterprise_customer_user (EnterpriseCustomerUser): The enterprise learner to which this enrollment is attached.
course_id (CourseKey): The ID of the course in which the learner was enrolled.
saved_for_later (bool): Specifies whether a user marked this course as saved for later in the learner portal.
source_slug (str): DB slug for the source of the enrollment, e.g. "enrollment_task", "management_command", etc.
unenrolled (bool): Specifies whether the related LMS course enrollment object was unenrolled.
unenrolled_at (datetime): Specifies when the related LMS course enrollment object was unenrolled.
"""

id = attr.ib(type=int)
created = attr.ib(type=datetime)
modified = attr.ib(type=datetime)
enterprise_customer_user = attr.ib(type=EnterpriseCustomerUser)
course_id = attr.ib(type=CourseKey)
saved_for_later = attr.ib(type=bool)
source_slug = attr.ib(type=str)
unenrolled = attr.ib(type=bool)
unenrolled_at = attr.ib(type=datetime)


@attr.s(frozen=True)
class BaseEnterpriseFulfillment:
"""
Defines the common attributes of enterprise fulfillment classes, i.e. ``enterprise.EnterpriseFulfillmentSource``.
Django model definition: https://github.com/openedx/edx-enterprise/blob/cc873d6/enterprise/models.py#L2213
Arguments:
uuid (str): Primary identifier of the record.
created (datetime): When the record was created.
modified (datetime): When the record was last modified.
fulfillment_type (str): Subsidy fulfillment type, typical values: "license", "learner_credit", "coupon_code".
enterprise_course_entitlement_uuid (UUID): The course entitlement the associated subsidy is for.
enterprise_course_enrollment (EnterpriseCourseEnrollment): The course enrollment the associated subsidy is for.
is_revoked (bool): Whether the enterprise subsidy is revoked, e.g., when a user's license is revoked.
"""

uuid = attr.ib(type=UUID)
created = attr.ib(type=datetime)
modified = attr.ib(type=datetime)
fulfillment_type = attr.ib(type=str)
enterprise_course_entitlement_uuid = attr.ib(type=UUID)
enterprise_course_enrollment = attr.ib(type=EnterpriseCourseEnrollment)
is_revoked = attr.ib(type=bool)


@attr.s(frozen=True)
class LearnerCreditEnterpriseCourseEnrollment(BaseEnterpriseFulfillment):
"""
Attributes of an ``enterprise.LearnerCreditEnterpriseCourseEnrollment`` record.
Django model definition: https://github.com/openedx/edx-enterprise/blob/cc873d6/enterprise/models.py#L2325
Arguments:
(All of the same from BaseEnterpriseFulfillment plus the following:)
transaction_id (UUID): Ledgered transaction UUID to associate with this learner credit fulfillment.
"""

transaction_id = attr.ib(type=UUID)


@attr.s(frozen=True)
class LicensedEnterpriseCourseEnrollment(BaseEnterpriseFulfillment):
"""
Attributes of an ``enterprise.LicensedEnterpriseCourseEnrollment`` record.
Django model definition: https://github.com/openedx/edx-enterprise/blob/cc873d6/enterprise/models.py#L2355
Arguments:
(All of the same from BaseEnterpriseFulfillment plus the following:)
license_uuid (UUID): License UUID to associate with this enterprise license fulfillment.
"""

license_uuid = attr.ib(type=UUID)
15 changes: 14 additions & 1 deletion openedx_events/enterprise/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
docs/decisions/0003-events-payload.rst
"""

from openedx_events.enterprise.data import LedgerTransaction, SubsidyRedemption
from openedx_events.enterprise.data import LearnerCreditEnterpriseCourseEnrollment, LedgerTransaction, SubsidyRedemption
from openedx_events.tooling import OpenEdxPublicSignal

# .. event_type: org.openedx.enterprise.subsidy.redeemed.v1
Expand Down Expand Up @@ -84,3 +84,16 @@
"ledger_transaction": LedgerTransaction,
}
)


# .. event_type: org.openedx.enterprise.learner_credit_course_enrollment.revoked.v1
# .. event_name: LEARNER_CREDIT_COURSE_ENROLLMENT_REVOKED
# .. event_description: emitted when a LearnerCreditEnterpriseCourseEnrollment is revoked. This most often happens when
# an enterprise learner unenrolls from a course which was LC-subsidized.
# .. event_data: LearnerCreditEnterpriseCourseEnrollment
LEARNER_CREDIT_COURSE_ENROLLMENT_REVOKED = OpenEdxPublicSignal(
event_type="org.openedx.enterprise.learner_credit_course_enrollment.revoked.v1",
data={
"learner_credit_course_enrollment": LearnerCreditEnterpriseCourseEnrollment,
}
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "CloudEvent",
"type": "record",
"doc": "Avro Event Format for CloudEvents created with openedx_events/schema",
"fields": [
{
"name": "content_object",
"type": {
"name": "ContentObjectChangedData",
"type": "record",
"fields": [
{
"name": "object_id",
"type": "string"
},
{
"name": "changes",
"type": {
"type": "array",
"items": "string"
}
}
]
}
}
],
"namespace": "org.openedx.content_authoring.content.object.associations.changed.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_key",
"type": "string"
}
]
}
}
],
"namespace": "org.openedx.content_authoring.content_library.collection.created.v1"
}
Loading

0 comments on commit f0849dc

Please sign in to comment.