File size: 965 Bytes
b7a7f32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from typing import TYPE_CHECKING

from sqlalchemy import Column, Integer, String, DateTime, ARRAY, ForeignKey
from sqlalchemy.orm import relationship
from sqlalchemy.sql.schema import UniqueConstraint
from sqlalchemy.sql.sqltypes import JSON


from core.db import Base


class AssignmentUpload(Base):
    id = Column(Integer, primary_key=True)

    submission_date = Column(DateTime, nullable=True)
    marks_obtained = Column(Integer, nullable=True)
    files = Column(ARRAY(JSON), nullable=True)

    assignment_id = Column(Integer, ForeignKey("assignment.id", ondelete="cascade"))
    assignment = relationship("Assignment", backref="assignment_upload")

    student_id = Column(Integer, ForeignKey("user.id", ondelete="cascade"))
    student = relationship("User", backref="assignment_upload")
    __table_args__ = (
        UniqueConstraint("assignment_id", "student_id", name="__student_assignment_uc"),
    )

    __tablename__ = "assignment_upload"  # noqa