Esempio n. 1
0
class Meetings(db.Model):
    IDM = db.Column(db.Integer,primary_key= True)
    Mdate = db.Column(db.Text)
    Mtime = db.Column(db.Text)
    IDG = db.Column(db.Integer,db.ForeignKey('groups.id'))
    Occurence = db.Column(db.Text) 
    Platform = db.Column(db.Text)
    title = db.Column(db.Text)
    Rate = db.Column(db.Integer)
    Pros = db.Column(db.String(500))
    Cons = db.Column(db.String(500))
    attending = db.Column(db.String(500))
    DateAdded = db.Column(db.Text)

    studentsinMeeting = db.relationship('StudentsInMeeting',backref='meetings',lazy='dynamic')

    def __init__(self,Mdate,Mtime,IDG,Occurence,Platform,title,Rate,Pros,Cons,attending,DateAdded):
        self.Mdate = Mdate
        self.Mtime = Mtime
        self.IDG = IDG
        self.Occurence= Occurence
        self.Platform = Platform
        self.title = title
        self.Rate = Rate
        self.Pros = Pros
        self.Cons = Cons
        self.attending = attending
        self.DateAdded = DateAdded
Esempio 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(20), 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 get_reset_token(self, expires_sec=1800):
        s = Serializer(app.config['SECRET_KEY'], expires_sec)
        return s.dumps({'user_id': self.id}).decode('utf-8')

    @staticmethod
    def verify_reset_token(token):
        s = Serializer(app.config['SECRET_KEY'])
        try:
            user_id = s.loads(token)['user_id']
        except:
            return None
        return User.query.get(user_id)


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

    def __repr__(self):
        return f"User('{self.username}','{self.email}','{self.image_file}')"
    
    def set_password(self, pw):
        pwhash = bcrypt.hashpw(pw.encode('utf8'), bcrypt.gensalt())
        self.password_hash = pwhash.decode('utf8') # decode the hash to prevent is encoded twice
        return self.password_hash
Esempio n. 3
0
class Buy(db.Model, UserMixin):
    __tablename__ = "buy"
    id = db.Column(db.Integer, primary_key=True)
    itemid = db.Column(db.String(64))
    itemname = db.Column(db.String(64))
    price = db.Column(db.String(64))
    name = db.Column(db.String(64), index=True)
    email = db.Column(db.String(64), unique=False, index=True)
    ph = db.Column(db.String(64))
    size = db.Column(db.String(64))
    location = db.Column(db.String(256), unique=False, index=True)
    city = db.Column(db.String(64))
    pin = db.Column(db.String(64))

    def __init__(self, itemid, itemname, price, name, email, ph, size,
                 location, city, pin):
        self.itemid = itemid
        self.itemname = itemname
        self.price = price
        self.name = name
        self.email = email
        self.ph = ph
        self.size = size
        self.location = location
        self.city = city
        self.pin = pin
Esempio n. 4
0
class User(db.Model, UserMixin):

    __tablename__ = 'users'

    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String(64))
    username = db.Column(db.String(64))
    password_hash = db.Column(db.String)
    job = db.Column(db.String)
    name = db.Column(db.String(64))
    phone = db.Column(db.String)
    profile_image = db.Column(db.String)
    doctor_rel = db.relationship('D_accounts', backref='duser', uselist=False)
    patient_rel = db.relationship('P_accounts', backref='puser', uselist=False)
    blog_rel = db.relationship('BlogPost', backref='post', lazy='dynamic')

    def __init__(self, email, username, password, job, name, phone,
                 profile_image):
        self.email = email
        self.username = username
        self.password_hash = generate_password_hash(password)
        self.job = job
        self.name = name
        self.phone = phone
        self.profile_image = profile_image

    def check_password(self, password):
        return check_password_hash(self.password_hash, password)

    def __repr__(self):
        return f"Welcome {self.username}"
Esempio n. 5
0
class User(db.Model, UserMixin):

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

    id = db.Column(db.Integer,db.ForeignKey('volunteers.IDV'), primary_key = True)
    email = db.Column(db.String(64), unique=True, index=True)
    username = db.Column(db.String(64), unique=True, nullable=False, index=True)
    firstname = db.Column(db.Text)
    lastname = db.Column(db.Text)
    tel = db.Column(db.Text)
    permission = db.Column(db.Text)
    password_hash = db.Column(db.String(128))

    def __init__(self,id, email, username,firstname, lastname,tel,permission,password):
        self.id = id
        self.email = email
        self.username = username
        self.firstname = firstname
        self.lastname = lastname
        self.tel = tel
        self.permission = permission
        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)
