Exemple #1
0
class Users(db.Model):

    __tablename__ = "user"

    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String(255), unique=True, nullable=False)
    password = db.Column(db.String(255), nullable=False)
    first_name = db.Column(db.String(255), nullable=False)
    last_name = db.Column(db.String(255), nullable=False)
    verified = db.Column(db.Boolean, default=False, nullable=False)

    def __init__(self, email, password, first_name, last_name):
        self.email = email
        self.password = argon2.hash(password)
        self.first_name = first_name
        self.last_name = last_name

    def authenticate(self, password):
        return argon2.verify(password, self.password)

    def change_password(self, old_password, new_password):
        if not argon2.verify(old_password, self.password):
            return False
        self.password = argon2.hash(new_password)
        self.save()
        return True
Exemple #2
0
class Restaurant(db.model):
    __tablename__ = "Restaurant"

    rest_id =  db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(255),  nullable=False)
    location = db.Column(db.String(255),  nullable=False)
    contact = db.Column(db.String(255),  nullable=False)
    open_time = db.Column(db.Time, nullable=False)
    end_time = db.Column(db.Time,nullable=True)

    @property
    def json(self):
        return to_json(self, self.__class__)
class Token(db.Model):
    __tablename__ = "token"

    token_id = db.Column(db.Integer, primary_key=True)
    charge_id = db.Column(db.Integer, db.ForeignKey('charge.charge_id'))
    vehicle_no = db.Column(db.String(200), nullable=False)
    computed_charge = db.Column(db.Float, nullable=True)
    pay_method = db.Column(db.String(200), nullable=True)

    entry_date = db.Column(db.DateTime, nullable=False)
    exit_date = db.Column(db.DateTime, nullable=True)
    entry_operator_id = db.Column(db.String(50), nullable=False)
    exit_operator_id = db.Column(db.String(50), nullable=True)
class Users(db.Model):

    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String(255), unique=True, nullable=False)
    password = db.Column(db.String(255), nullable=False)
    first_name = db.Column(db.String(255), nullable=False)
    last_name = db.Column(db.String(255), nullable=False)
    authenticated = db.Column(db.Boolean, default=False)

    def __init__(self, first_name, last_name, email, password):
        self.first_name = first_name
        self.last_name = last_name
        self.email = email
        self.password = argon2.hash(password)

    def authenticate(self, password):
        return argon2.verify(password, self.password)

    def change_password(self, old_password, new_password):
        if not argon2.verify(old_password, self.password):
            return False
        self.password = argon2.hash(new_password)
        self.save()
        return True

    @property
    def is_authenticated(self):
        return self.authenticated

    @property
    def is_active(self):
        return True

    @property
    def is_anonymous(self):
        return False

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

    def __repr__(self):
        return '<User {0}>'.format(self.email)
class ParkingLot(db.Model):

    __tablename__ = "parkinglot"

    id = db.Column(db.Integer, primary_key=True)
    pl_id = db.Column(db.Integer, nullable=False)
    pl_name = db.Column(db.String(255), nullable=False)
    pl_address = db.Column(db.String(255), nullable=False)
    pl_capacity = db.Column(db.Integer, nullable=False)
    pl_default_price = db.Column(db.Float, nullable=False)
    pl_active = db.Column(db.Boolean, default=True, nullable=False)

    def __init__(self, pl_id, pl_name, pl_address, pl_capacity,
                 pl_default_price, pl_active):
        self.pl_id = pl_id
        self.pl_name = pl_name
        self.pl_address = pl_address
        self.pl_capacity = pl_capacity
        self.pl_default_price = pl_default_price
        self.pl_active = pl_active
Exemple #6
0
class UtilizationStage(db.Model):
    __tablename__ = "utilization_stage"

    id = db.Column(db.Integer, primary_key=True)
    pl_id = db.Column(db.Integer, nullable=False)
    util_date = db.Column(db.Date, unique=True, nullable=False)
    util_per_hour = db.Column(db.String(175), nullable=False)
    rev_per_hour = db.Column(db.String(175), nullable=False)
    avg_util = db.Column(db.Float, nullable=False)
    total_rev = db.Column(db.Float, nullable=False)
    is_sent = db.Column(db.Boolean, default=False, nullable=False)

    def __init__(self, pl_id, util_date, util_per_hour, rev_per_hour, avg_util,
                 total_rev):
        self.pl_id = pl_id
        self.util_date = util_date
        self.util_per_hour = util_per_hour
        self.rev_per_hour = rev_per_hour
        self.avg_util = avg_util
        self.total_rev = total_rev
class Charge(db.Model):
    __tablename__ = "charge"

    charge_id = db.Column(db.Integer, primary_key=True)
    ch_active = db.Column(db.Boolean, default=True, nullable=False)
    update_date = db.Column(db.DateTime,
                            default=db.func.current_timestamp(),
                            nullable=False)

    pl_id = db.Column(db.Integer, db.ForeignKey('parkinglot.id'))
    price_snapshot = db.Column(db.String(2500), nullable=False)

    def __init__(self, pl_id, price_snapshot):
        self.pl_id = pl_id
        self.price_snapshot = price_snapshot
Exemple #8
0
class FoodItem(db.Model):
    __tablename__ = "product"

    item_id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(255), nullable=False)
    price = db.Column(db.Float, nullable=False)
    quantity = db.Column(db.Integer , nullable=False)
    description = db.Column(db.Unicode(500), index=True, unique=True)
    image_url = db.Column(db.Unicode(128))
    rest_id = db.Column(db.Integer, db.ForeignKey('Restaurant.rest_id'))

    #https://github.com/psthomas/crud-restaurant/blob/master/database_setup.py

    @property
    def json(self):
        return to_json(self, self.__class__)