Example #1
0
from enum import unique
# from cms.core.views import index
from cms import db,login_manager
from werkzeug.security import generate_password_hash,check_password_hash
from flask_login import UserMixin
from datetime import datetime

@login_manager.user_loader
def load_user(user_id):
    return Professor.query.get(user_id)


course_helper=db.Table('course_helper',
                        db.Column('user_id',db.Integer,db.ForeignKey('users.id')),
                        db.Column('course_id',db.Integer,db.ForeignKey('courses.id'))
                        )
branch_helper=db.Table('branch_helper',
                        db.Column('course_id',db.Integer,db.ForeignKey('courses.id')),
                        db.Column('branch_id',db.Integer,db.ForeignKey('branches.id'))
                        )
class Branch(db.Model):
    __tablename__='branches'
    id= db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100), nullable=False)
    students= db.relationship('User', backref='branch', lazy=True)
    professors= db.relationship('Professor', backref='branch', lazy=True)
    def __init__(self,name):
        self.name = name
    def __repr__(self)-> str:
        return self.name
class User(db.Model,UserMixin):
Example #2
0
from cms import db

Enrollments = db.Table('enrollment',
                       db.Column("course_id", db.Integer, db.ForeignKey("course.id"), primary_key=True),
                       db.Column("student_id", db.Integer, db.ForeignKey("student.id"), primary_key=True)
                       )