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 Jul 8, 2021
1 parent 7ca8286 commit b5882fa
Show file tree
Hide file tree
Showing 7 changed files with 133 additions and 3 deletions.
84 changes: 84 additions & 0 deletions openedx_events/learning/data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
"""
Data attributes for events within the architecture subdomain `learning`.
These attributes follow the form of attr objects specified in OEP-49 data
pattern.
"""
from datetime import datetime
from typing import Dict

import attr
from opaque_keys.edx.keys import CourseKey


@attr.s(frozen=True)
class StudentData:
"""
Attributes defined for Open edX student object.
"""

username = attr.ib(type=str)
email = attr.ib(type=str)
is_active = attr.ib(type=bool, default=True)
meta = attr.ib(type=Dict[str, str], factory=dict)
name = attr.ib(type=str, factory=str)


@attr.s(frozen=True)
class RegistrationFormData:
"""
Attributes defined for Open edX student object.
"""

account_form = attr.ib(type=Dict[str, str], factory=dict)
extension_form = attr.ib(type=Dict[str, str], factory=dict)


@attr.s(frozen=True)
class CourseData:
"""
Attributes defined for Open edX Course Overview object.
"""

course_key = attr.ib(type=CourseKey)
display_name = attr.ib(type=str, factory=str)
start = attr.ib(type=datetime, default=None)
end = attr.ib(type=datetime, default=None)


@attr.s(frozen=True)
class CourseEnrollmentData:
"""
Attributes defined for Open edX Course Enrollment object.
"""

user = attr.ib(type=StudentData)
course = attr.ib(type=CourseData)
mode = attr.ib(type=str)
is_active = attr.ib(type=bool)


@attr.s(frozen=True)
class CertificateData:
"""
Attributes defined for Open edX Certificate data object.
"""

user = attr.ib(type=StudentData)
course = attr.ib(type=CourseData)
mode = attr.ib(type=str)
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=CourseData)
name = attr.ib(type=str)
2 changes: 2 additions & 0 deletions requirements/base.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Core requirements for using this application
-c constraints.txt

attrs
django
edx-opaque-keys[django]
10 changes: 10 additions & 0 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,21 @@
#
# make upgrade
#
attrs==21.2.0
# via -r requirements/base.in
django==2.2.24
# via
# -c requirements/constraints.txt
# -r requirements/base.in
edx-opaque-keys[django]==2.2.2
# 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
7 changes: 7 additions & 0 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ docutils==0.17.1
# readme-renderer
edx-lint==5.0.0
# via -r requirements/quality.txt
edx-opaque-keys[django]==2.2.2
# via -r requirements/quality.txt
filelock==3.0.12
# via
# -r requirements/ci.txt
Expand Down Expand Up @@ -208,6 +210,10 @@ pylint-plugin-utils==0.6
# -r requirements/quality.txt
# pylint-celery
# pylint-django
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 @@ -278,6 +284,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
7 changes: 7 additions & 0 deletions requirements/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ docutils==0.17.1
# readme-renderer
# restructuredtext-lint
# sphinx
edx-opaque-keys[django]==2.2.2
# via -r requirements/test.txt
edx-sphinx-theme==3.0.0
# via -r requirements/doc.in
idna==2.10
Expand Down Expand Up @@ -86,6 +88,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 @@ -151,6 +157,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
7 changes: 7 additions & 0 deletions requirements/quality.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ docutils==0.17.1
# via readme-renderer
edx-lint==5.0.0
# via -r requirements/quality.in
edx-opaque-keys[django]==2.2.2
# via -r requirements/test.txt
idna==2.10
# via requests
importlib-metadata==4.6.1
Expand Down Expand Up @@ -124,6 +126,10 @@ pylint-plugin-utils==0.6
# via
# pylint-celery
# pylint-django
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 @@ -176,6 +182,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
19 changes: 16 additions & 3 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 @@ -18,6 +20,8 @@ django==2.2.24
# -r requirements/base.txt
ddt==1.4.2
# via -r requirements/test.in
edx-opaque-keys[django]==2.2.2
# via -r requirements/base.txt
iniconfig==1.1.1
# via pytest
jinja2==3.0.1
Expand All @@ -27,11 +31,17 @@ markupsafe==2.0.1
packaging==21.0
# 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 @@ -55,7 +65,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 b5882fa

Please sign in to comment.