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

Commit

Permalink
Domein modellen omzetten naar pydantic modellen #27
Browse files Browse the repository at this point in the history
  • Loading branch information
lbarraga committed Mar 1, 2024
1 parent 191f3f2 commit 45e6a88
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 24 deletions.
6 changes: 4 additions & 2 deletions backend/db/implementation/SqlAbstractDAO.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
from sqlalchemy import select
from sqlalchemy.orm import Session

from pydantic import BaseModel

from db.errors.database_errors import ItemNotFoundError
from db.extensions import engine
from db.models.models import AbstractModel
from domain.models.base_model import JsonRepresentable


T = TypeVar("T", bound=AbstractModel)
D = TypeVar("D", bound=JsonRepresentable)
D = TypeVar("D", bound=BaseModel)


class SqlAbstractDAO(Generic[T, D]):
Expand Down
4 changes: 2 additions & 2 deletions backend/db/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
from datetime import datetime
from typing import Generic, TypeVar

from pydantic import BaseModel
from sqlalchemy import Column, ForeignKey, Table
from sqlalchemy.orm import Mapped, mapped_column, relationship

from db.extensions import Base
from domain.models.AdminDataclass import AdminDataclass
from domain.models.base_model import JsonRepresentable
from domain.models.GroupDataclass import GroupDataclass
from domain.models.ProjectDataclass import ProjectDataclass
from domain.models.StudentDataclass import StudentDataclass
Expand All @@ -17,7 +17,7 @@
from domain.models.TeacherDataclass import TeacherDataclass
from domain.models.UserDataclass import UserDataclass

D = TypeVar("D", bound=JsonRepresentable)
D = TypeVar("D", bound=BaseModel)


@dataclass()
Expand Down
4 changes: 2 additions & 2 deletions backend/domain/models/GroupDataclass.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from dataclasses import dataclass

from domain.models.base_model import JsonRepresentable
from pydantic import BaseModel


@dataclass()
class GroupDataclass(JsonRepresentable):
class GroupDataclass(BaseModel):
id: int
project_id: int
6 changes: 3 additions & 3 deletions backend/domain/models/ProjectDataclass.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
from dataclasses import dataclass
from datetime import datetime

from domain.models.base_model import JsonRepresentable
from pydantic import BaseModel, PositiveInt


@dataclass()
class ProjectDataclass(JsonRepresentable):
class ProjectDataclass(BaseModel):
id: int
name: str
deadline: datetime
archived: bool
description: str
requirements: str
visible: bool
max_students: int
max_students: PositiveInt
subject_id: int
4 changes: 2 additions & 2 deletions backend/domain/models/SubjectDataclass.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from dataclasses import dataclass

from domain.models.base_model import JsonRepresentable
from pydantic import BaseModel


@dataclass()
class SubjectDataclass(JsonRepresentable):
class SubjectDataclass(BaseModel):
id: int
name: str
4 changes: 2 additions & 2 deletions backend/domain/models/SubmissionDataclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from dataclasses import dataclass
from datetime import datetime

from domain.models.base_model import JsonRepresentable
from pydantic import BaseModel


class SubmissionState(enum.Enum):
Expand All @@ -12,7 +12,7 @@ class SubmissionState(enum.Enum):


@dataclass()
class SubmissionDataclass(JsonRepresentable):
class SubmissionDataclass(BaseModel):
id: int
date_time: datetime
group_id: int
Expand Down
6 changes: 3 additions & 3 deletions backend/domain/models/UserDataclass.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from dataclasses import dataclass

from domain.models.base_model import JsonRepresentable
from pydantic import BaseModel, EmailStr


@dataclass()
class UserDataclass(JsonRepresentable):
class UserDataclass(BaseModel):
id: int
name: str
email: str
email: EmailStr
8 changes: 0 additions & 8 deletions backend/domain/models/base_model.py

This file was deleted.

0 comments on commit 45e6a88

Please sign in to comment.