Exemplo n.º 1
0
class User(db.Model):

    __tablename__ = "users"

    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    email = db.Column(db.String(255), unique=True, nullable=False)
    password = db.Column(db.String(255), nullable=False)
    registered_on = db.Column(db.DateTime, nullable=False)
    admin = db.Column(db.Boolean, nullable=False, default=False)

    def __init__(self, email, password, admin=False):
        self.email = email
        self.password = bcrypt.generate_password_hash(password)
        self.registered_on = datetime.datetime.now()
        self.admin = admin

    def is_authenticated(self):
        return True

    def is_active(self):
        return True

    def is_anonymous(self):
        return False

    def get_id(self):
        return self.id

    def __repr__(self):
        return '<User {0}>'.format(self.email)
Exemplo n.º 2
0
class User(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(20), unique=True, nullable=False)
    email = db.Column(db.String(120), unique=True, nullable=False)
    image_file = db.Column(db.String(20), nullable=False, default='default.jpg')
    password = db.Column(db.String(60), nullable=False)
    posts = db.relationship('Post', backref='author', lazy=True)

    def __repr__(self):
        return f"User('{self.username}', '{self.email}', '{self.image_file}')"
Exemplo n.º 3
0
class coordinator(db.Model):
    cd_id = db.Column('cd_id', db.Integer, primary_key=True)
    cd_name = db.Column('cd_name', db.String(20), nullable=False)
    cd_dept = db.Column('cd_dept', db.String(3), nullable=False)
    cd_phone = db.Column('cd_phone', db.String(12), unique=True)
    cd_email = db.Column('cd_email',
                         db.String(20),
                         unique=True,
                         nullable=False)

    projects = db.relationship('fyp', backref='coordinator', lazy=True)

    def __repr__(self):
        return f"fyp('{self.cd_id}', '{self.cd_email}')"
Exemplo n.º 4
0
class supervisor(db.Model):
    sv_id = db.Column('sv_id', db.Integer, primary_key=True)
    sv_name = db.Column('sv_name', db.String(20), nullable=False)
    sv_niche = db.Column('sv_niche', db.String(20))
    sv_phone = db.Column('sv_phone', db.String(12), unique=True)
    sv_email = db.Column('sv_email',
                         db.String(20),
                         unique=True,
                         nullable=False)
    sv_dept = db.Column('sv_dept', db.String(3), nullable=False)
    students = db.relationship('student', backref='supervisor', lazy=True)

    def __repr__(self):
        return f"supervisor('{self.sv_id}', '{self.sv_email}')"
Exemplo n.º 5
0
class fyp(db.Model):
    proj_id = db.Column('proj_id', db.String(4), primary_key=True)
    proj_title = db.Column('proj_title', db.String(50))
    proj_type = db.Column('proj_type', db.String(11))
    proj_level = db.Column('proj_level', db.String(4))

    cd_id = db.Column('cd_id',
                      db.Integer,
                      db.ForeignKey('coordinator.cd_id'),
                      nullable=False)

    students = db.relationship('student', backref='fyp', lazy=True)

    def __repr__(self):
        return f"fyp('{self.proj_id}', '{self.proj_title}')"
Exemplo n.º 6
0
class examiner(db.Model):
    ex_id = db.Column('ex_id', db.Integer, primary_key=True)
    ex_name = db.Column('ex_name', db.String(20), nullable=False)

    students = db.relationship('student', backref='examiner', lazy=True)

    def __repr__(self):
        return f"examiner('{self.ex_id}', '{self.ex_name}')"
Exemplo n.º 7
0
class User(db.Model, UserMixin):

    # Create a table in the db
    __tablename__ = 'users'

    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String(64), unique=True, index=True)
    username = db.Column(db.String(64), unique=True, index=True)
    password_hash = db.Column(db.String(128))

    def __init__(self, email, username, password):
        self.email = email
        self.username = username
        self.password_hash = generate_password_hash(password)

    def check_password(self, password):
        # https://stackoverflow.com/questions/23432478/flask-generate-password-hash-not-constant-output
        return check_password_hash(self.password_hash, password)
Exemplo n.º 8
0
class Post(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(100), nullable=False)
    date_posted = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
    content = db.Column(db.Text, nullable=False)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)

    def __repr__(self):
        return f"Post('{self.title}', '{self.date_posted}')"
Exemplo n.º 9
0
class schedule(db.Model):
    schedule_id = db.Column('schedule_id', db.Integer, primary_key=True)
    schedule_dept = db.Column('schedule_dept', db.String(3))
    schedule_class_date = db.Column('schedule_date',
                                    db.DateTime,
                                    default=datetime.utcnow)
    schedule_milestone = db.Column('schedule_milestone',
                                   db.DateTime,
                                   default=datetime.utcnow)

    projects = db.relationship('fyp', backref='schedule', lazy=True)

    def __repr__(self):
        return f"schedule('{self.schedule_id}', '{self.schedule_dept}', '{self.schedule_date}', '{self.schedule_milestone}')"
Exemplo n.º 10
0
class student(db.Model):
    student_id = db.Column('student_id', db.Integer, primary_key=True)
    student_name = db.Column('student_name', db.String(20), nullable=False)
    student_phone = db.Column('student_phone', db.String(12))
    student_email = db.Column('student_email', db.String(20), nullable=False)
    student_mark = db.Column('student_mark', db.Integer)
    student_dept = db.Column('student_dept', db.String(3), nullable=False)

    proj_id = db.Column('proj_id',
                        db.String(4),
                        db.ForeignKey('fyp.proj_id'),
                        nullable=False)
    sv_id = db.Column('sv_id',
                      db.Integer,
                      db.ForeignKey('supervisor.sv_id'),
                      nullable=False)
    examiner_id = db.Column('ex_id',
                            db.Integer,
                            db.ForeignKey('examiner.ex_id'),
                            nullable=False)

    def __repr__(self):
        return f"student('{self.student_id}', '{self.proj_id}')"