Skip to content

Commit

Permalink
feat: [EDXOLDMNG-218] Signals to save/delete certificate configuratio…
Browse files Browse the repository at this point in the history
…n for a course
  • Loading branch information
NikolayBorovenskiy authored and ormsbee committed Jan 30, 2023
1 parent 0f106cb commit bab0b39
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 2 deletions.
54 changes: 54 additions & 0 deletions openedx_events/content_authoring/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
(see deprecation proposal at https://github.com/openedx/public-engineering/issues/160)
"""
from datetime import datetime
from typing import BinaryIO, List

import attr
from opaque_keys.edx.keys import CourseKey, UsageKey
Expand Down Expand Up @@ -82,3 +83,56 @@ class DuplicatedXBlockData(XBlockData):
"""

source_usage_key = attr.ib(type=UsageKey)


@attr.s(frozen=True)
class CertificateSignatoryData:
"""
Attributes defined for Open edX CertificateSignatory data object.
Arguments:
image (BinaryIO): certificate signature image.
name (str): name of signatory.
organization (str): organization that signatory belongs to.
title (int): signatory title.
"""

# Note: Please take care that the image field is BinaryIO, which means
# that a file can be passed as an array of bytes. Watch the size of this file.
# It can potentially be large, making it difficult to pass this data structure through the Event Bus
# (CloudEvent messages, which should be 64K or less) and store it on disk space.
# We suggest referring to MAX_ASSET_UPLOAD_FILE_SIZE_IN_MB, i.e. restriction in the Studio for such cases.
image = attr.ib(type=BinaryIO)
# end Note
name = attr.ib(type=str)
organization = attr.ib(type=str)
title = attr.ib(type=str)


@attr.s(frozen=True)
class CertificateConfigData:
"""
Attributes defined for Open edX CertificateConfig data object.
Arguments:
certificate_type (str): certificate type. Possible types are certificate relevant course modes:
- credit,
- verified,
- professional,
- no-id-professional,
- executive-education,
- paid-executive-education,
- paid-bootcamp,
- masters.
course_key (CourseKey): identifier of the Course object.
title (str): certificate title.
signatories (List[CertificateSignatoryData]): contains a collection of signatures
that belong to the certificate configuration.
is_active (bool): indicates whether the certifivate configuration is active.
"""

certificate_type = attr.ib(type=str)
course_key = attr.ib(type=CourseKey)
title = attr.ib(type=str)
signatories = attr.ib(type=List[CertificateSignatoryData], factory=list)
is_active = attr.ib(type=bool, default=False)
32 changes: 31 additions & 1 deletion openedx_events/content_authoring/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
docs/decisions/0003-events-payload.rst
"""

from openedx_events.content_authoring.data import CourseCatalogData, DuplicatedXBlockData, XBlockData
from openedx_events.content_authoring.data import (
CertificateConfigData,
CourseCatalogData,
DuplicatedXBlockData,
XBlockData,
)
from openedx_events.tooling import OpenEdxPublicSignal

# .. event_type: org.openedx.content_authoring.course.catalog_info.changed.v1
Expand Down Expand Up @@ -62,3 +67,28 @@
"xblock_info": DuplicatedXBlockData,
}
)


# .. event_type: org.openedx.content_authoring.course.certificate_config.changed.v1
# .. event_name: COURSE_CERTIFICATE_CONFIG_CHANGED
# .. event_description: Fired when a course certificate configuration changes in Studio.
# Warning: This event is currently incompatible with the event bus, list/dict cannot be serialized yet
# .. event_data: CertificateConfigData
COURSE_CERTIFICATE_CONFIG_CHANGED = OpenEdxPublicSignal(
event_type="org.openedx.content_authoring.course.certificate_config.changed.v1",
data={
"certificate_config": CertificateConfigData,
}
)

# .. event_type: org.openedx.content_authoring.course.certificate_config.deleted.v1
# .. event_name: COURSE_CERTIFICATE_CONFIG_DELETED
# .. event_description: Fired when a course certificate configuration deletes in Studio.
# Warning: This event is currently incompatible with the event bus, list/dict cannot be serialized yet
# .. event_data: CertificateConfigData
COURSE_CERTIFICATE_CONFIG_DELETED = OpenEdxPublicSignal(
event_type="org.openedx.content_authoring.course.certificate_config.deleted.v1",
data={
"certificate_config": CertificateConfigData,
}
)
6 changes: 5 additions & 1 deletion openedx_events/event_bus/avro/tests/test_avro.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@

# If a signal is explicitly not for use with the event bus, add it to this list
# and document why in the event's annotations
KNOWN_UNSERIALIZABLE_SIGNALS = ["org.openedx.learning.discussions.configuration.changed.v1"]
KNOWN_UNSERIALIZABLE_SIGNALS = [
"org.openedx.learning.discussions.configuration.changed.v1",
"org.openedx.content_authoring.course.certificate_config.changed.v1",
"org.openedx.content_authoring.course.certificate_config.deleted.v1",
]


def generate_test_event_data_for_data_type(data_type):
Expand Down

0 comments on commit bab0b39

Please sign in to comment.