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 30, 2021
1 parent de25a1f commit c3f8b8a
Show file tree
Hide file tree
Showing 7 changed files with 162 additions and 11 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 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)
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]
13 changes: 12 additions & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
19 changes: 17 additions & 2 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
12 changes: 10 additions & 2 deletions requirements/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
18 changes: 16 additions & 2 deletions requirements/quality.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
22 changes: 18 additions & 4 deletions requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit c3f8b8a

Please sign in to comment.