Exemplo n.º 1
0
class Consumer(AppMixin, db.Model):
    id = db.Column(db.Integer, primary_key=True)
    first_name = db.Column(db.String, nullable=False)
    last_name = db.Column(db.String, nullable=False)
    address_id = db.Column(db.Integer, db.ForeignKey('address.id'), nullable=False)
    devices = db.relationship('Device', backref='consumer', lazy='dynamic')
    utility_provider_id = db.Column(db.Integer, db.ForeignKey('utility_provider.id'), nullable=False)
Exemplo n.º 2
0
class Device(AppMixin, db.Model):
    id = db.Column(db.Integer, primary_key=True)
    reference_code = db.Column(db.String, nullable=False)
    meter_reference_code = db.Column(db.String, nullable=True)
    consumer_id = db.Column(db.Integer, db.ForeignKey('consumer.id'), nullable=True)
    utility_provider_id = db.Column(db.Integer, db.ForeignKey('utility_provider.id'), nullable=True)
    is_master = db.Column(db.Boolean, default=False)
    is_slave = db.Column(db.Boolean, default=True)
    transformer_id = db.Column(db.Integer, db.ForeignKey('transformer.id'), nullable=True)
    transformer = db.relationship('Transformer', foreign_keys='Device.transformer_id')
Exemplo n.º 3
0
class UtilityProvider(AppMixin, db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String, nullable=False)
    url = db.Column(db.String, nullable=True)
    devices = db.relationship('Device', backref='utility_provider', lazy='dynamic')
    consumers = db.relationship('Consumer', backref='utility_provider', lazy='dynamic')
Exemplo n.º 4
0
class Country(AppMixin, db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(200))
    code = db.Column(db.String(200))
    states = db.relationship('State', backref='country', lazy='dynamic')
Exemplo n.º 5
0
class State(AppMixin, db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(200))
    code = db.Column(db.String(200))
    country_id = db.Column(db.Integer, db.ForeignKey('country.id'), nullable=False)
    cities = db.relationship('City', backref='state', lazy='dynamic')