Skip to content

Commit

Permalink
feat: add data attributes definition for learning subdomain
Browse files Browse the repository at this point in the history
  • Loading branch information
mariajgrimaldi committed Jun 9, 2021
1 parent 1f8a798 commit aa94458
Show file tree
Hide file tree
Showing 7 changed files with 145 additions and 25 deletions.
87 changes: 87 additions & 0 deletions openedx_events/learning/data.py
Original file line number Diff line number Diff line change
@@ -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 ProfileData:
"""
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=ProfileData, default=ProfileData())


@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)
2 changes: 2 additions & 0 deletions requirements/base.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Core requirements for using this application
-c constraints.txt

attrs
django
django-crum
edx-opaque-keys[django]
15 changes: 12 additions & 3 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,24 @@
#
# make upgrade
#
asgiref==3.3.4
# via django
attrs==21.2.0
# via -r requirements/base.in
django-crum==0.7.9
# via -r requirements/base.in
django==3.2.4
django==2.2.24
# via
# -r requirements/base.in
# django-crum
# 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
14 changes: 9 additions & 5 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ appdirs==1.4.4
# via
# -r requirements/ci.txt
# virtualenv
asgiref==3.3.4
# via
# -r requirements/quality.txt
# django
astroid==2.5.6
# via
# -r requirements/quality.txt
Expand Down Expand Up @@ -82,17 +78,20 @@ distlib==0.3.2
# virtualenv
django-crum==0.7.9
# via -r requirements/quality.txt
django==3.2.4
django==2.2.24
# via
# -r requirements/quality.txt
# django-crum
# edx-lint
# 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
Expand Down Expand Up @@ -214,6 +213,10 @@ pylint==2.8.3
# 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
Expand Down Expand Up @@ -284,6 +287,7 @@ stevedore==3.3.0
# via
# -r requirements/quality.txt
# code-annotations
# edx-opaque-keys
text-unidecode==1.3
# via
# -r requirements/quality.txt
Expand Down
14 changes: 9 additions & 5 deletions requirements/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
#
alabaster==0.7.12
# via sphinx
asgiref==3.3.4
# via
# -r requirements/test.txt
# django
attrs==21.2.0
# via
# -r requirements/test.txt
Expand Down Expand Up @@ -38,10 +34,11 @@ ddt==1.4.2
# via -r requirements/test.txt
django-crum==0.7.9
# via -r requirements/test.txt
django==3.2.4
django==2.2.24
# via
# -r requirements/test.txt
# django-crum
# edx-opaque-keys
doc8==0.8.1
# via -r requirements/doc.in
docutils==0.17.1
Expand All @@ -50,6 +47,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
Expand Down Expand Up @@ -92,6 +91,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
Expand Down Expand Up @@ -157,6 +160,7 @@ stevedore==3.3.0
# -r requirements/test.txt
# code-annotations
# doc8
# edx-opaque-keys
text-unidecode==1.3
# via
# -r requirements/test.txt
Expand Down
14 changes: 9 additions & 5 deletions requirements/quality.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
#
# make upgrade
#
asgiref==3.3.4
# via
# -r requirements/test.txt
# django
astroid==2.5.6
# via
# pylint
Expand Down Expand Up @@ -48,15 +44,18 @@ ddt==1.4.2
# via -r requirements/test.txt
django-crum==0.7.9
# via -r requirements/test.txt
django==3.2.4
django==2.2.24
# via
# -r requirements/test.txt
# django-crum
# edx-lint
# 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.5.0
Expand Down Expand Up @@ -130,6 +129,10 @@ pylint==2.8.3
# 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
Expand Down Expand Up @@ -182,6 +185,7 @@ stevedore==3.3.0
# via
# -r requirements/test.txt
# code-annotations
# edx-opaque-keys
text-unidecode==1.3
# via
# -r requirements/test.txt
Expand Down
24 changes: 17 additions & 7 deletions requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
#
# make upgrade
#
asgiref==3.3.4
attrs==21.2.0
# via
# -r requirements/base.txt
# django
attrs==21.2.0
# via pytest
# pytest
click==8.0.1
# via code-annotations
code-annotations==1.1.2
Expand All @@ -20,10 +18,13 @@ ddt==1.4.2
# via -r requirements/test.in
django-crum==0.7.9
# via -r requirements/base.txt
django==3.2.4
django==2.2.24
# via
# -r requirements/base.txt
# django-crum
# edx-opaque-keys
edx-opaque-keys[django]==2.2.1
# via -r requirements/base.txt
iniconfig==1.1.1
# via pytest
jinja2==3.0.1
Expand All @@ -33,11 +34,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-cov==2.12.1
Expand All @@ -61,7 +68,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
Expand Down

0 comments on commit aa94458

Please sign in to comment.