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

Commit

Permalink
Merge pull request #34 from SELab-2/modellen_naar_pydantic
Browse files Browse the repository at this point in the history
Modellen naar pydantic
  • Loading branch information
msathieu authored Mar 2, 2024
2 parents 191f3f2 + f824037 commit 8c1832a
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 87 deletions.
4 changes: 2 additions & 2 deletions backend/db/implementation/SqlAbstractDAO.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from typing import Generic, TypeVar

from pydantic import BaseModel
from sqlalchemy import select
from sqlalchemy.orm import Session

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.

21 changes: 0 additions & 21 deletions backend/domain/validation/SubjectValidator.py

This file was deleted.

18 changes: 0 additions & 18 deletions backend/domain/validation/TeacherValidator.py

This file was deleted.

24 changes: 0 additions & 24 deletions backend/domain/validation/ValidationResult.py

This file was deleted.

2 changes: 2 additions & 0 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
annotated-types==0.6.0
anyio==4.3.0
click==8.1.7
dnspython==2.6.1
email_validator==2.1.1
fastapi==0.110.0
greenlet==3.0.3
h11==0.14.0
Expand Down

0 comments on commit 8c1832a

Please sign in to comment.