Example #1
0
class PostModel(db.Model):
    post_id = db.Column(db.Integer,
                        primary_key=True,
                        nullable=False,
                        autoincrement=True)
    user_id = db.Column(db.Integer,
                        db.ForeignKey(UserModel.user_id),
                        nullable=False)
    post_text = db.Column(db.String, nullable=False)
    comments = db.relationship("CommentModel",
                               backref='posts',
                               cascade='delete')
    created_time = db.Column(db.DateTime(timezone=True), default=func.now())
    points = db.relationship("PostPointModel",
                             backref='posts',
                             cascade='delete')

    def __init__(self, post_text, user_id):
        self.user_id = user_id
        self.post_text = post_text
        self.created_time = datetime.utcnow()
        self.modified_at = datetime.utcnow()

    def __repr__(self):
        return '<Post %r>' % self.post_text
Example #2
0
class File(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    filename = db.Column(db.String(100), unique=False, nullable=False)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)

    def __repr__(self):
        return '<Post %r>' % self.id
Example #3
0
class RoleModel(db.Model):
    role_id = db.Column(db.Integer(), primary_key=True, autoincrement=True)
    role_name = db.Column(db.String(), unique=True)
    users = db.relationship("UserRolesModel",
                            backref='roles',
                            cascade='delete',
                            lazy=True)

    def __init__(self, role_name):
        self.role_name = role_name
Example #4
0
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String(100), unique=True, nullable=False)
    password = db.Column(db.String(100), nullable=False)

    # admin = db.Column(db.Boolean(), nullable=True)
    # posts = db.Column(db)

    def __repr__(self):
        return '<User %r>' % self.email
Example #5
0
class UserRolesModel(db.Model):
    user_role_id = db.Column(db.Integer(),
                             primary_key=True,
                             autoincrement=True)
    user_id = db.Column(db.Integer(),
                        db.ForeignKey(UserModel.user_id),
                        unique=True)
    role_id = db.Column(db.Integer(), db.ForeignKey(RoleModel.role_id))

    def __init__(self, user_id, role_id):
        self.user_id = user_id
        self.role_id = role_id
Example #6
0
class Result(db.Model):
    __tablename__ = 'results'
    id = db.Column(db.Integer(), primary_key=True)
    date = db.Column(db.DateTime, nullable=False)
    results = db.Column(db.ARRAY(Float), nullable=False)
    mean = db.Column(db.Float, nullable=False)
    pacientId = db.Column(db.Float, nullable=False)

    def __init__(self, date, results, mean, pacientId):
        self.date = date
        self.results = results
        self.mean = mean
        self.pacientId = pacientId
Example #7
0
class CommentPointModel(db.Model):
    def __init__(self, comment_id, points):
        self.comment_id = comment_id
        self.points = points

    comment_id = db.Column(db.Integer,
                           db.ForeignKey(CommentModel.comment_id),
                           unique=False,
                           nullable=False)
    point_id = db.Column(db.Integer,
                         primary_key=True,
                         nullable=False,
                         autoincrement=True)
    points = db.Column(db.Integer, nullable=False)
Example #8
0
class UserPointModel(db.Model):
    def __init__(self, user_id, points):
        self.user_id = user_id
        self.points = points

    user_id = db.Column(db.Integer,
                        db.ForeignKey(UserModel.user_id),
                        unique=False,
                        nullable=False)
    point_id = db.Column(db.Integer,
                         primary_key=True,
                         nullable=False,
                         autoincrement=True)
    points = db.Column(db.Integer, nullable=False)
Example #9
0
class Medic(UserMixin, db.Model):
    __tablename__ = 'medici'
    id = db.Column(db.Integer(), primary_key=True)
    nume = db.Column(db.String(255), nullable=False)
    prenume = db.Column(db.String(255), nullable=False)
    email = db.Column(db.String(255), nullable=False, unique=True)
    parola = db.Column(db.String(255), nullable=False, server_default='')
    status = db.Column(db.String(255), nullable=False)

    def __init__(self, nume, prenume, email):
        self.nume = nume
        self.prenume = prenume
        self.email = email
        self.password = ''
        self.status = ''

    def __repr__(self):
        return '<Medic {}>'.format(self.email)

    def set_password(self, parola):
        self.parola = generate_password_hash(parola)

    def set_status(self, status):
        self.status = status

    def check_password(self, parola):
        return check_password_hash(self.parola, parola)
Example #10
0
class UserModel(db.Model):
    user_id = db.Column(db.Integer,
                        primary_key=True,
                        nullable=False,
                        autoincrement=True)
    username = db.Column(db.String(120), unique=True, nullable=False)
    email = db.Column(db.String, unique=True, nullable=False)
    password_hash = db.Column(db.String(120), unique=True, nullable=False)
    created_time = db.Column(db.DateTime(timezone=True), default=func.now())
    modified_at = db.Column(db.DateTime(timezone=True), default=func.now())
    comments = db.relationship('CommentModel',
                               backref='users',
                               cascade='delete',
                               lazy=True)
    posts = db.relationship('PostModel',
                            backref='users',
                            cascade='delete',
                            lazy=True)
    points = db.relationship("UserPointModel",
                             backref='users',
                             cascade='delete',
                             lazy=True)
    roles = db.relationship("UserRolesModel",
                            backref='users',
                            lazy=True,
                            cascade='delete')

    def __init__(self, username, email, raw_password):
        self.username = username
        self.email = email
        # Save the hashed password
        self.set_password(raw_password)

    def __repr__(self):
        return '<User %r>' % self.username

    def set_password(self, raw_password):
        self.password_hash = generate_password_hash(raw_password)

    def check_password(self, password):
        return check_password_hash(self.password_hash, password)
Example #11
0
class Patient(UserMixin, db.Model):
    __tablename__ = 'pacienti'
    id = db.Column(db.Integer(), primary_key=True)
    numeParinte = db.Column(db.String(255), nullable=False)
    prenumeParinte = db.Column(db.String(255), nullable=False)
    email = db.Column(db.String(255), nullable=False, unique=True)
    telefon = db.Column(db.Integer, nullable=False)
    parola = db.Column(db.String(255), nullable=False, server_default='')
    numeCopil = db.Column(db.String(255), nullable=False)
    prenumeCopil = db.Column(db.String(255), nullable=False)
    varsta = db.Column(db.Integer, nullable=False)
    medicId = db.Column(db.Integer, nullable=False)
    status = db.Column(db.String(255), nullable=False)

    def __init__(self, numeParinte, numeCopil, prenumeParinte, prenumeCopil,
                 email, telefon, varsta, idMedic):
        self.numeParinte = numeParinte
        self.numeCopil = numeCopil
        self.prenumeParinte = prenumeParinte
        self.prenumeCopil = prenumeCopil
        self.telefon = telefon
        self.email = email
        self.varsta = varsta
        self.password = ''
        self.status = ''
        self.medicId = idMedic

    def __repr__(self):
        return '<Pacient {}>'.format(self.email)

    def set_password(self, parola):
        self.parola = generate_password_hash(parola)

    def set_varsta(self, v):
        self.varsta = generate_password_hash(v)

    def set_status(self, status):
        self.status = status

    def check_password(self, parola):
        return check_password_hash(self.parola, parola)