-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: convert classes to dataclasses in types module
- Loading branch information
Showing
9 changed files
with
180 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
import dataclasses | ||
|
||
|
||
@dataclasses.dataclass | ||
class ActionPayload: | ||
""" | ||
Class represents action payload API entity | ||
:param can_apply_for_distance: | ||
:param can_print: | ||
:param can_add_homework: | ||
""" | ||
def __init__(self, can_apply_for_distance: bool = True, can_print=None, | ||
can_add_homework: bool = True): | ||
self.can_apply_for_distance = can_apply_for_distance | ||
self.can_print = can_print | ||
self.can_add_homework = can_add_homework | ||
can_apply_for_distance: bool = True | ||
can_print: bool = True | ||
can_add_homework: bool = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,39 @@ | ||
class Education: | ||
def __init__(self, push_subscribe: bool, education_id: int, group_id: int, group_name: str, | ||
institution_id: int, institution_name: str, jurisdiction_id: int, jurisdiction_name: str, is_active, | ||
distance_education: bool, distance_education_updated_at: str, parent_firstname: str, | ||
parent_surname: str, parent_middlename: str, parent_email: str): | ||
""" | ||
Class represent API education class | ||
:param push_subscribe: | ||
:param education_id: | ||
:param group_id: | ||
:param group_name: | ||
:param institution_id: | ||
:param institution_name: | ||
:param jurisdiction_id: | ||
:param jurisdiction_name: | ||
:param is_active: | ||
:param distance_education: | ||
:param distance_education_updated_at: | ||
:param parent_firstname: | ||
:param parent_surname: | ||
:param parent_middlename: | ||
:param parent_email: | ||
""" | ||
self.parent_email = parent_email | ||
self.parent_middlename = parent_middlename | ||
self.parent_surname = parent_surname | ||
self.parent_firstname = parent_firstname | ||
self.distance_education_updated_at = distance_education_updated_at | ||
self.distance_education = distance_education | ||
self.is_active = is_active | ||
self.jurisdiction_name = jurisdiction_name | ||
self.jurisdiction_id = jurisdiction_id | ||
self.institution_name = institution_name | ||
self.institution_id = institution_id | ||
self.group_name = group_name | ||
self.group_id = group_id | ||
self.education_id = education_id | ||
self.push_subscribe = push_subscribe | ||
import dataclasses | ||
from typing import Any | ||
|
||
|
||
@dataclasses.dataclass | ||
class Education: | ||
""" | ||
Class represent API education class | ||
:param push_subscribe: | ||
:param education_id: | ||
:param group_id: | ||
:param group_name: | ||
:param institution_id: | ||
:param institution_name: | ||
:param jurisdiction_id: | ||
:param jurisdiction_name: | ||
:param is_active: | ||
:param distance_education: | ||
:param distance_education_updated_at: | ||
:param parent_firstname: | ||
:param parent_surname: | ||
:param parent_middlename: | ||
:param parent_email: | ||
""" | ||
push_subscribe: bool | ||
education_id: int | ||
group_id: int | ||
group_name: str | ||
institution_id: int | ||
institution_name: str | ||
jurisdiction_id: int | ||
jurisdiction_name: str | ||
is_active: Any | ||
distance_education: bool | ||
distance_education_updated_at: str | ||
parent_firstname: str | ||
parent_surname: str | ||
parent_middlename: str | ||
parent_email: str |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,19 @@ | ||
import dataclasses | ||
from typing import Any | ||
|
||
|
||
@dataclasses.dataclass | ||
class Estimate: | ||
def __init__(self, estimate_type_code: str, estimate_type_name: str, | ||
estimate_value_code: str, estimate_value_name: str, estimate_comment): | ||
""" | ||
Class represents estimate API entity | ||
:param estimate_type_code: | ||
:param estimate_type_name: | ||
:param estimate_value_code: | ||
:param estimate_value_name: | ||
:param estimate_comment: | ||
""" | ||
self.estimate_type_code = estimate_type_code | ||
self.estimate_type_name = estimate_type_name | ||
self.estimate_value_code = estimate_value_code | ||
self.estimate_value_name = estimate_value_name | ||
self.estimate_comment = estimate_comment | ||
""" | ||
Class represents estimate API entity | ||
:param estimate_type_code: | ||
:param estimate_type_name: | ||
:param estimate_value_code: | ||
:param estimate_value_name: | ||
:param estimate_comment: | ||
""" | ||
estimate_type_code: str | ||
estimate_type_name: str | ||
estimate_value_code: str | ||
estimate_value_name: str | ||
estimate_comment: Any |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
import dataclasses | ||
|
||
|
||
@dataclasses.dataclass | ||
class Identity: | ||
def __init__(self, id: int, uid: str = None): | ||
""" | ||
Class for implement identity parameter in API | ||
:param id: identity id | ||
:param uid: identity uid | ||
""" | ||
self.id = id | ||
self.uid = uid | ||
""" | ||
Class for implement identity parameter in API | ||
:param id: identity id | ||
:param uid: identity uid | ||
""" | ||
id: int | ||
uid: str = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,39 @@ | ||
import dataclasses | ||
import datetime | ||
from typing import Any | ||
|
||
from petersbugredu_wrap.types.action_payload import ActionPayload | ||
from petersbugredu_wrap.types.estimate import Estimate | ||
from petersbugredu_wrap.types.identity import Identity | ||
from petersbugredu_wrap.types.task import Task | ||
|
||
|
||
@dataclasses.dataclass | ||
class LessonEntry: | ||
def __init__(self, identity: Identity, number: int, datetime_from: datetime.datetime, | ||
datetime_to: datetime.datetime, subject_id: int,subject_name: str, content_name: str, | ||
content_description, content_additional_material, tasks: list[Task], estimates: list[Estimate], | ||
action_payload: ActionPayload): | ||
""" | ||
Class represents lesson entry in API | ||
:param identity: | ||
:param number: | ||
:param datetime_from: | ||
:param datetime_to: | ||
:param subject_id: | ||
:param subject_name: | ||
:param content_name: | ||
:param content_description: | ||
:param content_additional_material: | ||
:param tasks: | ||
:param estimates: | ||
:param action_payload: | ||
""" | ||
|
||
self.action_payload = action_payload | ||
self.estimates = estimates | ||
self.tasks = tasks | ||
self.content_additional_material = content_additional_material | ||
self.content_description = content_description | ||
self.content_name = content_name | ||
self.subject_name = subject_name | ||
self.subject_id = subject_id | ||
self.datetime_to = datetime_to | ||
self.datetime_from = datetime_from | ||
self.number = number | ||
self.identity = identity | ||
""" | ||
Class represents lesson entry in API | ||
:param identity: | ||
:param number: | ||
:param datetime_from: | ||
:param datetime_to: | ||
:param subject_id: | ||
:param subject_name: | ||
:param content_name: | ||
:param content_description: | ||
:param content_additional_material: | ||
:param tasks: | ||
:param estimates: | ||
:param action_payload: | ||
""" | ||
identity: Identity | ||
number: int | ||
datetime_from: datetime.datetime | ||
datetime_to: datetime.datetime | ||
subject_id: int | ||
subject_name: str | ||
content_name: str | ||
content_description: Any | ||
content_additional_material: Any | ||
tasks: list[Task] | ||
estimates: list[Estimate] | ||
action_payload: ActionPayload |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,31 @@ | ||
import dataclasses | ||
import datetime | ||
|
||
|
||
@dataclasses.dataclass | ||
class MarkEntry: | ||
def __init__(self, id: int, education_id: int, lesson_id: int, subject_id: int, | ||
subject_name: str, date: datetime.datetime,estimate_value_code: str, estimate_value_name: str, | ||
estimate_type_code: str, estimate_type_name: str, estimate_comment: str): | ||
""" | ||
Class represents mark entry in API | ||
:param id: | ||
:param education_id: | ||
:param lesson_id: | ||
:param subject_id: | ||
:param subject_name: | ||
:param date: | ||
:param estimate_value_code: | ||
:param estimate_value_name: | ||
:param estimate_type_code: | ||
:param estimate_type_name: | ||
:param estimate_comment: | ||
""" | ||
self.estimate_type_name = estimate_type_name | ||
self.estimate_type_code = estimate_type_code | ||
self.estimate_comment = estimate_comment | ||
self.estimate_value_name = estimate_value_name | ||
self.estimate_value_code = estimate_value_code | ||
self.date = date | ||
self.subject_name = subject_name | ||
self.subject_id = subject_id | ||
self.lesson_id = lesson_id | ||
self.id = id | ||
self.education_id = education_id | ||
""" | ||
Class represents mark entry in API | ||
:param id: | ||
:param education_id: | ||
:param lesson_id: | ||
:param subject_id: | ||
:param subject_name: | ||
:param date: | ||
:param estimate_value_code: | ||
:param estimate_value_name: | ||
:param estimate_type_code: | ||
:param estimate_type_name: | ||
:param estimate_comment: | ||
""" | ||
id: int | ||
education_id: int | ||
lesson_id: int | ||
subject_id: int | ||
subject_name: str | ||
date: datetime.datetime | ||
estimate_value_code: str | ||
estimate_value_name: str | ||
estimate_type_code: str | ||
estimate_type_name: str | ||
estimate_comment: str |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,15 @@ | ||
class Subject: | ||
def __init__(self, id: int, name: str): | ||
self.name = name | ||
self.id = id | ||
import dataclasses | ||
|
||
|
||
@dataclasses.dataclass | ||
class Subject: #TODO Add functional to class | ||
""" | ||
Not implemented yet | ||
:param id: | ||
:param name: | ||
""" | ||
id: int | ||
name: str | ||
|
||
def __post_init__(self): | ||
raise NotImplementedError |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,19 @@ | ||
import dataclasses | ||
from typing import Any | ||
|
||
|
||
@dataclasses.dataclass | ||
class Task: | ||
def __init__(self, task_name: str, task_code, task_kind_code: str, task_kind_name: str, files: list): | ||
""" | ||
Class represents task in API | ||
:param task_name: | ||
:param task_code: | ||
:param task_kind_code: | ||
:param task_kind_name: | ||
:param files: | ||
""" | ||
self.files = files | ||
self.task_kind_name = task_kind_name | ||
self.task_kind_code = task_kind_code | ||
self.task_code = task_code | ||
self.task_name = task_name | ||
|
||
""" | ||
Class represents task in API | ||
:param task_name: | ||
:param task_code: | ||
:param task_kind_code: | ||
:param task_kind_name: | ||
:param files: | ||
""" | ||
task_name: str | ||
task_code: Any | ||
task_kind_code: str | ||
task_kind_name: str | ||
files: list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
import dataclasses | ||
|
||
|
||
@dataclasses.dataclass | ||
class Teacher: | ||
def __init__(self, firstname: str, surname: str, middlename: str, position_name: str, subjects: list[dict]): | ||
""" | ||
Class Teacher represents school teachers returned by API | ||
:param firstname: Teacher firstname | ||
:param surname: Teacher surname | ||
:param middlename: Teacher middlename | ||
:param position_name: Name of position where teacher is | ||
:param subjects: List of teacher's subjects | ||
""" | ||
self.firstname = firstname | ||
self.surname = surname | ||
self.middlename = middlename | ||
self.position_name = position_name | ||
self.subjects = subjects | ||
""" | ||
Class Teacher represents school teachers returned by API | ||
:param firstname: Teacher firstname | ||
:param surname: Teacher surname | ||
:param middlename: Teacher middlename | ||
:param position_name: Name of position where teacher is | ||
:param subjects: List of teacher's subjects | ||
""" | ||
firstname: str | ||
surname: str | ||
middlename: str | ||
position_name: str | ||
subjects: list[dict] |