Esempio n. 6
0
class Condidate(db.Model):

    __tablename__ = 'condidates'

    id = db.Column(db.Integer,primary_key= True)
    group_id = db.Column(db.Integer,db.ForeignKey('groups.id'))
    emailc = db.Column(db.String(64), unique=True, index=True)
    pronounc = db.Column(db.Text)
    phonenumc = db.Column(db.String(10))
    stimes = db.Column(db.Text)
    text = db.Column(db.Text)
    status = db.Column(db.Text)
    firstname = db.Column(db.Text)
    lastname = db.Column(db.Text)


    def __init__(self,group_id,emailc,pronounc,phonenumc,stimes,text,status,firstname,lastname):
        self.group_id = group_id
        self.emailc = emailc
        self.pronounc = pronounc
        self.phonenumc = phonenumc
        self.stimes = stimes
        self.text = text
        self.status = status
        self.firstname =firstname
        self.lastname = lastname
Esempio n. 7
0
class User(db.Model, UserMixin):

    # this is the table name inside the database
    __tablename__ = 'users'

    id = db.Column(db.Integer, primary_key=True)  # id, remains unique
    name = db.Column(db.String(20))
    email = db.Column(db.String(64), unique=True,
                      index=True)  # email should be unique
    password_hash = db.Column(db.String(128))  # password hash
    diseases = db.relationship('Disease', backref='users', lazy='dynamic')

    def __init__(self, name, email, password):
        self.name = name
        self.email = email
        # saving a sha sum hash instead of actual pass
        self.password_hash = generate_password_hash(password)

    def check_password(self, password):
        # checking if hashes match
        return check_password_hash(self.password_hash, password)

    def diseases_dict(self):
        disease_list = []
        symptoms_list = []
        for disease in self.diseases:
            disease_list.append(disease.disease_name)
            symptoms_list.append(disease.symptoms)
        disease_dict = dict(zip(symptoms_list, disease_list))
        return disease_dict
Esempio n. 8
0
class User(db.Model, UserMixin):

    __tablename__ = 'users'

    # Columns or attributes in database table named __tablename__
    id = db.Column(db.Integer,
                   primary_key=True)  # Primary key and will auto increment
    email = db.Column(db.String(128), unique=True, index=True, nullable=False)
    name = db.Column(db.String(128), nullable=False)
    contact_no = db.Column(db.String(20), default='0')
    password_hash = db.Column(db.String(512), nullable=False)

    # First argument is the name of class model to which it will reference
    # backref is the name of the relation
    # backref is a simple way to also declare a new property on the 'BlogPost' class
    # It is a one to many relationship by default
    events = db.relationship('Event', backref='user_of_this_event', lazy=True)

    #If you would want to have a one-to-one relationship you can pass uselist=False to relationship()

    def __init__(self, email, name, password, contact_no=None):
        self.email = email
        self.name = name
        self.contact_no = contact_no
        self.password_hash = generate_password_hash(password)

    def validate_password(self, password):
        return check_password_hash(self.password_hash, password)

    # Returns the string representaion of the class object
    def __repr__(self):
        return f'User mail: {self.email}'
Esempio n. 9
0
class User(UserMixin,db.Model):

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

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

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

    def check_password(self,password):
        # https://stackoverflow.com/questions/23432478/flask-generate-password-hash-not-constant-output
        # if password==self.password_hash:
        #     return True
        # else:
        #     return False
        return check_password_hash(self.password_hash,password)
Esempio n. 10
0
class PatientTest(db.Model):
    __tablename__ = 'patient_test'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(80), nullable=False)
    details = db.Column(db.String(150))
    patient_id = db.Column(db.Integer,
                           db.ForeignKey('patient.id'),
                           nullable=False)
    appointment_id = db.Column(db.Integer,
                               db.ForeignKey('appointment.id'),
                               nullable=False)

    patient = db.relationship('Patient',
                              backref=db.backref('test',
                                                 lazy='dynamic',
                                                 cascade="all, delete"))
    appointment = db.relationship('Appointment',
                                  backref=db.backref('patient_test',
                                                     lazy='dynamic',
                                                     cascade="all, delete"))

    def __init__(self, name, details, patient_id, appointment_id):
        self.name = name
        self.details = details
        self.patient_id = patient_id
        self.appointment_id = appointment_id

    def __repr__(self):
        return f'patient_test({self.id},{self.name},{self.patient_id},{self.details},{self.appointment_id})'

    def save(self):
        db.session.add(self)
        db.session.commit()
