diff --git a/openedx_events/learning/data.py b/openedx_events/learning/data.py new file mode 100644 index 00000000..899b1091 --- /dev/null +++ b/openedx_events/learning/data.py @@ -0,0 +1,87 @@ +""" +Data attributes for events within the architecture subdomain `learning`. + +These attributes follow the form of attr objects specified in OEP-49 data +pattern. +""" +from typing import Dict + +import attr +from opaque_keys.edx.keys import CourseKey + + +@attr.s(frozen=True) +class UserProfileData: + """ + Attributes defined for Open edX student's profile object. + """ + + meta = attr.ib(type=Dict[str, str], factory=dict) + name = attr.ib(type=str, factory=str) + + +@attr.s(frozen=True) +class StudentData: + """ + Attributes defined for Open edX student object. + """ + + username = attr.ib(type=str) + email = attr.ib(type=str) + first_name = attr.ib(type=str, factory=str) + last_name = attr.ib(type=str, factory=str) + is_active = attr.ib(type=bool, default=True) + profile = attr.ib(type=UserProfileData, default=UserProfileData()) + + +@attr.s(frozen=True) +class RegistrationData: + """ + Attributes defined for Open edX registration profile object. + """ + + activation_key = attr.ib(type=str) + + +@attr.s(frozen=True) +class CourseOverviewData: + """ + Attributes defined for Open edX Course Overview object. + """ + + course_key = attr.ib(type=CourseKey) + display_name = attr.ib(type=CourseKey, factory=str) + + +@attr.s(frozen=True) +class CourseEnrollmentData: + """ + Attributes defined for Open edX Course Enrollment object. + """ + + user = attr.ib(type=StudentData) + course = attr.ib(type=CourseOverviewData) + mode = attr.ib(type=str) + is_active = attr.ib(type=bool) + + +@attr.s(frozen=True) +class CertificateData(CourseEnrollmentData): + """ + Attributes defined for Open edX Certificate data object. + """ + + grade = attr.ib(type=str) + status = attr.ib(type=str) + download_url = attr.ib(type=str) + name = attr.ib(type=str) + + +@attr.s(frozen=True) +class CohortData: + """ + Attributes defined for Open edX Cohort Membership object. + """ + + user = attr.ib(type=StudentData) + course = attr.ib(type=CourseOverviewData) diff --git a/requirements/base.in b/requirements/base.in index fd083527..9f7cd0ec 100644 --- a/requirements/base.in +++ b/requirements/base.in @@ -1,5 +1,7 @@ # Core requirements for using this application -c constraints.txt +attrs django django-crum +edx-opaque-keys[django] diff --git a/requirements/base.txt b/requirements/base.txt index 36f758e9..2617719d 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -4,14 +4,25 @@ # # make upgrade # +attrs==21.2.0 + # via -r requirements/base.in +django-crum==0.7.9 + # via -r requirements/base.in django==2.2.24 # via # -c requirements/constraints.txt # -r requirements/base.in # django-crum -django-crum==0.7.9 + # edx-opaque-keys +edx-opaque-keys[django]==2.2.1 # via -r requirements/base.in +pbr==5.6.0 + # via stevedore +pymongo==3.11.4 + # via edx-opaque-keys pytz==2021.1 # via django sqlparse==0.4.1 # via django +stevedore==3.3.0 + # via edx-opaque-keys diff --git a/requirements/dev.txt b/requirements/dev.txt index ba4c72bf..b0161e7d 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -76,20 +76,23 @@ distlib==0.3.2 # via # -r requirements/ci.txt # virtualenv +django-crum==0.7.9 + # via -r requirements/quality.txt django==2.2.24 # via # -c requirements/constraints.txt # -r requirements/quality.txt # django-crum # edx-lint -django-crum==0.7.9 - # via -r requirements/quality.txt + # edx-opaque-keys docutils==0.17.1 # via # -r requirements/quality.txt # readme-renderer edx-lint==5.0.0 # via -r requirements/quality.txt +edx-opaque-keys[django]==2.2.1 + # via -r requirements/quality.txt filelock==3.0.12 # via # -r requirements/ci.txt @@ -211,6 +214,17 @@ pylint-plugin-utils==0.6 # -r requirements/quality.txt # pylint-celery # pylint-django +pylint==2.8.3 + # via + # -r requirements/quality.txt + # edx-lint + # pylint-celery + # pylint-django + # pylint-plugin-utils +pymongo==3.11.4 + # via + # -r requirements/quality.txt + # edx-opaque-keys pyparsing==2.4.7 # via # -r requirements/ci.txt @@ -281,6 +295,7 @@ stevedore==3.3.0 # via # -r requirements/quality.txt # code-annotations + # edx-opaque-keys text-unidecode==1.3 # via # -r requirements/quality.txt diff --git a/requirements/doc.txt b/requirements/doc.txt index 0ec46e2e..5a0186c6 100644 --- a/requirements/doc.txt +++ b/requirements/doc.txt @@ -32,13 +32,14 @@ coverage==5.5 # pytest-cov ddt==1.4.2 # via -r requirements/test.txt +django-crum==0.7.9 + # via -r requirements/test.txt django==2.2.24 # via # -c requirements/constraints.txt # -r requirements/test.txt # django-crum -django-crum==0.7.9 - # via -r requirements/test.txt + # edx-opaque-keys doc8==0.8.1 # via -r requirements/doc.in docutils==0.17.1 @@ -47,6 +48,8 @@ docutils==0.17.1 # readme-renderer # restructuredtext-lint # sphinx +edx-opaque-keys[django]==2.2.1 + # via -r requirements/test.txt edx-sphinx-theme==2.1.0 # via -r requirements/doc.in idna==2.10 @@ -89,6 +92,10 @@ pygments==2.9.0 # doc8 # readme-renderer # sphinx +pymongo==3.11.4 + # via + # -r requirements/test.txt + # edx-opaque-keys pyparsing==2.4.7 # via # -r requirements/test.txt @@ -154,6 +161,7 @@ stevedore==3.3.0 # -r requirements/test.txt # code-annotations # doc8 + # edx-opaque-keys text-unidecode==1.3 # via # -r requirements/test.txt diff --git a/requirements/quality.txt b/requirements/quality.txt index d5757c7a..a7b3847d 100644 --- a/requirements/quality.txt +++ b/requirements/quality.txt @@ -42,18 +42,21 @@ cryptography==3.4.7 # via secretstorage ddt==1.4.2 # via -r requirements/test.txt +django-crum==0.7.9 + # via -r requirements/test.txt django==2.2.24 # via # -c requirements/constraints.txt # -r requirements/test.txt # django-crum # edx-lint -django-crum==0.7.9 - # via -r requirements/test.txt + # edx-opaque-keys docutils==0.17.1 # via readme-renderer edx-lint==5.0.0 # via -r requirements/quality.in +edx-opaque-keys[django]==2.2.1 + # via -r requirements/test.txt idna==2.10 # via requests importlib-metadata==4.6.0 @@ -127,6 +130,16 @@ pylint-plugin-utils==0.6 # via # pylint-celery # pylint-django +pylint==2.8.3 + # via + # edx-lint + # pylint-celery + # pylint-django + # pylint-plugin-utils +pymongo==3.11.4 + # via + # -r requirements/test.txt + # edx-opaque-keys pyparsing==2.4.7 # via # -r requirements/test.txt @@ -179,6 +192,7 @@ stevedore==3.3.0 # via # -r requirements/test.txt # code-annotations + # edx-opaque-keys text-unidecode==1.3 # via # -r requirements/test.txt diff --git a/requirements/test.txt b/requirements/test.txt index 17184c79..ae1b5e34 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -5,7 +5,9 @@ # make upgrade # attrs==21.2.0 - # via pytest + # via + # -r requirements/base.txt + # pytest click==8.0.1 # via code-annotations code-annotations==1.1.2 @@ -14,12 +16,15 @@ coverage==5.5 # via pytest-cov ddt==1.4.2 # via -r requirements/test.in +django-crum==0.7.9 + # via -r requirements/base.txt django==2.2.24 # via # -c requirements/constraints.txt # -r requirements/base.txt # django-crum -django-crum==0.7.9 + # edx-opaque-keys +edx-opaque-keys[django]==2.2.1 # via -r requirements/base.txt iniconfig==1.1.1 # via pytest @@ -30,11 +35,17 @@ markupsafe==2.0.1 packaging==20.9 # via pytest pbr==5.6.0 - # via stevedore + # via + # -r requirements/base.txt + # stevedore pluggy==0.13.1 # via pytest py==1.10.0 # via pytest +pymongo==3.11.4 + # via + # -r requirements/base.txt + # edx-opaque-keys pyparsing==2.4.7 # via packaging pytest==6.2.4 @@ -58,7 +69,10 @@ sqlparse==0.4.1 # -r requirements/base.txt # django stevedore==3.3.0 - # via code-annotations + # via + # -r requirements/base.txt + # code-annotations + # edx-opaque-keys text-unidecode==1.3 # via python-slugify toml==0.10.2