From bd265c17fe0397f5ee249b7200aeaf30dbbd2e17 Mon Sep 17 00:00:00 2001 From: Andrei Duvakin Date: Sun, 26 Jan 2025 19:57:49 +0500 Subject: [PATCH] =?UTF-8?q?=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D0=BB=20=D0=BD?= =?UTF-8?q?=D0=BE=D0=B2=D1=8B=D0=B5=20=D1=82=D0=B0=D0=B1=D0=BB=D0=B8=D1=86?= =?UTF-8?q?=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../infrastructure/database/models/courses.py | 2 ++ .../database/models/lectures.py | 17 ++++++++++++++++ .../infrastructure/database/models/lessons.py | 18 +++++++++++++++++ .../database/models/step_tasks.py | 19 ++++++++++++++++++ .../database/models/step_types.py | 14 +++++++++++++ .../infrastructure/database/models/steps.py | 20 +++++++++++++++++++ .../database/models/task_files.py | 16 +++++++++++++++ .../database/models/task_types.py | 14 +++++++++++++ 8 files changed, 120 insertions(+) create mode 100644 API/app/infrastructure/database/models/lectures.py create mode 100644 API/app/infrastructure/database/models/lessons.py create mode 100644 API/app/infrastructure/database/models/step_tasks.py create mode 100644 API/app/infrastructure/database/models/step_types.py create mode 100644 API/app/infrastructure/database/models/steps.py create mode 100644 API/app/infrastructure/database/models/task_files.py create mode 100644 API/app/infrastructure/database/models/task_types.py diff --git a/API/app/infrastructure/database/models/courses.py b/API/app/infrastructure/database/models/courses.py index 4fcb2a3..9e54e4d 100644 --- a/API/app/infrastructure/database/models/courses.py +++ b/API/app/infrastructure/database/models/courses.py @@ -19,3 +19,5 @@ class Course(Base): students = relationship('CourseStudent', back_populates='course') notifications = relationship('Notification', back_populates='course') + + lessons = relationship('Lesson', back_populates='course') diff --git a/API/app/infrastructure/database/models/lectures.py b/API/app/infrastructure/database/models/lectures.py new file mode 100644 index 0000000..f8d9495 --- /dev/null +++ b/API/app/infrastructure/database/models/lectures.py @@ -0,0 +1,17 @@ +from sqlalchemy import Column, Integer, String, ForeignKey +from sqlalchemy.orm import relationship + +from app.infrastructure.database.models import Base + + +class Lectures(Base): + __tablename__ = 'lectures' + + id = Column(Integer, primary_key=True, autoincrement=True) + text = Column(String, nullable=False) + image = Column(String) + number = Column(Integer, nullable=False) + + step_id = Column(Integer, ForeignKey('steps.id'), nullable=False) + + step = relationship('Step', back_populates='lectures') diff --git a/API/app/infrastructure/database/models/lessons.py b/API/app/infrastructure/database/models/lessons.py new file mode 100644 index 0000000..9ecc5bb --- /dev/null +++ b/API/app/infrastructure/database/models/lessons.py @@ -0,0 +1,18 @@ +from sqlalchemy import Column, Integer, String, ForeignKey, VARCHAR +from sqlalchemy.orm import relationship + +from app.infrastructure.database.models import Base + + +class Lesson(Base): + __tablename__ = 'lessons' + + id = Column(Integer, primary_key=True, autoincrement=True) + title = Column(VARCHAR(200), nullable=False) + description = Column(String, nullable=False) + + course_id = Column(Integer, ForeignKey('courses.id'), nullable=False) + + course = relationship('Course', back_populates='lessons') + + steps = relationship('Step', back_populates='lesson') diff --git a/API/app/infrastructure/database/models/step_tasks.py b/API/app/infrastructure/database/models/step_tasks.py new file mode 100644 index 0000000..6f773dc --- /dev/null +++ b/API/app/infrastructure/database/models/step_tasks.py @@ -0,0 +1,19 @@ +from sqlalchemy import Column, Integer, String, ForeignKey +from sqlalchemy.orm import relationship + +from app.infrastructure.database.models import Base + + +class StepTask(Base): + __tablename__ = 'step_tasks' + + id = Column(Integer, primary_key=True, autoincrement=True) + text = Column(String, nullable=False) + + step_id = Column(Integer, ForeignKey('steps.id'), nullable=False) + type_id = Column(Integer, ForeignKey('task_types.id'), nullable=False) + + step = relationship('Step', back_populates='tasks') + type = relationship('TaskType', back_populates='tasks') + + files = relationship('TaskFile', back_populates='task') diff --git a/API/app/infrastructure/database/models/step_types.py b/API/app/infrastructure/database/models/step_types.py new file mode 100644 index 0000000..9ad8f3c --- /dev/null +++ b/API/app/infrastructure/database/models/step_types.py @@ -0,0 +1,14 @@ +from sqlalchemy import Column, Integer, String, VARCHAR +from sqlalchemy.orm import relationship + +from app.infrastructure.database.models import Base + + +class StepType(Base): + __tablename__ = 'step_types' + + id = Column(Integer, primary_key=True, autoincrement=True) + title = Column(VARCHAR(200), nullable=False) + description = Column(String, nullable=False) + + steps = relationship('Step', back_populates='type') diff --git a/API/app/infrastructure/database/models/steps.py b/API/app/infrastructure/database/models/steps.py new file mode 100644 index 0000000..680a206 --- /dev/null +++ b/API/app/infrastructure/database/models/steps.py @@ -0,0 +1,20 @@ +from sqlalchemy import Column, Integer, ForeignKey, VARCHAR +from sqlalchemy.orm import relationship + +from app.infrastructure.database.models import Base + + +class Step(Base): + __tablename__ = 'steps' + + id = Column(Integer, primary_key=True, autoincrement=True) + title = Column(VARCHAR(200)) + + lesson_id = Column(Integer, ForeignKey('lessons.id'), nullable=False) + type_id = Column(Integer, ForeignKey('step_types.id'), nullable=False) + + lesson = relationship('Lesson', back_populates='steps') + type = relationship('StepType', back_populates='steps') + + lectures = relationship('Lectures', back_populates='step') + tasks = relationship('StepTask', back_populates='step') diff --git a/API/app/infrastructure/database/models/task_files.py b/API/app/infrastructure/database/models/task_files.py new file mode 100644 index 0000000..6ee5b5a --- /dev/null +++ b/API/app/infrastructure/database/models/task_files.py @@ -0,0 +1,16 @@ +from sqlalchemy import Column, Integer, String, ForeignKey +from sqlalchemy.orm import relationship + +from app.infrastructure.database.models import Base + + +class TaskFile(Base): + __tablename__ = 'task_files' + + id = Column(Integer, primary_key=True, autoincrement=True) + file_path = Column(String, nullable=False) + file_title = Column(String, nullable=False) + + task_id = Column(Integer, ForeignKey('step_tasks.id'), nullable=False) + + task = relationship('StepTask', back_populates='files') diff --git a/API/app/infrastructure/database/models/task_types.py b/API/app/infrastructure/database/models/task_types.py new file mode 100644 index 0000000..a914587 --- /dev/null +++ b/API/app/infrastructure/database/models/task_types.py @@ -0,0 +1,14 @@ +from sqlalchemy import Column, Integer, String, VARCHAR +from sqlalchemy.orm import relationship + +from app.infrastructure.database.models import Base + + +class TaskType(Base): + __tablename__ = 'task_types' + + id = Column(Integer, primary_key=True, autoincrement=True) + title = Column(VARCHAR(200), nullable=False) + description = Column(String, nullable=False) + + tasks = relationship('StepTask', back_populates='type')