From b707b29c8de299802e07052821f63947ac5a1cbd Mon Sep 17 00:00:00 2001 From: Sovraska Date: Sat, 16 Dec 2023 21:53:51 +0300 Subject: [PATCH] removes some models --- app/models/achievements.py | 13 --------- app/models/associations.py | 54 ------------------------------------- app/models/base.py | 12 --------- app/models/courses.py | 21 --------------- app/models/examinations.py | 10 ------- app/models/notifications.py | 11 -------- app/models/profiles.py | 19 ------------- app/models/tariffs.py | 14 ---------- app/models/tasks.py | 13 --------- 9 files changed, 167 deletions(-) delete mode 100644 app/models/achievements.py delete mode 100644 app/models/associations.py delete mode 100644 app/models/base.py delete mode 100644 app/models/courses.py delete mode 100644 app/models/examinations.py delete mode 100644 app/models/notifications.py delete mode 100644 app/models/profiles.py delete mode 100644 app/models/tariffs.py delete mode 100644 app/models/tasks.py diff --git a/app/models/achievements.py b/app/models/achievements.py deleted file mode 100644 index bcdaded..0000000 --- a/app/models/achievements.py +++ /dev/null @@ -1,13 +0,0 @@ -from sqlalchemy.orm import relationship - -from app.core.db import Base -from app.models.base import AbstractBaseMixin -from app.models.associations import achievement_profile_association - - -class Achievement(AbstractBaseMixin, Base): - profiles = relationship( - 'Profile', - secondary=achievement_profile_association, - back_populates='achievements' - ) diff --git a/app/models/associations.py b/app/models/associations.py deleted file mode 100644 index 5589c49..0000000 --- a/app/models/associations.py +++ /dev/null @@ -1,54 +0,0 @@ -from sqlalchemy import ( - Column, Integer, ForeignKey, Table, SmallInteger -) -from sqlalchemy.orm import relationship - -from app.core.db import Base - - -group_user_association = Table( - 'group_user_association', Base.metadata, - Column('user_id', Integer, ForeignKey('user.id')), - Column('group_id', Integer, ForeignKey('group.id')), -) - -achievement_profile_association = Table( - 'achievement_profile_association', Base.metadata, - Column('profile_id', Integer, ForeignKey('profile.id')), - Column('achievement_id', Integer, ForeignKey('achievement.id')) -) -course_task_association = Table( - 'course_task_association', Base.metadata, - Column('course_id', Integer, ForeignKey('course.id')), - Column('task_id', Integer, ForeignKey('task.id')) -) -course_tariff_association = Table( - 'course_tariff_association', Base.metadata, - Column('course_id', Integer, ForeignKey('course.id')), - Column('tariff_id', Integer, ForeignKey('tariff.id')) -) -user_notification_association = Table( - 'user_notification_association', Base.metadata, - Column('user_id', Integer, ForeignKey('user.id')), - Column('notification_id', Integer, ForeignKey('notification.id')) -) - - -class UserCourse(Base): - user_id = Column(Integer, ForeignKey('user.id'), primary_key=True) - course_id = Column(Integer, ForeignKey('course.id'), primary_key=True) - progress = Column(SmallInteger) - user = relationship('User', back_populates='course_usercourse') - course = relationship('Course', back_populates='user_usercourse') - - -class UserExamination(Base): - user_id = Column(Integer, ForeignKey('user.id'), primary_key=True) - examination_id = Column( - Integer, ForeignKey('examination.id'), primary_key=True - ) - progress = Column(SmallInteger) - user = relationship('User', back_populates='examination_userexamination') - examination = relationship( - 'Examination', back_populates='user_userexamination' - ) diff --git a/app/models/base.py b/app/models/base.py deleted file mode 100644 index 8aba703..0000000 --- a/app/models/base.py +++ /dev/null @@ -1,12 +0,0 @@ -from sqlalchemy import Column, String, Text - -from app.core.config import settings - - -class AbstractBaseMixin(object): - name = Column( - String(length=settings.max_length_string), - unique=True, - nullable=False - ) - description = Column(Text) diff --git a/app/models/courses.py b/app/models/courses.py deleted file mode 100644 index 66fb0b6..0000000 --- a/app/models/courses.py +++ /dev/null @@ -1,21 +0,0 @@ -from sqlalchemy.orm import relationship - -from app.core.db import Base -from app.models.base import AbstractBaseMixin -from app.models.associations import ( - course_task_association, course_tariff_association -) - - -class Course(AbstractBaseMixin, Base): - tasks = relationship( - 'Task', - secondary=course_task_association, - back_populates='courses' - ) - user_usercourse = relationship('UserCourse', back_populates='course') - tariffs = relationship( - 'Tariff', - secondary=course_tariff_association, - back_populates='courses' - ) diff --git a/app/models/examinations.py b/app/models/examinations.py deleted file mode 100644 index 74d05d2..0000000 --- a/app/models/examinations.py +++ /dev/null @@ -1,10 +0,0 @@ -from sqlalchemy.orm import relationship - -from app.core.db import Base -from app.models.base import AbstractBaseMixin - - -class Examination(AbstractBaseMixin, Base): - user_userexamination = relationship( - 'UserExamination', back_populates='examination' - ) diff --git a/app/models/notifications.py b/app/models/notifications.py deleted file mode 100644 index 75d5e4f..0000000 --- a/app/models/notifications.py +++ /dev/null @@ -1,11 +0,0 @@ -from sqlalchemy.orm import relationship - -from app.core.db import Base -from app.models.associations import user_notification_association - - -class Notification(Base): - users = relationship( - 'User', secondary=user_notification_association, - back_populates='notifications' - ) diff --git a/app/models/profiles.py b/app/models/profiles.py deleted file mode 100644 index 8ef3d27..0000000 --- a/app/models/profiles.py +++ /dev/null @@ -1,19 +0,0 @@ -from sqlalchemy import Column, String, SmallInteger, Integer, ForeignKey -from sqlalchemy.orm import relationship - -from app.core.db import Base -from app.core.config import settings -from app.models.associations import achievement_profile_association - - -class Profile(Base): - first_name = Column(String(length=settings.max_length_string)) - second_name = Column(String(length=settings.max_length_string)) - age = Column(SmallInteger) - achievements = relationship( - 'Achievement', - secondary=achievement_profile_association, - back_populates='profiles' - ) - user_id = Column(Integer, ForeignKey('user.id')) - user = relationship('User', back_populates="profile") diff --git a/app/models/tariffs.py b/app/models/tariffs.py deleted file mode 100644 index f39f06f..0000000 --- a/app/models/tariffs.py +++ /dev/null @@ -1,14 +0,0 @@ -from sqlalchemy.orm import relationship - -from app.core.db import Base -from app.models.base import AbstractBaseMixin -from app.models.associations import course_tariff_association - - -class Tariff(AbstractBaseMixin, Base): - courses = relationship( - 'Course', - secondary=course_tariff_association, - back_populates='tariffs' - ) - users = relationship('User', back_populates='tariff') diff --git a/app/models/tasks.py b/app/models/tasks.py deleted file mode 100644 index 71cb738..0000000 --- a/app/models/tasks.py +++ /dev/null @@ -1,13 +0,0 @@ -from sqlalchemy.orm import relationship - -from app.core.db import Base -from app.models.base import AbstractBaseMixin -from app.models.associations import course_task_association - - -class Task(AbstractBaseMixin, Base): - courses = relationship( - 'Course', - secondary=course_task_association, - back_populates='tasks' - )