Esempio n. 1
0
class Medication(db.Model):
    __tablename = "Medication"
    id = db.Column(db.Integer(), primary_key=True)
    username = db.Column(db.String(40))
    med_name = db.Column(db.String(50))
    dosage_interval = db.Column(db.String())
    prescription_date = db.Column(db.DateTime(), default=datetime.utcnow())
Esempio n. 2
0
class Hobby(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer,
                        db.ForeignKey('user.id'),
                        nullable=False,
                        server_default="")

    name = db.Column(db.String(32), index=True, nullable=False)
    sunday = db.Column(db.Boolean, default=False)
    monday = db.Column(db.Boolean, default=False)
    tuesday = db.Column(db.Boolean, default=False)
    wednesday = db.Column(db.Boolean, default=False)
    thursday = db.Column(db.Boolean, default=False)
    friday = db.Column(db.Boolean, default=False)
    saturday = db.Column(db.Boolean, default=False)
    color = db.Column(db.String(3), default="Red")
    #Need to check for null when displaying
    duration = db.Column(db.String(2), nullable=False)
    notes = db.Column(db.Text)
    goals = db.Column(db.Text)

    dates = db.relationship('Day',
                            secondary=days,
                            backref='hobbies',
                            lazy=True)

    def __repr__(self):
        return '<Hobby {}, Notes {}>'.format(self.name, self.notes)
Esempio n. 3
0
class User(db.Model):
    __tablename__ = "users"

    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(20), unique=True, index=True)
    password = db.Column(db.String(250))
    registered_on = db.Column(db.DateTime, nullable=False, index=True)

    def __init__(self, username, password):
        self.username = username
        self.set_password(password)
        self.registered_on = datetime.utcnow()

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

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

    def is_authenticated(self):
        return True

    def is_active(self):
        return True

    def is_anonymous(self):
        return False

    def get_id(self):
        return str(self.id)

    def __repr__(self):
        return '<User %r>' % (self.username)
Esempio n. 4
0
class User(db.Model):
	username = db.Column(db.String(80))
	password = db.Column(db.String(16))
        
        def __init__(self, username, password):
                self.username = username
                self.password = password

        def user_name_exists(username):
                exists = Session.query(exists().where(User.username == username)).scalar()
                return exists
Esempio n. 5
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(50), 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. 6
0
class PersonalInfo(db.Model):
    __tablename__ = "personal_Info"
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(64), nullable=False)
    age = db.Column(db.Integer())
    date_of_birth = db.Column(db.DateTime, default=datetime.now())
    social_security_number = db.Column(db.Integer)
    emergency_contact = db.Column(db.Integer())
    blood_group = db.Column(db.String(20))
    rhesus_factor = db.Column(db.String(20))
    height = db.Column(db.Integer())
    weight = db.Column(db.Integer())
Esempio n. 7
0
class Camp(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    owner_id = db.Column(db.Integer, db.ForeignKey("user.id"))
    name = db.Column(db.String(128), index=True)
    group = db.Column(db.String(64), index=True)
    location = db.Column(db.String(128), index=True)
    start_date = db.Column(db.DateTime, index=True, nullable=True)
    end_date = db.Column(db.DateTime, index=True, nullable=True)
    key = db.Column(db.String(8), index=True, unique=True)
    linked_car = db.relationship("Car", backref="car_id", lazy="dynamic")

    def __repr__(self):
        return "<CampName{} ".format(self.name) + " group:{} ".format(
            self.group) + " key:{}>".format(self.key)
Esempio n. 8
0
class Webcam(db.Model):
    __tablename__ = "webcams"

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(20), unique=True, index=True)
    filename = db.Column(db.String(20), unique=True, index=True)
    url = db.Column(db.String(250))
    created_on = db.Column(db.DateTime, nullable=False, index=True)

    @property
    def full_path(self):
        return '/static/media/%s' % self.filename

    def __repr__(self):
        return '<Webcam %r>' % (self.name)
Esempio n. 9
0
class User(UserMixin, db.Model):
    __tablename__ = "user"
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(64), nullable=False)
    email = db.Column(db.String(64), nullable=False)
    password_hash = db.Column(db.String(128), nullable=False)
    profile_picture = db.Column(db.String(40), default="default.png")
    first_name = db.Column(db.String(20))
    last_name = db.Column(db.String(20))
    address = db.Column(db.String(20))
    contact = db.Column(db.Integer())

    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')

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

    @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)

    ### REPRESENTATION METHOD CODE GOES HERE ###

    def __repr__(self):
        return f"User('{self.username}', '{self.email}')"
Esempio n. 10
0
class User(UserMixin, db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(64), index=True, unique=True)
    email = db.Column(db.String(120), index=True, unique=True)
    password_hash = db.Column(db.String(128))
    owned_car = db.relationship("Car", backref="car_owner", lazy="dynamic")
    owned_camp = db.relationship("Camp", backref="camp_owner", lazy="dynamic")

    assigned_seat = db.Column(db.Integer, db.ForeignKey("seat.id"))

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

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

    def __repr__(self):
        return "<Username: {}>".format(self.username)
Esempio n. 11
0
class User(UserMixin, db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(32),
                         index=True,
                         unique=True,
                         nullable=False)
    email = db.Column(db.String(128), index=True, unique=True, nullable=False)
    password_hash = db.Column(db.String(128))
    hobbies = db.relationship('Hobby', backref='user', lazy=True)

    def __repr__(self):
        return '<User {}>'.format(self.username)

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

    def get_password(self, password):
        return check_password_hash(self.password_hash, password)
Esempio n. 12
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)
    
    # To return user data
    def __repr__(self):
        return f"Post('{self.title}','{self.date_posted}')"
Esempio n. 13
0
class Car(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    number_of_seats = db.Column(db.Integer)
    starting_location = db.Column(db.String(140))
    owner_id = db.Column(db.Integer, db.ForeignKey("user.id"))
    seats = db.relationship("Seat", backref="seat_id", lazy="dynamic")

    linked_camp = db.Column(db.Integer, db.ForeignKey("camp.id"))

    def __repr__(self):
        return "<Car=> Owner:{} ".format(
            self.owner_id, self.number_of_seats) + "Seats:{} ".format(
                self.number_of_seats)
Esempio n. 14
0
class Immunizations(db.Model):
    __tablename__ = "Vaccines"
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(30))
    vaccine = db.Column(db.String(30))
    date = db.Column(db.DateTime, default=datetime.now())
Esempio n. 15
0
class Allergies(db.Model):
    __tablename__ = 'Allergies'
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(30))
    category = db.Column(db.String(30))
    allergens = db.Column(db.String(200))
Esempio n. 16
0
class HealthHistory(db.Model):
    __tablename__ = "Health_History"
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(30), nullable=False)
    health_condition = db.Column(db.String(50))
    condition_description = db.Column(db.String(300))