put the old dhid in the new placeholder device

This commit is contained in:
Cayo Puigdefabregas 2022-08-10 18:05:18 +02:00
parent f3766e49a8
commit f55abc4a7b
3 changed files with 7 additions and 2 deletions

View File

@ -63,6 +63,9 @@ def clone_device(device):
if device.type == "Battery":
device.size
old_devicehub_id = device.devicehub_id
dict_device = copy.copy(device.__dict__)
dict_device.pop('_sa_instance_state')
dict_device.pop('id', None)
@ -73,6 +76,8 @@ def clone_device(device):
dict_device.pop('tags', None)
dict_device.pop('system_uuid', None)
new_device = device.__class__(**dict_device)
new_device.devicehub_id = old_devicehub_id
device.devicehub_id = None
db.session.add(new_device)
if hasattr(device, 'components'):

View File

@ -276,7 +276,7 @@ class DeviceRow(BaseDeviceRow):
software=snapshot.software.name, version=snapshot.version
)
# General information about device
self['DHID'] = device.devicehub_id
self['DHID'] = self.placeholder.device.devicehub_id
self['DocumentID'] = self.document_id
self['Public Link'] = '{url}{id}'.format(
url=url_for('Device.main', _external=True), id=device.devicehub_id

View File

@ -34,7 +34,7 @@
{% if placeholder.binding %}
<li class="nav-item">
<a class="nav-link" href="{{ url_for('inventory.device_details', id=placeholder.binding.devicehub_id) }}">Workbench device</a>
<a class="nav-link" href="{# url_for('inventory.device_details', id=placeholder.binding.devicehub_id) #}">Workbench device</a>
</li>
{% endif %}