создал новые таблицы
This commit is contained in:
parent
bd265c17fe
commit
44b2fa8d98
16
API/app/infrastructure/database/models/answer_files.py
Normal file
16
API/app/infrastructure/database/models/answer_files.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
from sqlalchemy import Column, Integer, String, ForeignKey
|
||||||
|
from sqlalchemy.orm import relationship
|
||||||
|
|
||||||
|
from app.infrastructure.database.models import Base
|
||||||
|
|
||||||
|
|
||||||
|
class AnswerFile(Base):
|
||||||
|
__tablename__ = 'answer_files'
|
||||||
|
|
||||||
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||||
|
file_path = Column(String, nullable=False)
|
||||||
|
file_title = Column(String, nullable=False)
|
||||||
|
|
||||||
|
answer_id = Column(Integer, ForeignKey('task_answers.id'), nullable=False)
|
||||||
|
|
||||||
|
answer = relationship('TaskAnswer', back_populates='files')
|
||||||
18
API/app/infrastructure/database/models/answer_options.py
Normal file
18
API/app/infrastructure/database/models/answer_options.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
from sqlalchemy import Column, Integer, String, Boolean, ForeignKey
|
||||||
|
from sqlalchemy.orm import relationship
|
||||||
|
|
||||||
|
from app.infrastructure.database.models import Base
|
||||||
|
|
||||||
|
|
||||||
|
class AnswerOption(Base):
|
||||||
|
__tablename__ = 'answer_options'
|
||||||
|
|
||||||
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||||
|
answer = Column(String, nullable=False)
|
||||||
|
is_current = Column(Boolean, nullable=False, default=False)
|
||||||
|
|
||||||
|
task_id = Column(Integer, ForeignKey('step_tasks.id'), nullable=False)
|
||||||
|
|
||||||
|
task = relationship('StepTask', back_populates='answer_options')
|
||||||
|
|
||||||
|
test_answers = relationship('TestAnswer', back_populates='answer')
|
||||||
@ -17,3 +17,5 @@ class StepTask(Base):
|
|||||||
type = relationship('TaskType', back_populates='tasks')
|
type = relationship('TaskType', back_populates='tasks')
|
||||||
|
|
||||||
files = relationship('TaskFile', back_populates='task')
|
files = relationship('TaskFile', back_populates='task')
|
||||||
|
answer_options = relationship('AnswerOption', back_populates='task')
|
||||||
|
answers = relationship('TaskAnswer', back_populates='task')
|
||||||
|
|||||||
23
API/app/infrastructure/database/models/task_answers.py
Normal file
23
API/app/infrastructure/database/models/task_answers.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
from sqlalchemy import Column, Integer, ForeignKey, DateTime, String, Boolean
|
||||||
|
from sqlalchemy.sql import func
|
||||||
|
from sqlalchemy.orm import relationship
|
||||||
|
|
||||||
|
from app.infrastructure.database.models import Base
|
||||||
|
|
||||||
|
|
||||||
|
class TaskAnswer(Base):
|
||||||
|
__tablename__ = 'task_answers'
|
||||||
|
|
||||||
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||||
|
answer_date = Column(DateTime, nullable=False, default=func.utcnow)
|
||||||
|
text = Column(String, nullable=False)
|
||||||
|
is_current = Column(Boolean, default=None)
|
||||||
|
comment = Column(String)
|
||||||
|
|
||||||
|
user_id = Column(Integer, ForeignKey('users.id'), nullable=False)
|
||||||
|
task_id = Column(Integer, ForeignKey('step_tasks.id'), nullable=False)
|
||||||
|
|
||||||
|
user = relationship('User', back_populates='task_answers')
|
||||||
|
task = relationship('StepTask', back_populates='answers')
|
||||||
|
|
||||||
|
files = relationship('AnswerFile', back_populates='answer')
|
||||||
18
API/app/infrastructure/database/models/test_answers.py
Normal file
18
API/app/infrastructure/database/models/test_answers.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
from sqlalchemy import Column, Integer, ForeignKey, DateTime
|
||||||
|
from sqlalchemy.sql import func
|
||||||
|
from sqlalchemy.orm import relationship
|
||||||
|
|
||||||
|
from app.infrastructure.database.models import Base
|
||||||
|
|
||||||
|
|
||||||
|
class TestAnswer(Base):
|
||||||
|
__tablename__ = 'test_answers'
|
||||||
|
|
||||||
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||||
|
answer_date = Column(DateTime, nullable=False, default=func.utcnow)
|
||||||
|
|
||||||
|
user_id = Column(Integer, ForeignKey('users.id'), nullable=False)
|
||||||
|
answer_id = Column(Integer, ForeignKey('answer_options.id'), nullable=False)
|
||||||
|
|
||||||
|
user = relationship('User', back_populates='test_answers')
|
||||||
|
answer = relationship('AnswerOption', back_populates='test_answers')
|
||||||
@ -33,9 +33,11 @@ class User(Base):
|
|||||||
role = relationship('Role', back_populates='users')
|
role = relationship('Role', back_populates='users')
|
||||||
|
|
||||||
appeals = relationship('Appeal', back_populates='user')
|
appeals = relationship('Appeal', back_populates='user')
|
||||||
owned_courses = relationship('Course', back_populates='owned_courses')
|
owned_courses = relationship('Course', back_populates='owner_user')
|
||||||
enrolled_courses = relationship('CourseStudent', back_populates='user')
|
enrolled_courses = relationship('CourseStudent', back_populates='user')
|
||||||
notifications = relationship('Notification', back_populates='user')
|
notifications = relationship('Notification', back_populates='user')
|
||||||
|
test_answers = relationship('TestAnswer', back_populates='user')
|
||||||
|
task_answers = relationship('TaskAnswer', back_populates='user')
|
||||||
|
|
||||||
def check_password(self, password):
|
def check_password(self, password):
|
||||||
return check_password_hash(self.password, password)
|
return check_password_hash(self.password, password)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user