Skip to content

Commit

Permalink
style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DRIESASTER committed Mar 12, 2024
1 parent e5b4010 commit 009962a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
6 changes: 3 additions & 3 deletions backend/src/project/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
from src.subject.schemas import SubjectList


from . import service
from ..auth.exceptions import NotAuthorized
from ..subject.service import get_subjects, get_teachers


async def retrieve_subjects(
user: User = Depends(get_authenticated_user), db: Session = Depends(get_db)
) -> SubjectList:
teacher_subjects, student_subjects = await service.get_subjects(db, user.uid)
teacher_subjects, student_subjects = await get_subjects(db, user.uid)
return SubjectList(as_teacher=teacher_subjects, as_student=student_subjects)


Expand All @@ -24,6 +24,6 @@ async def user_permission_validation(
db: Session = Depends(get_db),
):
if not user.is_admin:
teachers = await service.get_teachers(db, subject_id)
teachers = await get_teachers(db, subject_id)
if not list(filter(lambda teacher: teacher.id == user.uid, teachers)):
raise NotAuthorized()
22 changes: 10 additions & 12 deletions backend/src/project/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,26 @@
from typing import Optional

from pydantic import BaseModel
from sqlalchemy import Column, BigInteger, String, Date, ForeignKey, CheckConstraint
from sqlalchemy import Column, BigInteger, String, Date, ForeignKey, CheckConstraint, Integer
from sqlalchemy.orm import relationship, Mapped
from src.database import Base

from backend.src.subject.models import Subject
f


class Project(Base):
__tablename__ = 'project'

id = Column(Integer, primary_key=True) # type: Mapped[int]
deadline = Column(Date, nullable=False) # type: Mapped[date]
name = Column(String, nullable=False) # type: Mapped[str]
subject_id = Column(Integer, ForeignKey('subject.id'),
nullable=True) # type: Mapped[int]
description = Column(String, nullable=True) # type: Mapped[str]
subject = relationship("Subject") # type: Mapped[Subject]
enroll_deadline: Mapped[date] = Column(
Date, nullable=True) # type: Mapped[date]
id = Column(BigInteger, primary_key=True)
deadline = Column(Date, nullable=False)
name = Column(String, nullable=False)
subject_id = Column(BigInteger, ForeignKey('subject.id'), nullable=True)
description = Column(String, nullable=True)
subject = relationship("Subject")
enroll_deadline: Mapped[date] = Column(Date, nullable=True)

# Relationships
subject = relationship("Subject") # type: Mapped[Subject]
subject = relationship("Subject")

__table_args__ = (
CheckConstraint('deadline >= CURRENT_DATE', name='deadline_check'),
Expand Down

0 comments on commit 009962a

Please sign in to comment.