Esempio n. 11
0
class Quotes(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    quoteauthor = db.Column(db.String(100), index=True)
    quotestring = db.Column(db.String(200), index=True)

    def __repr__(self):
        return "<Quote : {}>".format(self.quotestring)
Esempio n. 12
0
class User(UserMixin, db.Model):

    __tablename__ = 'users'

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

    def get_reset_token(self, expires_sec=1800):
        s = Serializer(app.config['SECRET_KEY'], expires_sec)
        return s.dumps({'user_id': self.id}).decode('utf-8')

    @staticmethod
    def verify_reset_token(token):
        s = Serializer(app.config['SECRET_KEY'])
        try:
            user_id = s.loads(token)['user_id']
        except:
            return None
        return User.query.get(user_id)

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

    def check_password(self, password):
        return check_password_hash(self.password_hash, password)
Esempio n. 13
0
class User(db.Model, UserMixin):

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

    id = db.Column(db.Integer, primary_key=True)
    profile_image = db.Column(db.String(20), default='default_profile.png')
    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))
    user_type = db.Column(db.String(64), index=True)
    roles = db.relationship('Role', secondary='user_roles')
    s_user = db.relationship('Students', backref='students', uselist=False)
    t_user = db.relationship('Teachers', backref='teachers', uselist=False)
    posts = db.relationship('BlogPost', backref='author', lazy=True)

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

    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)
Esempio n. 14
0
class BlogPost(db.Model):
    # Setup the relationship to the User table
    users = db.relationship(User)

    # Model for the Blog Posts on Website
    id = db.Column(db.Integer, primary_key=True)
    # Notice how we connect the BlogPost to a particular author
    user_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False)
    date = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
    blog_img = db.Column(db.String(20), default='default_img.png')
    title = db.Column(db.String(140), nullable=False)
    topic = db.Column(db.String(60), nullable=False)
    text = db.Column(db.Text, nullable=False)
    blogcount = db.relationship('Blogcount', backref='coupos')
    usr = db.relationship('User', backref='userspost')

    def __init__(self, title, text, topic, blog_img, user_id):
        self.title = title
        self.text = text
        self.topic = topic
        self.blog_img = blog_img
        self.user_id = user_id

    def __repr__(self):
        return f"Post Id: {self.id} --- Date: {self.date} --- Title: {self.title}"
Esempio n. 15
0
class Actor(db.Model):
    """This class represents a table actors in the database
    """
    __tablename__ = 'actors'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(64), unique=True, index=True)
    added_on = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
    short_bio = db.Column(db.Text, nullable=False)
    picture = db.Column(db.String())
    # Connecting the Actor to a particular user (adder)
    user_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False)
    # Setup the relationship to the User table
    users = db.relationship(User)

    # This connects Movie to an Actor Author.
    movies = db.relationship('Movie', backref='author', lazy=True)

    def __repr__(self):
        """This method helps to easily print an instance of the class"""
        return f"<Actor ID: {self.id} --{self.name}--Added_on:{self.added_on}>"

    @property
    def serialize(self):
        """This method will help to represent the class User as a json object
        """
        return {
            'id': self.id,
            'name': self.name,
            'added_on': self.added_on,
            'short_bio': self.short_bio,
            'picture': self.picture,
            'user_id': self.user_id,
            'movies': [m.serialize for m in self.movies]
        }
Esempio n. 16
0
class User(db.Model, UserMixin):
    __tablename__ = 'user'

    id = db.Column(db.BigInteger, primary_key=True, index=True)
    email = db.Column(db.String(128), unique=True, nullable=False, index=True)
    password = db.Column(db.String(128), nullable=False)
    created = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
    modified = db.Column(db.DateTime)
    change_config = db.Column(db.PickleType)

    role = db.relationship('Role',
                           secondary='user_roles',
                           backref=db.backref('user', lazy='dynamic'))

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

    def __repr__(self):
        return f'user({self.id},{self.email},{self.created})'

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

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

    def add_role(self, role):
        self.role.append(role)

    def save(self):
        db.session.add(self)
        db.session.commit()
Esempio n. 17
0
class Stock(db.Model, UserMixin):

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

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(64), unique=True, index=True)
    code = db.Column(db.String(16), unique=True)
    fair_price = db.Column(db.Float)
    target_price = db.Column(db.Float)
    market_price = db.Column(db.Float)
    gain = db.Column(db.Float)
    txn_price = db.Column(db.Float)
    quantity = db.Column(db.Integer)

    def __init__(self,
                 name,
                 code,
                 fair_price,
                 target_price=0.0,
                 market_price=0.0,
                 gain=0.0,
                 txn_price=0.0,
                 quantity=0):
        self.name = name
        self.code = code
        self.fair_price = fair_price
        self.target_price = target_price
        self.market_price = market_price
        self.gain = gain
        self.txn_price = txn_price
        self.quantity = quantity
