class Partner(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(50), nullable=False) description = db.Column(db.Text, nullable=False) image = db.Column(db.String(20), nullable=False, default='default.jpg') def __repr__(self): return f"Partner('{self.name}', '{self.description}')"
class History(db.Model): id = db.Column(db.Integer, primary_key=True) header = db.Column(db.String(50), nullable=False) description = db.Column(db.Text, nullable=False) date = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) image = db.Column(db.String(20), nullable=False, default='default.jpg') def __repr__(self): return f"History('{self.header}', '{self.description}', '{self.datetime}')"
class NewsComment(db.Model): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(50), nullable=False) email = db.Column(db.String(30), nullable=False) message = db.Column(db.Text, nullable=False) datetime = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) news_id = db.Column(db.Integer, db.ForeignKey('news.id'), nullable=False) def __repr__(self): return f"NewsComment('{self.username}', '{self.email}', '{self.datetime}', '{self.message}')"
class Callback(db.Model): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(50), nullable=False) email = db.Column(db.String(30), nullable=False) phone = db.Column(db.String(13)) subject = db.Column(db.String(60), nullable=False) message = db.Column(db.Text, nullable=False) datetime = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) def __repr__(self): return f"Callback('{self.username}', '{self.email}', '{self.subject}', '{self.message}', '{self.datetime}')"
class News(db.Model): id = db.Column(db.Integer, primary_key=True) header = db.Column(db.String(70), nullable=False) description = db.Column(db.Text, nullable=False) date_posted = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) image = db.Column(db.String(20), nullable=False, default='default.jpg') text = db.Column(db.Text, nullable=False) category_id = db.Column(db.Integer, db.ForeignKey('news_category.id')) comments = db.relationship('NewsComment', backref='news', lazy=True) def __repr__(self): return f"News('{self.header}', '{self.description}', '{self.date_posted}')"
class Project(db.Model): id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(70), nullable=False) image = db.Column(db.String(20), nullable=False, default='default.jpg') description = db.Column(db.Text, nullable=False) authors = db.Column(db.String(180), nullable=False) url = db.Column(db.String(70)) year = db.Column(db.Enum(Years), default=Years.FIRST) semester = db.Column(db.Enum(Semesters), default=Semesters.FIRST) pictures = db.relationship('ProjectPicture', backref='project', lazy=True, cascade='all, delete') def __repr__(self): return f"Project('{self.title}', '{self.description}', '{self.authors}', '{self.year}','{self.semester}')"
class ProjectPicture(db.Model): id = db.Column(db.Integer, primary_key=True) image = db.Column(db.String(20), nullable=False, default='default.jpg') project_id = db.Column(db.Integer, db.ForeignKey('project.id'), nullable=False) def __repr__(self): return f"ProjectPicture('{self.id}', '{self.project_id}')"
class PageText(db.Model): id = db.Column(db.Integer, primary_key=True) primary_text = db.Column(db.Text) image = db.Column(db.String(20)) secondary_text = db.Column(db.Text) position = db.Column(db.Integer, nullable=False, default=1) page_id = db.Column(db.Integer, db.ForeignKey('page.id'), nullable=False) def __repr__(self): return f"PageText('{self.primary_text}', '{self.secondary_text}', '{self.position}', '{self.page_id}')"
class Page(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(30), nullable=False) texts = db.relationship('PageText', backref='page', lazy=True, cascade='all, delete') def __repr__(self): return f"Page('{self.name}')"
class NewsCategory(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(30), nullable=False) news = db.relationship('News', backref='category', lazy=True, cascade='save-update') def __repr__(self): return f"NewsCategory('{self.name}')"
class Teacher(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(70), nullable=False) position = db.Column(db.String(50), nullable=False) link = db.Column(db.String(70)) incumbency = db.Column(db.String(50), nullable=False) description = db.Column(db.Text) interests = db.Column(db.Text) research_directions = db.Column(db.Text) hobby = db.Column(db.String(50)) scopus_id = db.Column(db.String(11)) scholar_id = db.Column(db.String(12)) image = db.Column(db.String(20), nullable=False, default='default.jpg') def __repr__(self): return f"Teacher('{self.name}', '{self.position}', '{self.incumbency}', '{self.description}')"
class Course(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(50), nullable=False) credits = db.Column(db.Integer, nullable=False) year = db.Column(db.Enum(Years), default=Years.FIRST) semester = db.Column(db.Enum(Semesters), default=Semesters.FIRST) related = db.relation('CourseRelationship', primaryjoin=id == CourseRelationship.one_course_id, cascade='all, delete') def get_related_courses(self): courses = [] for one in self.related: courses.append( Course.query.filter_by(id=one.other_course_id).first()) return courses def __repr__(self): return f"Course('{self.name}', '{self.credits}', '{self.year}', '{self.semester}')"