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

Commit

Permalink
verwijderen code duplicatie #45
Browse files Browse the repository at this point in the history
  • Loading branch information
lbarraga committed Mar 7, 2024
1 parent 5ebf484 commit c9d1fea
Showing 1 changed file with 0 additions and 15 deletions.
15 changes: 0 additions & 15 deletions backend/domain/logic/subject.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,7 @@
from db.errors.database_errors import ActionAlreadyPerformedError
from db.models.models import Student, Subject, Teacher
from domain.logic.basic_operations import get, get_all
from domain.logic.student import is_user_student
from domain.logic.teacher import is_user_teacher
from domain.models.SubjectDataclass import SubjectDataclass
from domain.models.UserDataclass import UserDataclass


def is_user_authorized_for_subject(session: Session, subject: SubjectDataclass, user: UserDataclass) -> bool:
if is_user_teacher(session, user.id):
subjects_of_teacher: list[SubjectDataclass] = get_subjects_of_teacher(session, subject.id)
return subject in subjects_of_teacher

if is_user_student(session, user.id):
subjects_of_student: list[SubjectDataclass] = get_subjects_of_student(session, subject.id)
return subject in subjects_of_student

return False


def create_subject(session: Session, name: str) -> SubjectDataclass:
Expand Down

0 comments on commit c9d1fea

Please sign in to comment.