simplify db model
This commit is contained in:
parent
f616f2c2e1
commit
5fbfe5f33a
2 changed files with 14 additions and 32 deletions
|
@ -236,7 +236,6 @@ class Region(db.Model):
|
|||
pid = db.Column(db.Integer, primary_key=True)
|
||||
inv_servers = db.relationship('Server', backref='region', lazy='dynamic')
|
||||
inv_addresses = db.relationship('Address', backref='region', lazy='dynamic')
|
||||
inv_bridges = db.relationship('Bridge', backref='region', lazy='dynamic')
|
||||
|
||||
enabled = db.Column(db.Boolean)
|
||||
name = db.Column(db.String)
|
||||
|
@ -256,35 +255,13 @@ class Server(db.Model):
|
|||
hdd = db.Column(db.String)
|
||||
address = db.Column(db.String)
|
||||
|
||||
class Bridge(db.Model):
|
||||
__tablename__ = 'bridges'
|
||||
pid = db.Column(db.Integer, primary_key=True)
|
||||
user_id = db.Column(db.ForeignKey('users.pid')) #FK
|
||||
region_id = db.Column(db.ForeignKey('regions.pid')) #FK
|
||||
inv_routers = db.relationship('Router', backref='bridge', lazy='dynamic')
|
||||
inv_deployments = db.relationship('Deployment', backref='bridge', lazy='dynamic')
|
||||
|
||||
date_created = db.Column(db.DateTime, default=datetime.utcnow)
|
||||
deleted = db.Column(db.Boolean, default=False)
|
||||
bridge_id = db.Column(db.String)
|
||||
|
||||
class Router(db.Model):
|
||||
__tablename__ = 'routers'
|
||||
pid = db.Column(db.Integer, primary_key=True)
|
||||
user_id = db.Column(db.ForeignKey('users.pid')) #FK
|
||||
bridge_id = db.Column(db.ForeignKey('bridges.pid')) #FK
|
||||
inv_addresses = db.relationship('Address', backref='router', lazy='dynamic')
|
||||
|
||||
date_created = db.Column(db.DateTime, default=datetime.utcnow)
|
||||
deleted = db.Column(db.Boolean, default=False)
|
||||
|
||||
machine_id = db.Column(db.BigInteger) #unit_id
|
||||
inv_deployments = db.relationship('Deployment', backref='server', lazy='dynamic')
|
||||
|
||||
class Deployment(db.Model):
|
||||
__tablename__ = 'deployments'
|
||||
pid = db.Column(db.Integer, primary_key=True)
|
||||
user_id = db.Column(db.ForeignKey('users.pid')) #FK
|
||||
bridge_id = db.Column(db.ForeignKey('bridges.pid')) #FK
|
||||
server_id = db.Column(db.ForeignKey('servers.pid')) #FK
|
||||
date_created = db.Column(db.DateTime, default=datetime.utcnow)
|
||||
deleted = db.Column(db.Boolean, default=False)
|
||||
|
||||
|
@ -295,6 +272,7 @@ class Deployment(db.Model):
|
|||
period = db.Column(db.Integer)
|
||||
daysleft = db.Column(db.Integer)
|
||||
|
||||
vlan = db.Column(db.Integer)
|
||||
machine_id = db.Column(db.BigInteger) #unit_id
|
||||
machine_alias = db.Column(db.String) #dns name
|
||||
machine_cpu = db.Column(db.Integer)
|
||||
|
@ -302,12 +280,14 @@ class Deployment(db.Model):
|
|||
machine_hdd = db.Column(db.Integer)
|
||||
discount = db.Column(db.Integer)
|
||||
|
||||
inv_addresses = db.relationship('Address', backref='assignee', lazy='dynamic')
|
||||
|
||||
class Address(db.Model):
|
||||
__tablename__ = 'address'
|
||||
pid = db.Column(db.Integer, primary_key=True)
|
||||
user_id = db.Column(db.ForeignKey('users.pid')) #FK
|
||||
region_id = db.Column(db.ForeignKey('regions.pid')) #FK
|
||||
router_id = db.Column(db.ForeignKey('routers.pid')) #FK
|
||||
deployment_id = db.Column(db.ForeignKey('deployments.pid')) #FK
|
||||
date_assigned = db.Column(db.DateTime, default=datetime.utcnow)
|
||||
enabled = db.Column(db.Boolean)
|
||||
|
||||
|
|
|
@ -17,10 +17,11 @@
|
|||
<thead>
|
||||
<tr>
|
||||
<th>IP</th>
|
||||
<th>Reverse DNS</th>
|
||||
<th>Asignee</th>
|
||||
<th>VLAN</th>
|
||||
<th>Slave</th>
|
||||
<th>Region</th>
|
||||
<th>Router</th>
|
||||
<th>Owner</th>
|
||||
<th>rDNS</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -28,10 +29,11 @@
|
|||
<tr>
|
||||
{% if address.enabled == False %}<tr class="danger">{% else %}<tr>{% endif %}
|
||||
<td>{{ address.ip }}</td>
|
||||
<td>{{ address.rdns }}</td>
|
||||
<td>{{ address.assignee.machine_alias }}</td>
|
||||
<td>{{ address.assignee.vlan }}</td>
|
||||
<td>{{ address.server.name }}</td>
|
||||
<td>{{ address.region.name }}</td>
|
||||
<td>{{ address.router.machine_id }}</td>
|
||||
<td>{{ address.owner.email }}</td>
|
||||
<td>{{ address.rdns }}</td>
|
||||
{% endfor %}
|
||||
</tr>
|
||||
</tbody>
|
||||
|
|
Loading…
Reference in a new issue