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

Commit

Permalink
Add description field to projects
Browse files Browse the repository at this point in the history
  • Loading branch information
msathieu committed Mar 1, 2024
1 parent cd23feb commit 29c48fa
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 11 deletions.
26 changes: 21 additions & 5 deletions backend/db/implementation/SqlProjectDAO.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,33 @@ class SqlProjectDAO(SqlAbstractDAO[Project, ProjectDataclass], ProjectDAO):
def __init__(self) -> None:
self.model_class = Project

def create_project(self, subject_id: int, name: str, deadline: datetime, archived: bool, requirements: str,
visible: bool, max_students: int) -> ProjectDataclass:
def create_project(
self,
subject_id: int,
name: str,
deadline: datetime,
archived: bool,
description: str,
requirements: str,
visible: bool,
max_students: int,
) -> ProjectDataclass:
with Session(engine) as session:
subject: Subject | None = session.get(Subject, subject_id)
if not subject:
msg = f"Subject with id {subject_id} not found"
raise ItemNotFoundError(msg)

new_project: Project = Project(subject_id=subject_id, name=name, deadline=deadline,
archived=archived, requirements=requirements, visible=visible,
max_students=max_students)
new_project: Project = Project(
subject_id=subject_id,
name=name,
deadline=deadline,
archived=archived,
description=description,
requirements=requirements,
visible=visible,
max_students=max_students,
)

session.add(new_project)
session.commit()
Expand Down
19 changes: 14 additions & 5 deletions backend/db/interface/ProjectDAO.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,25 @@


class ProjectDAO(AbstractDAO[Project, ProjectDataclass]):

@abstractmethod
def create_project(self, subject_id: int, name: str, deadline: datetime, archived: bool, requirements: str,
visible: bool, max_students: int) -> ProjectDataclass:
def create_project(
self,
subject_id: int,
name: str,
deadline: datetime,
archived: bool,
description: str,
requirements: str,
visible: bool,
max_students: int,
) -> ProjectDataclass:
"""
Creëert een nieuw ProjectDataClass in de database en associeert het met een SubjectDataClass.
:param max_students: maximaal aantal studenten per groep per project
:param visible: of het project zichtbaar is voor de studenten
:param requirements: Uitleg van het project
:param visible: of het project zichtbaar is voor de studentent
:param description: Beschrijving van het project
:param requirements: Vereisten van het project
:param archived: Of het project gearchiveerd is
:param name: De naam van het project
:param deadline: De deadline van het project
Expand Down
3 changes: 3 additions & 0 deletions backend/db/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

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


@dataclass()
class AbstractModel(Generic[D]):
@abstractmethod
Expand Down Expand Up @@ -107,6 +108,7 @@ class Project(Base, AbstractModel):
name: Mapped[str]
deadline: Mapped[datetime]
archived: Mapped[bool]
description: Mapped[str]
requirements: Mapped[str]
visible: Mapped[bool]
max_students: Mapped[int]
Expand All @@ -121,6 +123,7 @@ def to_domain_model(self) -> ProjectDataclass:
name=self.name,
deadline=self.deadline,
archived=self.archived,
description=self.description,
requirements=self.requirements,
visible=self.visible,
max_students=self.max_students,
Expand Down
1 change: 1 addition & 0 deletions backend/domain/models/ProjectDataclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class ProjectDataclass(JsonRepresentable):
name: str
deadline: datetime
archived: bool
description: str
requirements: str
visible: bool
max_students: int
Expand Down
3 changes: 2 additions & 1 deletion backend/fill_database_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
name="PROJECT",
archived=False,
visible=True,
requirements="Maak iets in javafx",
description="Maak iets in javafx",
requirements="Een zip bestand met java-code",
max_students=2,
deadline=datetime(2000, 1, 1, 0, 0, 0, tzinfo=tz.LOCAL),
)
Expand Down

0 comments on commit 29c48fa

Please sign in to comment.