Esempio n. 18
0
class Patient(db.Model):
    __tablename__ = 'patient'

    id = db.Column(db.Integer, primary_key=True, index=True)
    name = db.Column(db.String(70), nullable=False)
    gender = db.Column(db.String(8), nullable=False)
    address = db.Column(db.String(150), nullable=False)
    city = db.Column(db.String(150))
    dob = db.Column(db.DateTime)
    contact = db.Column(db.BigInteger, unique=True)
    user_id = db.Column(db.BigInteger,
                        db.ForeignKey('user.id'),
                        nullable=False)

    user = db.relationship('User',
                           backref=db.backref('patient',
                                              lazy='dynamic',
                                              cascade="delete"))

    def __init__(self, name, gender, address, city, dob, contact, user_id):
        self.name = name
        self.gender = gender
        self.address = address
        self.city = city
        self.dob = dob
        self.contact = contact
        self.user_id = user_id

    def __repr__(self):
        return f'patient({self.id},{self.name},{self.gender},{self.address},{self.city},{self.dob},{self.contact})'

    def save(self):
        db.session.add(self)
        db.session.commit()
Esempio n. 19
0
class User(db.Model, UserMixin):

    __tablename__ = 'users'

    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(64), unique=True, index=True)
    password_hash = db.Column(db.String(128))
    email = db.Column(db.String(64), unique=True, index=True)
    profile_image = db.Column(db.String,
                              nullable=False,
                              default='default_profile.png')

    posts = db.relationship('BlogPosts', backref='author', lazy=True)

    def __init__(self, username, password, email):

        self.username = username
        self.password_hash = generate_password_hash(password)
        self.email = email

    def check_password(self, password):
        return check_password_hash(self.password_hash, password)

    def __repr__(self):
        return f"User: {self.username}"
Esempio n. 20
0
class Places(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    address = db.Column(db.String())
    city = db.Column(db.String())
    country = db.Column(db.String())

    def __repr__(self):
        return '<city %r>' % (self.city)
Esempio n. 21
0
class authenticated_user(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.String(48), db.ForeignKey('users.myid'), nullable=False, index=True)
    token = db.Column(db.String(48), unique=True, index=True)
    last_time_checked = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)

    def __init__(self, user_id, token):
        self.user_id = user_id
        self.token = token
Esempio n. 22
0
class Adding(db.Model, UserMixin):
    __tablename__ = "items"
    itemid = db.Column(db.String(64), primary_key=True)
    itemname = db.Column(db.String(64), index=True)
    price = db.Column(db.String(64))

    def __init__(self, itemid, itemname, price):
        self.itemid = itemid
        self.itemname = itemname
        self.price = price
Esempio n. 23
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}')"
Esempio n. 24
0
class active_users(db.Model):
    __tablename__ = 'active_users'
    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.String(48), db.ForeignKey('users.myid'), nullable=False, index=True)
    request_sid = db.Column(db.String(120), unique=True, nullable=False)
    date = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)

    def __init__(self, user_id, request_sid):
        self.user_id = user_id
        self.request_sid = request_sid
Esempio n. 25
0
class Menu(db.Model):
    __tablename__ = "menu"
    id = db.Column(db.Integer,
                   autoincrement=True,
                   primary_key=True,
                   nullable=False)  # 主键自增,唯一,不可为空
    name = db.Column(db.String(128), unique=True)
    price = db.Column(db.String(64), nullable=False)

    def __repr__(self):
        return "Menu object: name=%s" % self.name
Esempio n. 26
0
class Semester(db.Model):

    __tablename__ = 'semesters'

    users = db.relationship(User)

    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False)

    term = db.Column(db.String(10), nullable=False)
    year = db.Column(db.String(20), nullable=False)
Esempio n. 27
0
class URL(db.Model):
    hash_id = db.Column(db.String(10), primary_key=True)
    short_url = db.Column(db.String(80), unique=True, nullable=False)
    long_url = db.Column(db.String(500), unique=True, nullable=False)
    user_id = db.Column(db.Integer, db.ForeignKey('users.id'))

    def __init__(self, hash_id, short_url, long_url, user_id):
        self.hash_id = hash_id
        self.short_url = short_url
        self.long_url = long_url
        self.user_id = user_id
Esempio n. 28
0
class User(db.Model, UserMixin):
    __tablename__ = 'users'
    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String(64), unique=True, index=True)
    password_hash = db.Column(db.String(128))

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

    def check_password(self, password):
        return check_password_hash(self.password_hash, password)
Esempio n. 29
0
class Contact(db.Model):
    __tablename__ = "forms"
    id = db.Column(db.Integer, primary_key=True)
    text = db.Column(db.Text)
    date = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
    email = db.Column(db.String(64))
    name = db.Column(db.String(64))

    def __init__(self, text, email, name):
        self.text = text
        self.email = email
        self.name = name
Esempio n. 30
0
class User(db.Model, UserMixin):
    __tablename__ = 'users'

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

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

    def check_password(self, password):
        check_password_hash(self.password_hash, password)