Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

Commit

Permalink
Add domain models
Browse files Browse the repository at this point in the history
Closes #11
  • Loading branch information
msathieu committed Feb 24, 2024
1 parent e3e20af commit 28b6fcc
Showing 1 changed file with 56 additions and 5 deletions.
61 changes: 56 additions & 5 deletions backend/domain/models/models.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,74 @@
import dataclasses
from abc import ABC
from dataclasses import dataclass
from datetime import datetime


@dataclass()
class JsonRepresentable(ABC):

def to_dict(self) -> dict:
return dataclasses.asdict(self)


@dataclass()
class SubjectDataclass(JsonRepresentable):
class UserDataclass(JsonRepresentable):
id: int
name: str
teacher_id: int = None
id: int = None
email: str


@dataclass()
class AdminDataclass(JsonRepresentable):
id: int


@dataclass()
class TeacherDataclass(JsonRepresentable):
id: int
subject_ids: list[int] | None = None


@dataclass()
class StudentDataclass(JsonRepresentable):
id: int = -1
subject_ids: list[int] | None = None
group_ids: list[int] | None = None
submission_ids: list[int] | None = None


@dataclass()
class SubjectDataclass(JsonRepresentable):
name: str
id: int | None = None
teacher_ids: list[int] | None = None


@dataclass()
class ProjectDataclass(JsonRepresentable):
name: str
id: int = None
deadline: datetime
archived: bool
requirements: str
visible: bool
max_students: int
subject_id: int
id: int | None = None
groups: list[int] | None = None


@dataclass()
class GroupDataclass(JsonRepresentable):
project_id: int
id: int | None = None
student_ids: list[int] | None = None
submission_ids: list[int] | None = None


@dataclass()
class SubmissionDataclass(JsonRepresentable):
date_time: datetime
group_id: int
student_id: int
state: int
message: str
id: int | None = None

0 comments on commit 28b6fcc

Please sign in to comment.