Model photo upload fixes; network devices linked to catalog models
This commit is contained in:
@@ -49,6 +49,13 @@ class NetworkDevice(BaseModel):
|
||||
)
|
||||
|
||||
# Vendor
|
||||
modelnumberid = db.Column(
|
||||
db.Integer,
|
||||
db.ForeignKey('models.modelnumberid'),
|
||||
nullable=True,
|
||||
comment='Catalog model, which is where the device photo comes from'
|
||||
)
|
||||
|
||||
vendorid = db.Column(
|
||||
db.Integer,
|
||||
db.ForeignKey('vendors.vendorid'),
|
||||
@@ -97,6 +104,7 @@ class NetworkDevice(BaseModel):
|
||||
)
|
||||
networkdevicetype = db.relationship('NetworkDeviceType', backref='networkdevices')
|
||||
vendor = db.relationship('Vendor', backref='network_devices')
|
||||
model = db.relationship('Model', backref='network_devices')
|
||||
|
||||
__table_args__ = (
|
||||
db.Index('idx_netdev_type', 'networkdevicetypeid'),
|
||||
@@ -116,5 +124,11 @@ class NetworkDevice(BaseModel):
|
||||
result['networkdevicetypename'] = self.networkdevicetype.networkdevicetype
|
||||
if self.vendor:
|
||||
result['vendorname'] = self.vendor.vendor
|
||||
# Same shape as machines, PCs and printers: the detail page's hero image
|
||||
# binds to imageurl, and it comes from the catalog model, not the device.
|
||||
if self.model:
|
||||
result['modelname'] = self.model.modelnumber
|
||||
if self.model.imageurl:
|
||||
result['imageurl'] = self.model.imageurl
|
||||
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user