From f8c487892c668212c4d2a7797c83d0f57e6bed68 Mon Sep 17 00:00:00 2001 From: Ruben Vandamme Date: Thu, 14 Mar 2024 10:32:32 +0100 Subject: [PATCH 01/10] code annotations db --- backend/db/extensions.py | 28 +++++++++++++++++++++++----- backend/db/models/models.py | 13 ++++++++++++- 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/backend/db/extensions.py b/backend/db/extensions.py index 137d3c8a..24186942 100644 --- a/backend/db/extensions.py +++ b/backend/db/extensions.py @@ -3,15 +3,33 @@ from sqlalchemy import create_engine from sqlalchemy.orm import DeclarativeBase -db_host = os.getenv("DB_HOST", "localhost") -db_port = os.getenv("DB_PORT", "5432") -db_user = os.getenv("DB_USERNAME", "postgres") -db_password = os.getenv("DB_PASSWORD", "postgres") -db_database = os.getenv("DB_DATABASE", "delphi") +""" +Retrieve the variables needed for a connection to the database. +We use environment variables for the code to be more adaptable across different environments. +The second variable in os.getenv specifies the default value. +""" +# where the database is hosted +db_host = os.getenv("DB_HOST", "localhost") +# port number on which the database server is listening +db_port = os.getenv("DB_PORT", "5432") +# username for the database +db_user = os.getenv("DB_USERNAME", "postgres") +# password for the user +db_password = os.getenv("DB_PASSWORD", "postgres") +# name of the database +db_database = os.getenv("DB_DATABASE", "delphi") +# dialect+driver://username:password@host:port/database DB_URI = f"postgresql://{db_user}:{db_password}@{db_host}:{db_port}/{db_database}" + +# The engine manages database-operations. +# There is only one instance of the engine, specified here. engine = create_engine(DB_URI) class Base(DeclarativeBase): + """ + This class is meant to be inherited from to define the database tables, see [db/models/models.py]. + For usage, please check https://docs.sqlalchemy.org/en/13/orm/extensions/declarative/basic_use.html. + """ pass diff --git a/backend/db/models/models.py b/backend/db/models/models.py index ba540dd1..42f9f6bd 100644 --- a/backend/db/models/models.py +++ b/backend/db/models/models.py @@ -1,5 +1,5 @@ from abc import abstractmethod -from dataclasses import dataclass +from dataclasses import dataclass # automatically add special methods as __init__() and __repr__() from datetime import datetime from typing import Generic, TypeVar @@ -17,15 +17,26 @@ from domain.models.TeacherDataclass import TeacherDataclass from domain.models.UserDataclass import UserDataclass +# Create a generic type variable bound to subclasses of BaseModel. D = TypeVar("D", bound=BaseModel) @dataclass() class AbstractModel(Generic[D]): + """ + This class is meant to be inherited by the python classes for the database tables. + It makes sure that every child implements the to_domain_model function + and receives Pydantic data validation. + """ @abstractmethod def to_domain_model(self) -> D: + """ + Change to an actual easy-to-use dataclass defined in [domain/models/*]. + This prevents working with instances of SQLAlchemy's Base class. + """ pass +# See the EER diagram for a more visual representation. @dataclass() class User(Base, AbstractModel): From ef765464f228003fd3ae517b6a3dc2c9c7880f54 Mon Sep 17 00:00:00 2001 From: Ruben Vandamme Date: Thu, 14 Mar 2024 10:46:52 +0100 Subject: [PATCH 02/10] code annotations db --- backend/db/errors/database_errors.py | 10 ++++++++++ backend/db/sessions.py | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/backend/db/errors/database_errors.py b/backend/db/errors/database_errors.py index 05a400e7..45704809 100644 --- a/backend/db/errors/database_errors.py +++ b/backend/db/errors/database_errors.py @@ -1,13 +1,23 @@ class ItemNotFoundError(Exception): + """ + The specified item was not found in the database. + """ def __init__(self, message: str) -> None: super().__init__(message) class ActionAlreadyPerformedError(Exception): + """ + The specified action was already performed on the database once before + and may not be performed again as to keep consistency. + """ def __init__(self, message: str) -> None: super().__init__(message) class NoSuchRelationError(Exception): + """ + There is no relation between the two specified elements in the database. + """ def __init__(self, message: str) -> None: super().__init__(message) diff --git a/backend/db/sessions.py b/backend/db/sessions.py index da201a92..fdfda192 100644 --- a/backend/db/sessions.py +++ b/backend/db/sessions.py @@ -4,10 +4,15 @@ from db.extensions import engine +# Generator for db sessions. Check the [documentation.md] for the use of sessions. SessionLocal: sessionmaker[Session] = sessionmaker(autocommit=False, autoflush=False, bind=engine) def get_session() -> Generator[Session, None, None]: + """ + Returns a generator for session objects. + To be used as dependency injection. + """ db = SessionLocal() try: yield db From 6c2a871c0e47310a6cd971d9cc1987fdcbb770f6 Mon Sep 17 00:00:00 2001 From: Ruben Vandamme Date: Thu, 14 Mar 2024 11:16:05 +0100 Subject: [PATCH 03/10] code annotations domain --- backend/domain/logic/basic_operations.py | 8 ++++++++ backend/domain/logic/group.py | 5 ++++- backend/domain/logic/project.py | 3 +++ backend/domain/logic/submission.py | 3 +++ backend/domain/logic/user.py | 3 +++ backend/domain/models/APIUser.py | 3 +++ backend/domain/models/UserDataclass.py | 4 ++++ 7 files changed, 28 insertions(+), 1 deletion(-) diff --git a/backend/domain/logic/basic_operations.py b/backend/domain/logic/basic_operations.py index 94fb15e3..c9a1c63e 100644 --- a/backend/domain/logic/basic_operations.py +++ b/backend/domain/logic/basic_operations.py @@ -6,10 +6,15 @@ from db.errors.database_errors import ItemNotFoundError from db.models.models import AbstractModel +# Create a generic type variable bound to subclasses of AbstractModel. T = TypeVar("T", bound=AbstractModel) def get(session: Session, object_type: type[T], ident: int) -> T: + """ + General function for retrieving a single object from the database. + The type of the object and its id as well a session object has to be provided. + """ generic_object: T | None = session.get(object_type, ident) if not generic_object: @@ -20,4 +25,7 @@ def get(session: Session, object_type: type[T], ident: int) -> T: def get_all(session: Session, object_type: type[T]) -> list[T]: + """ + General function for retrieving all objects of a certain type from the database. + """ return list(session.scalars(select(object_type)).all()) diff --git a/backend/domain/logic/group.py b/backend/domain/logic/group.py index eaab0039..53e049f3 100644 --- a/backend/domain/logic/group.py +++ b/backend/domain/logic/group.py @@ -8,6 +8,9 @@ def create_group(session: Session, project_id: int) -> GroupDataclass: + """ + Create an empty group for a certain project. + """ project: Project = get(session, Project, project_id) new_group: Group = Group(project_id=project_id) project.groups.append(new_group) @@ -34,7 +37,7 @@ def get_groups_of_project(session: Session, project_id: int) -> list[GroupDatacl def get_groups_of_student(session: Session, student_id: int) -> list[GroupDataclass]: student: Student = get(session, Student, ident=student_id) - groups: list[Group] = student.groups + groups: list[Group] = student.groupsget_groups_of_student return [group.to_domain_model() for group in groups] diff --git a/backend/domain/logic/project.py b/backend/domain/logic/project.py index 2e3b6967..91efcf89 100644 --- a/backend/domain/logic/project.py +++ b/backend/domain/logic/project.py @@ -18,6 +18,9 @@ def create_project( visible: bool, max_students: int, ) -> ProjectDataclass: + """ + Create a project for a certain subject. + """ subject: Subject = get(session, Subject, subject_id) new_project: Project = Project( diff --git a/backend/domain/logic/submission.py b/backend/domain/logic/submission.py index e4bb8318..63e02d9f 100644 --- a/backend/domain/logic/submission.py +++ b/backend/domain/logic/submission.py @@ -15,6 +15,9 @@ def create_submission( state: SubmissionState, date_time: datetime, ) -> SubmissionDataclass: + """ + Create a submission for a certain project by a certain group. + """ student: Student = get(session, Student, ident=student_id) group: Group = get(session, Group, ident=group_id) diff --git a/backend/domain/logic/user.py b/backend/domain/logic/user.py index b3f25f9b..1cb203a4 100644 --- a/backend/domain/logic/user.py +++ b/backend/domain/logic/user.py @@ -11,6 +11,9 @@ def convert_user(session: Session, user: UserDataclass) -> APIUser: + """ + Given a UserDataclass, check what roles that user has and fill those in to convert it to an APIUser. + """ api_user = APIUser(id=user.id, name=user.name, email=user.email, roles=[]) if is_user_teacher(session, user.id): diff --git a/backend/domain/models/APIUser.py b/backend/domain/models/APIUser.py index c37fb477..46477557 100644 --- a/backend/domain/models/APIUser.py +++ b/backend/domain/models/APIUser.py @@ -4,6 +4,9 @@ class APIUser(BaseModel): + """ + A user with that has is roles specified. + """ id: int name: str email: EmailStr diff --git a/backend/domain/models/UserDataclass.py b/backend/domain/models/UserDataclass.py index 33e94a5d..6e9e8e64 100644 --- a/backend/domain/models/UserDataclass.py +++ b/backend/domain/models/UserDataclass.py @@ -2,6 +2,10 @@ class UserDataclass(BaseModel): + """ + This user does not have any roles yet. + When the roles become specified, use the almost equivalent APIUser. + """ id: int name: str email: EmailStr From 0b27c44191d662104eae496edcc70fe17a296d7b Mon Sep 17 00:00:00 2001 From: Ruben Vandamme Date: Thu, 14 Mar 2024 11:24:31 +0100 Subject: [PATCH 04/10] code annotations other --- backend/documentation.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/backend/documentation.md b/backend/documentation.md index 8d2b6fc5..5dd488be 100644 --- a/backend/documentation.md +++ b/backend/documentation.md @@ -50,6 +50,8 @@ We use **FastAPI** as framework. FastAPI follows the OpenAPI Specification. Its Every route recieves a session object as a dependency injection, to forward to the corresponding logic operation. Dependencies are components that need to be executed before the route operation function is called. We let FastAPI handle this for us. Other than a database connection through the session object, we sometimes also inject some authentication/authorization logic (see [routes/dependencies/role_dependencies.py]) with corresponding errors in [routes/errors/authentication.py]. +For specific documentation about the API-endpoints, start the app and go to /docs. + ## 4) Running the app We start by defining app = FastAPI() in [app.py]. Next, we add our routers from the previous section. We also add some exception handlers using the corresponding tag. FastAPI calls these handlers for us if needed. this way, we only have to return a corresponding JSONResponse. Finally, we start the app using a **uvicorn** server. This is the standard for FastApi. "app:app" specifies the location of the FastApi object. The first "app" refers to the module (i.e., app.py), and the second "app" refers to the variable (i.e., the FastAPI application object). By default, Uvicorn will run on the localhost port 8000. Another thing to note in this file is that we provide [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) functionality in production. \ No newline at end of file From b05c15f031dfecee791d83cbeecd7f37808ebe2f Mon Sep 17 00:00:00 2001 From: Ruben Vandamme Date: Thu, 14 Mar 2024 11:46:09 +0100 Subject: [PATCH 05/10] ruff linting fixed --- backend/db/errors/database_errors.py | 2 +- backend/db/extensions.py | 21 ++++++++++----------- backend/db/models/models.py | 5 ++--- backend/domain/logic/basic_operations.py | 2 +- backend/domain/models/UserDataclass.py | 2 +- 5 files changed, 15 insertions(+), 17 deletions(-) diff --git a/backend/db/errors/database_errors.py b/backend/db/errors/database_errors.py index 45704809..4d0ced8e 100644 --- a/backend/db/errors/database_errors.py +++ b/backend/db/errors/database_errors.py @@ -8,7 +8,7 @@ def __init__(self, message: str) -> None: class ActionAlreadyPerformedError(Exception): """ - The specified action was already performed on the database once before + The specified action was already performed on the database once before and may not be performed again as to keep consistency. """ def __init__(self, message: str) -> None: diff --git a/backend/db/extensions.py b/backend/db/extensions.py index 24186942..1b4cb3f2 100644 --- a/backend/db/extensions.py +++ b/backend/db/extensions.py @@ -9,15 +9,15 @@ The second variable in os.getenv specifies the default value. """ # where the database is hosted -db_host = os.getenv("DB_HOST", "localhost") -# port number on which the database server is listening -db_port = os.getenv("DB_PORT", "5432") -# username for the database -db_user = os.getenv("DB_USERNAME", "postgres") -# password for the user -db_password = os.getenv("DB_PASSWORD", "postgres") -# name of the database -db_database = os.getenv("DB_DATABASE", "delphi") +db_host = os.getenv("DB_HOST", "localhost") +# port number on which the database server is listening +db_port = os.getenv("DB_PORT", "5432") +# username for the database +db_user = os.getenv("DB_USERNAME", "postgres") +# password for the user +db_password = os.getenv("DB_PASSWORD", "postgres") +# name of the database +db_database = os.getenv("DB_DATABASE", "delphi") # dialect+driver://username:password@host:port/database DB_URI = f"postgresql://{db_user}:{db_password}@{db_host}:{db_port}/{db_database}" @@ -29,7 +29,6 @@ class Base(DeclarativeBase): """ - This class is meant to be inherited from to define the database tables, see [db/models/models.py]. + This class is meant to be inherited from to define the database tables, see [db/models/models.py]. For usage, please check https://docs.sqlalchemy.org/en/13/orm/extensions/declarative/basic_use.html. """ - pass diff --git a/backend/db/models/models.py b/backend/db/models/models.py index 42f9f6bd..09010ea0 100644 --- a/backend/db/models/models.py +++ b/backend/db/models/models.py @@ -1,5 +1,5 @@ from abc import abstractmethod -from dataclasses import dataclass # automatically add special methods as __init__() and __repr__() +from dataclasses import dataclass # automatically add special methods as __init__() and __repr__() from datetime import datetime from typing import Generic, TypeVar @@ -25,7 +25,7 @@ class AbstractModel(Generic[D]): """ This class is meant to be inherited by the python classes for the database tables. - It makes sure that every child implements the to_domain_model function + It makes sure that every child implements the to_domain_model function and receives Pydantic data validation. """ @abstractmethod @@ -34,7 +34,6 @@ def to_domain_model(self) -> D: Change to an actual easy-to-use dataclass defined in [domain/models/*]. This prevents working with instances of SQLAlchemy's Base class. """ - pass # See the EER diagram for a more visual representation. diff --git a/backend/domain/logic/basic_operations.py b/backend/domain/logic/basic_operations.py index c9a1c63e..1e74d534 100644 --- a/backend/domain/logic/basic_operations.py +++ b/backend/domain/logic/basic_operations.py @@ -13,7 +13,7 @@ def get(session: Session, object_type: type[T], ident: int) -> T: """ General function for retrieving a single object from the database. - The type of the object and its id as well a session object has to be provided. + The type of the object and its id as well a session object has to be provided. """ generic_object: T | None = session.get(object_type, ident) diff --git a/backend/domain/models/UserDataclass.py b/backend/domain/models/UserDataclass.py index 6e9e8e64..167a56f1 100644 --- a/backend/domain/models/UserDataclass.py +++ b/backend/domain/models/UserDataclass.py @@ -3,7 +3,7 @@ class UserDataclass(BaseModel): """ - This user does not have any roles yet. + This user does not have any roles yet. When the roles become specified, use the almost equivalent APIUser. """ id: int From ce3abdc9543dc9a85e8cbe3be4e73396500ac5d6 Mon Sep 17 00:00:00 2001 From: Ruben Vandamme Date: Thu, 14 Mar 2024 11:53:40 +0100 Subject: [PATCH 06/10] small fix --- backend/domain/logic/group.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/domain/logic/group.py b/backend/domain/logic/group.py index 53e049f3..fff26c2c 100644 --- a/backend/domain/logic/group.py +++ b/backend/domain/logic/group.py @@ -37,7 +37,7 @@ def get_groups_of_project(session: Session, project_id: int) -> list[GroupDatacl def get_groups_of_student(session: Session, student_id: int) -> list[GroupDataclass]: student: Student = get(session, Student, ident=student_id) - groups: list[Group] = student.groupsget_groups_of_student + groups: list[Group] = student.groups return [group.to_domain_model() for group in groups] From efc3c547d6a9877b50e2e1ae76b983c4a7a5ffc6 Mon Sep 17 00:00:00 2001 From: Ruben Vandamme Date: Thu, 14 Mar 2024 12:01:56 +0100 Subject: [PATCH 07/10] update documentation.md --- backend/documentation.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/documentation.md b/backend/documentation.md index 5dd488be..9ad562fd 100644 --- a/backend/documentation.md +++ b/backend/documentation.md @@ -14,7 +14,7 @@ For test purposes, mockup data is available in [fill_database_mock.py]. A visual #### II) tables -Using our EER diagram, we now want to create the corresponding tables. We use SQLAlchemy's declarative base pattern. Start by defining a Base class. This class contains the necessary functionality to interact with the database. Next, we create a python class for each table we need, and make it inherit the Base class. We call this a model (see [db/models/models.py]). For specifics on how to define these models, see [this link](https://docs.sqlalchemy.org/en/13/orm/extensions/declarative/basic_use.html). +Using our EER diagram, we now want to create the corresponding tables. We use SQLAlchemy's declarative base pattern. Start by defining a Base class. This class contains the necessary functionality to interact with the database. Next, we create a python class for each table we need, and make it inherit the Base class. We call this a model (see [db/models/models.py]). For specifics on how to define these models, see [this link](https://docs.sqlalchemy.org/en/20/orm/declarative_styles.html#using-a-declarative-base-class). An important thing to notice in this file is that other than the Base class, all models also inherit a class named AbstractModel. It makes sure that each model implements *to_domain_model*. We will come back to this function later on. @@ -50,8 +50,8 @@ We use **FastAPI** as framework. FastAPI follows the OpenAPI Specification. Its Every route recieves a session object as a dependency injection, to forward to the corresponding logic operation. Dependencies are components that need to be executed before the route operation function is called. We let FastAPI handle this for us. Other than a database connection through the session object, we sometimes also inject some authentication/authorization logic (see [routes/dependencies/role_dependencies.py]) with corresponding errors in [routes/errors/authentication.py]. -For specific documentation about the API-endpoints, start the app and go to /docs. +For specific documentation about the API-endpoints, start the app and go to /api/docs. ## 4) Running the app -We start by defining app = FastAPI() in [app.py]. Next, we add our routers from the previous section. We also add some exception handlers using the corresponding tag. FastAPI calls these handlers for us if needed. this way, we only have to return a corresponding JSONResponse. Finally, we start the app using a **uvicorn** server. This is the standard for FastApi. "app:app" specifies the location of the FastApi object. The first "app" refers to the module (i.e., app.py), and the second "app" refers to the variable (i.e., the FastAPI application object). By default, Uvicorn will run on the localhost port 8000. Another thing to note in this file is that we provide [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) functionality in production. \ No newline at end of file +We start by defining app = FastAPI() in [app.py]. Next, we add our routers from the previous section. We also add some exception handlers using the corresponding tag. FastAPI calls these handlers for us if needed. this way, we only have to return a corresponding JSONResponse. Finally, we start the app using a **uvicorn** server. This is the standard for FastApi. "app:app" specifies the location of the FastApi object. The first "app" refers to the module (i.e., app.py), and the second "app" refers to the variable (i.e., the FastAPI application object). By default, Uvicorn will run on the localhost port 8000. Another thing to note in this file is that we provide [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) functionality for the local version only. \ No newline at end of file From 4a56559a0be88a73c7e9685904cf3ba4c923dbf3 Mon Sep 17 00:00:00 2001 From: Ruben Vandamme Date: Thu, 14 Mar 2024 12:23:08 +0100 Subject: [PATCH 08/10] verwerking onduidelijkheden --- backend/domain/logic/admin.py | 3 +++ backend/domain/logic/student.py | 3 +++ backend/domain/logic/teacher.py | 3 +++ 3 files changed, 9 insertions(+) diff --git a/backend/domain/logic/admin.py b/backend/domain/logic/admin.py index 8f5eb019..0a23c0d5 100644 --- a/backend/domain/logic/admin.py +++ b/backend/domain/logic/admin.py @@ -6,6 +6,9 @@ def create_admin(session: Session, name: str, email: str) -> AdminDataclass: + """ + This function is meant creating a new user that is an admin. It does not change the role of an existing user. + """ new_user: User = User(name=name, email=email) session.add(new_user) session.commit() diff --git a/backend/domain/logic/student.py b/backend/domain/logic/student.py index 4d161e10..20037ff4 100644 --- a/backend/domain/logic/student.py +++ b/backend/domain/logic/student.py @@ -6,6 +6,9 @@ def create_student(session: Session, name: str, email: str) -> StudentDataclass: + """ + This function is meant creating a new user that is a student. It does not change the role of an existing user. + """ new_user: User = User(name=name, email=email) session.add(new_user) session.commit() diff --git a/backend/domain/logic/teacher.py b/backend/domain/logic/teacher.py index 4f665646..6ea7275a 100644 --- a/backend/domain/logic/teacher.py +++ b/backend/domain/logic/teacher.py @@ -6,6 +6,9 @@ def create_teacher(session: Session, name: str, email: str) -> TeacherDataclass: + """ + This function is meant creating a new user that is a teacher. It does not change the role of an existing user. + """ new_user: User = User(name=name, email=email) session.add(new_user) session.commit() From cc0ff9334de5e2b742515c3b6818725738c91d8e Mon Sep 17 00:00:00 2001 From: Ruben Vandamme Date: Thu, 14 Mar 2024 12:28:13 +0100 Subject: [PATCH 09/10] verwijzing naar de README --- backend/documentation.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/backend/documentation.md b/backend/documentation.md index 9ad562fd..196a1158 100644 --- a/backend/documentation.md +++ b/backend/documentation.md @@ -4,9 +4,7 @@ #### I) setup -- step 1: Install and set up **PostgreSQL**. We refer to the [official documentation](https://www.postgresql.org/docs/16/admin.html). -- step 2: Start a PostgreSQL server. -- step 3: Create a database on this server. +Check the README.md for installation. We use **SQLAlchemy** to access this database in our backend app. SQLAlchemy allows us to start defining tables, performing queries, etc.. The setup of SQLAlchemy happens in [db/extensions.py]. Here, an SQLAlchemy engine is created. This engine is the component that manages connections to the database. A [database URI](https://docs.sqlalchemy.org/en/20/core/engines.html) is needed to create such an engine. Because we host the backend app and the database in the same place, we use localhost in the URI as default. This is not mandatory; the database and backend app are two seperate things. From 05dc471ff126852e39b2d7d5f7e1202c79793d21 Mon Sep 17 00:00:00 2001 From: Ruben Vandamme Date: Thu, 14 Mar 2024 16:04:08 +0100 Subject: [PATCH 10/10] review changes --- backend/db/extensions.py | 2 +- backend/domain/logic/admin.py | 2 +- backend/domain/logic/student.py | 2 +- backend/domain/logic/teacher.py | 2 +- backend/domain/models/APIUser.py | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/db/extensions.py b/backend/db/extensions.py index 1b4cb3f2..c2714e9b 100644 --- a/backend/db/extensions.py +++ b/backend/db/extensions.py @@ -30,5 +30,5 @@ class Base(DeclarativeBase): """ This class is meant to be inherited from to define the database tables, see [db/models/models.py]. - For usage, please check https://docs.sqlalchemy.org/en/13/orm/extensions/declarative/basic_use.html. + For usage, please check https://docs.sqlalchemy.org/en/20/orm/declarative_styles.html#using-a-declarative-base-class. """ diff --git a/backend/domain/logic/admin.py b/backend/domain/logic/admin.py index 0a23c0d5..2a5d5418 100644 --- a/backend/domain/logic/admin.py +++ b/backend/domain/logic/admin.py @@ -7,7 +7,7 @@ def create_admin(session: Session, name: str, email: str) -> AdminDataclass: """ - This function is meant creating a new user that is an admin. It does not change the role of an existing user. + This function is meant to create a new user that is an admin. It does not change the role of an existing user. """ new_user: User = User(name=name, email=email) session.add(new_user) diff --git a/backend/domain/logic/student.py b/backend/domain/logic/student.py index 20037ff4..a42e1933 100644 --- a/backend/domain/logic/student.py +++ b/backend/domain/logic/student.py @@ -7,7 +7,7 @@ def create_student(session: Session, name: str, email: str) -> StudentDataclass: """ - This function is meant creating a new user that is a student. It does not change the role of an existing user. + This function is meant to create a new user that is a student. It does not change the role of an existing user. """ new_user: User = User(name=name, email=email) session.add(new_user) diff --git a/backend/domain/logic/teacher.py b/backend/domain/logic/teacher.py index 6ea7275a..01e2d81b 100644 --- a/backend/domain/logic/teacher.py +++ b/backend/domain/logic/teacher.py @@ -7,7 +7,7 @@ def create_teacher(session: Session, name: str, email: str) -> TeacherDataclass: """ - This function is meant creating a new user that is a teacher. It does not change the role of an existing user. + This function is meant to create a new user that is a teacher. It does not change the role of an existing user. """ new_user: User = User(name=name, email=email) session.add(new_user) diff --git a/backend/domain/models/APIUser.py b/backend/domain/models/APIUser.py index 46477557..bfd6e819 100644 --- a/backend/domain/models/APIUser.py +++ b/backend/domain/models/APIUser.py @@ -5,7 +5,7 @@ class APIUser(BaseModel): """ - A user with that has is roles specified. + Same as UserDataclass, but with the roles specified in a list. """ id: int name: str