modify abstract for snapshot and real for placeholder
This commit is contained in:
parent
d6ed1240a0
commit
a1febe8b3f
|
@ -1671,8 +1671,8 @@ class BindingForm(FlaskForm):
|
|||
self.phid.errors = [txt]
|
||||
return False
|
||||
|
||||
if self.device.is_abstract() not in ['Abstract', 'Real']:
|
||||
txt = "This is not a Abstract or Real device."
|
||||
if self.device.is_abstract() not in ['Snapshot', 'Placeholder']:
|
||||
txt = "This is not a Snapshot or Placeholder device."
|
||||
self.phid.errors = [txt]
|
||||
return False
|
||||
|
||||
|
@ -1686,7 +1686,7 @@ class BindingForm(FlaskForm):
|
|||
self.phid.errors = [txt]
|
||||
return False
|
||||
|
||||
if self.placeholder.status not in ['Abstract', 'Real']:
|
||||
if self.placeholder.status not in ['Snapshot', 'Placeholder']:
|
||||
txt = "This placeholder have a binding with other device. "
|
||||
txt += "Before you need to do an unbinding with this other device."
|
||||
self.phid.errors = [txt]
|
||||
|
|
|
@ -235,9 +235,9 @@ class BindingView(GenericMixin):
|
|||
messages.error('Device Phid: "{}" not exist!'.format(self.phid))
|
||||
return True
|
||||
|
||||
if self.old_device.placeholder.status != 'Abstract':
|
||||
if self.old_device.placeholder.status != 'Snapshot':
|
||||
messages.error(
|
||||
'Device Dhid: "{}" is not a Abstract device!'.format(self.dhid)
|
||||
'Device Dhid: "{}" is not a Snapshot device!'.format(self.dhid)
|
||||
)
|
||||
return True
|
||||
|
||||
|
@ -267,10 +267,10 @@ class BindingView(GenericMixin):
|
|||
if not self.new_placeholder:
|
||||
return
|
||||
|
||||
if self.old_device.placeholder.status == 'Abstract':
|
||||
if self.old_device.placeholder.status == 'Snapshot':
|
||||
self.new_device = self.new_placeholder.device
|
||||
self.old_placeholder = self.old_device.placeholder
|
||||
elif self.old_device.placeholder.status == 'Real':
|
||||
elif self.old_device.placeholder.status == 'Placeholder':
|
||||
self.new_device = self.old_device
|
||||
self.old_placeholder = self.new_placeholder
|
||||
self.old_device = self.old_placeholder.device
|
||||
|
@ -308,8 +308,8 @@ class BindingView(GenericMixin):
|
|||
db.session.commit()
|
||||
|
||||
next_url = url_for('inventory.device_details', id=self.real_dhid)
|
||||
txt = 'Device real with PHID: {} and DHID: {} bind successfully with '
|
||||
txt += 'device abstract PHID: {} DHID: {}.'
|
||||
txt = 'Device placeholder with PHID: {} and DHID: {} bind successfully with '
|
||||
txt += 'device snapshot PHID: {} DHID: {}.'
|
||||
messages.success(
|
||||
txt.format(
|
||||
self.real_phid, self.real_dhid, self.abstract_phid, self.abstract_dhid
|
||||
|
@ -527,7 +527,7 @@ class DeviceCreateView(GenericMixin):
|
|||
|
||||
amount = form.amount.data
|
||||
tpy = form.type.data
|
||||
txt = f'{amount} real Device "{tpy}" created successfully.'
|
||||
txt = f'{amount} placeholders Device "{tpy}" created successfully.'
|
||||
placeholder = (
|
||||
Placeholder.query.filter_by(owner=g.user)
|
||||
.order_by(Placeholder.id.desc())
|
||||
|
@ -536,7 +536,7 @@ class DeviceCreateView(GenericMixin):
|
|||
if amount == 1 and placeholder:
|
||||
phid = placeholder.phid
|
||||
dhid = placeholder.device.devicehub_id
|
||||
txt = f'Device "{tpy}" real with PHID {phid} and DHID {dhid} '
|
||||
txt = f'Device "{tpy}" placeholder with PHID {phid} and DHID {dhid} '
|
||||
txt += 'created successfully'
|
||||
messages.success(txt)
|
||||
return flask.redirect(next_url)
|
||||
|
|
|
@ -683,13 +683,13 @@ class Device(Thing):
|
|||
def is_abstract(self):
|
||||
if self.placeholder:
|
||||
if self.placeholder.is_abstract:
|
||||
return 'Abstract'
|
||||
return 'Snapshot'
|
||||
if self.placeholder.binding:
|
||||
return 'Twin'
|
||||
return 'Real'
|
||||
return 'Placeholder'
|
||||
if self.binding:
|
||||
if self.binding.is_abstract:
|
||||
return 'Abstract'
|
||||
return 'Snapshot'
|
||||
return 'Twin'
|
||||
|
||||
return ''
|
||||
|
@ -952,10 +952,10 @@ class Placeholder(Thing):
|
|||
@property
|
||||
def status(self):
|
||||
if self.is_abstract:
|
||||
return 'Abstract'
|
||||
return 'Snapshot'
|
||||
if self.binding:
|
||||
return 'Twin'
|
||||
return 'Real'
|
||||
return 'Placeholder'
|
||||
|
||||
|
||||
class Computer(Device):
|
||||
|
|
|
@ -252,16 +252,16 @@ class BaseDeviceRow(OrderedDict):
|
|||
self['Benchmark RamSysbench (points)'] = ''
|
||||
# Placeholder
|
||||
self['PHID'] = ''
|
||||
self['Is Abstract'] = ''
|
||||
self['Is Snapshot'] = ''
|
||||
self['Pallet'] = ''
|
||||
self['id Supplier'] = ''
|
||||
self['Real Info'] = ''
|
||||
self['Real Components'] = ''
|
||||
self['Real Type'] = ''
|
||||
self['Real Serial Number'] = ''
|
||||
self['Real Part Number'] = ''
|
||||
self['Real Model'] = ''
|
||||
self['Real Manufacturer'] = ''
|
||||
self['Placeholder Info'] = ''
|
||||
self['Placeholder Components'] = ''
|
||||
self['Placeholder Type'] = ''
|
||||
self['Placeholder Serial Number'] = ''
|
||||
self['Placeholder Part Number'] = ''
|
||||
self['Placeholder Model'] = ''
|
||||
self['Placeholder Manufacturer'] = ''
|
||||
|
||||
|
||||
class DeviceRow(BaseDeviceRow):
|
||||
|
@ -506,16 +506,20 @@ class DeviceRow(BaseDeviceRow):
|
|||
def get_placeholder_datas(self):
|
||||
# Placeholder
|
||||
self['PHID'] = none2str(self.placeholder.phid)
|
||||
self['Is Abstract'] = none2str(self.device.is_abstract())
|
||||
self['Is Snapshot'] = none2str(self.device.is_abstract())
|
||||
self['Pallet'] = none2str(self.placeholder.pallet)
|
||||
self['id Supplier'] = none2str(self.placeholder.id_device_supplier)
|
||||
self['Real Info'] = none2str(self.placeholder.info)
|
||||
self['Real Components'] = none2str(self.placeholder.components)
|
||||
self['Real Type'] = none2str(self.placeholder.device.type)
|
||||
self['Real Manufacturer'] = none2str(self.placeholder.device.manufacturer)
|
||||
self['Real Model'] = none2str(self.placeholder.device.model)
|
||||
self['Real Part Number'] = none2str(self.placeholder.device.part_number)
|
||||
self['Real Serial Number'] = none2str(self.placeholder.device.serial_number)
|
||||
self['Placeholder Info'] = none2str(self.placeholder.info)
|
||||
self['Placeholder Components'] = none2str(self.placeholder.components)
|
||||
self['Placeholder Type'] = none2str(self.placeholder.device.type)
|
||||
self['Placeholder Manufacturer'] = none2str(
|
||||
self.placeholder.device.manufacturer
|
||||
)
|
||||
self['Placeholder Model'] = none2str(self.placeholder.device.model)
|
||||
self['Placeholder Part Number'] = none2str(self.placeholder.device.part_number)
|
||||
self['Placeholder Serial Number'] = none2str(
|
||||
self.placeholder.device.serial_number
|
||||
)
|
||||
|
||||
|
||||
class StockRow(OrderedDict):
|
||||
|
|
|
@ -23,15 +23,15 @@
|
|||
<p>This is a binding between:
|
||||
<ul>
|
||||
{% if new_placeholder.is_abstract %}
|
||||
<li>1. Device abstract with DHID:<b>{{ new_placeholder.device.devicehub_id }}</b> and PHID: <b>{{ new_placeholder.phid }}</b></li>
|
||||
<li>2. Device real with DHID: <b>{{ old_placeholder.device.devicehub_id }}</b> and PHID:<b>{{ old_placeholder.phid }}</b></li>
|
||||
<li>1. Device snapshot with DHID:<b>{{ new_placeholder.device.devicehub_id }}</b> and PHID: <b>{{ new_placeholder.phid }}</b></li>
|
||||
<li>2. Device placeholder with DHID: <b>{{ old_placeholder.device.devicehub_id }}</b> and PHID:<b>{{ old_placeholder.phid }}</b></li>
|
||||
{% else %}
|
||||
<li>1. Device abstract with DHID:<b>{{ old_placeholder.device.devicehub_id }}</b> and PHID: <b>{{ old_placeholder.phid }}</b></li>
|
||||
<li>2. Device real with DHID: <b>{{ new_placeholder.device.devicehub_id }}</b> and PHID:<b>{{ new_placeholder.phid }}</b></li>
|
||||
<li>1. Device snapshot with DHID:<b>{{ old_placeholder.device.devicehub_id }}</b> and PHID: <b>{{ old_placeholder.phid }}</b></li>
|
||||
<li>2. Device placeholder with DHID: <b>{{ new_placeholder.device.devicehub_id }}</b> and PHID:<b>{{ new_placeholder.phid }}</b></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</p>
|
||||
<p>The DHID and PHID information of the abstract will be lost.</p>
|
||||
<p>The DHID and PHID information of the snapshot will be lost.</p>
|
||||
<p>The information in <span class="text-danger">red colour</span> will be losted and replaced by the information in <span class="text-success">green colour</span>.<br />
|
||||
The information in <span class="text-warning">orange</span> will be replaced by the information in <span class="text-success">green</span> and you always can recover
|
||||
it by doing an unbinding action or find this information into device details web.
|
||||
|
@ -43,7 +43,7 @@
|
|||
<tr class="text-center">
|
||||
<th scope="col">Basic Data</th>
|
||||
<th scope="col">Info Twin device</th>
|
||||
<th scope="col">Info Abstract device</th>
|
||||
<th scope="col">Info Snapshot device</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -128,7 +128,7 @@
|
|||
<thead>
|
||||
<tr class="text-center">
|
||||
<th scope="col">Info Twin device</th>
|
||||
<th scope="col">Info Abstract device</th>
|
||||
<th scope="col">Info Snapshot device</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -153,13 +153,13 @@
|
|||
{% if actions %}
|
||||
<h2>Actions</h2>
|
||||
<p>
|
||||
The actions will become real device and will no longer be in the abstract
|
||||
The actions will become placeholder device and will no longer be in the snapshot
|
||||
</p>
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr class="text-center">
|
||||
<th scope="col">Info Twin device</th>
|
||||
<th scope="col">Info Abstract device</th>
|
||||
<th scope="col">Info Snapshot device</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -181,13 +181,13 @@
|
|||
{% if tags %}
|
||||
<h2>Tags</h2>
|
||||
<p>
|
||||
The tags will become real device and will no longer be in the abstract
|
||||
The tags will become placeholder device and will no longer be in the snapshot
|
||||
</p>
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr class="text-center">
|
||||
<th scope="col">Info Twin device</th>
|
||||
<th scope="col">Info Abstract device</th>
|
||||
<th scope="col">Info Snapshot device</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
{% if placeholder.status in ['Abstract', 'Real'] %}
|
||||
{% if placeholder.status in ['Snapshot', 'Placeholder'] %}
|
||||
<a type="button" href="{{ url_for('inventory.binding_search', dhid=placeholder.device.devicehub_id) }}" class="btn btn-primary" style="float: right; margin-right: 15px;">
|
||||
New Twin
|
||||
</a>
|
||||
|
@ -232,13 +232,13 @@
|
|||
</div>
|
||||
|
||||
<div class="tab-pane fade profile-overview" id="components">
|
||||
<h5 class="card-title">Components Real part</h5>
|
||||
<h5 class="card-title">Components Placeholder</h5>
|
||||
<div class="list-group col-6">
|
||||
{{ placeholder.components or '' }}
|
||||
</div>
|
||||
|
||||
{% if placeholder.binding %}
|
||||
<h5 class="card-title">Components Abstract part</h5>
|
||||
<h5 class="card-title">Components Snapshot</h5>
|
||||
<div class="list-group col-6">
|
||||
{% for component in placeholder.binding.components|sort(attribute='type') %}
|
||||
<div class="list-group-item">
|
||||
|
|
|
@ -291,7 +291,7 @@
|
|||
<div class="btn-group dropdown m-1" uib-dropdown="">
|
||||
<button id="btnSnapshot" type="button" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<i class="bi bi-laptop"></i>
|
||||
New Devices Real
|
||||
New Devices Placeholders
|
||||
</button>
|
||||
<ul class="dropdown-menu" aria-labelledby="btnSnapshot">
|
||||
<li>
|
||||
|
@ -301,7 +301,7 @@
|
|||
<a href="{{ url_for('inventory.upload_placeholder') }}" class="dropdown-item">
|
||||
{% endif %}
|
||||
<i class="bi bi-upload"></i>
|
||||
Upload Placeholder Spreadsheet
|
||||
Upload Spreadsheet
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
|
@ -311,7 +311,7 @@
|
|||
<a href="{{ url_for('inventory.device_add') }}" class="dropdown-item">
|
||||
{% endif %}
|
||||
<i class="bi bi-plus"></i>
|
||||
Create a new Placeholder
|
||||
Create a new
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -320,7 +320,7 @@
|
|||
<div class="btn-group dropdown m-1" uib-dropdown="">
|
||||
<button id="btnSnapshot" type="button" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<i class="bi bi-laptop"></i>
|
||||
New Devices Abstract
|
||||
New Devices Snapshot
|
||||
</button>
|
||||
<ul class="dropdown-menu" aria-labelledby="btnSnapshot">
|
||||
<li>
|
||||
|
@ -330,7 +330,7 @@
|
|||
<a href="{{ url_for('inventory.upload_snapshot') }}" class="dropdown-item">
|
||||
{% endif %}
|
||||
<i class="bi bi-upload"></i>
|
||||
Upload Snapshot files
|
||||
Upload files
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
|
@ -201,7 +201,7 @@
|
|||
<div class="btn-group dropdown m-1" uib-dropdown="">
|
||||
<button id="btnSnapshot" type="button" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<i class="bi bi-laptop"></i>
|
||||
New Device Real
|
||||
New Device Placeholder
|
||||
</button>
|
||||
<ul class="dropdown-menu" aria-labelledby="btnSnapshot">
|
||||
<li>
|
||||
|
@ -211,7 +211,7 @@
|
|||
<a href="{{ url_for('inventory.upload_placeholder') }}" class="dropdown-item">
|
||||
{% endif %}
|
||||
<i class="bi bi-upload"></i>
|
||||
Upload Placeholder Spreadsheet
|
||||
Upload Spreadsheet
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
|
@ -221,7 +221,7 @@
|
|||
<a href="{{ url_for('inventory.device_add') }}" class="dropdown-item">
|
||||
{% endif %}
|
||||
<i class="bi bi-plus"></i>
|
||||
Create a new Placeholder
|
||||
Create a new
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -230,7 +230,7 @@
|
|||
<div class="btn-group dropdown m-1" uib-dropdown="">
|
||||
<button id="btnSnapshot" type="button" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<i class="bi bi-laptop"></i>
|
||||
New Device Abstract
|
||||
New Device Snapshot
|
||||
</button>
|
||||
<ul class="dropdown-menu" aria-labelledby="btnSnapshot">
|
||||
<li>
|
||||
|
@ -240,7 +240,7 @@
|
|||
<a href="{{ url_for('inventory.upload_snapshot') }}" class="dropdown-item">
|
||||
{% endif %}
|
||||
<i class="bi bi-upload"></i>
|
||||
Upload Snapshot files
|
||||
Upload files
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
|
@ -26,8 +26,8 @@
|
|||
<thead>
|
||||
<tr class="text-center">
|
||||
<th scope="col">Basic Data</th>
|
||||
<th scope="col">Info Abstract device</th>
|
||||
<th scope="col">Info Real device</th>
|
||||
<th scope="col">Info Snapshot device</th>
|
||||
<th scope="col">Info Placeholder device</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -111,8 +111,8 @@
|
|||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr class="text-center">
|
||||
<th scope="col">Info Abstract device</th>
|
||||
<th scope="col">Info Real device</th>
|
||||
<th scope="col">Info Snapshot device</th>
|
||||
<th scope="col">Info Placeholder device</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -132,13 +132,13 @@
|
|||
{% if placeholder.device.manual_actions or placeholder.binding.manual_actions %}
|
||||
<h2>Actions</h2>
|
||||
<p>
|
||||
The actions will become real device and will no longer be in the abstract
|
||||
The actions will become placeholder device and will no longer be in the placeholder
|
||||
</p>
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr class="text-center">
|
||||
<th scope="col">Info Abstract device</th>
|
||||
<th scope="col">Info Real device</th>
|
||||
<th scope="col">Info Snapshot device</th>
|
||||
<th scope="col">Info Placeholder device</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -161,13 +161,13 @@
|
|||
{% if placeholder.device.tags %}
|
||||
<h2>Tags</h2>
|
||||
<p>
|
||||
The tags will become real device and will no longer be in the abstract
|
||||
The tags will become placeholder device and will no longer be in the placeholder
|
||||
</p>
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr class="text-center">
|
||||
<th scope="col">Info Abstract device</th>
|
||||
<th scope="col">Info Real device</th>
|
||||
<th scope="col">Info Snapshot device</th>
|
||||
<th scope="col">Info Placeholder device</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -457,7 +457,7 @@ def test_add_monitor(user3: UserClientFlask):
|
|||
assert phid == '1'
|
||||
assert dhid == 'O48N2'
|
||||
|
||||
txt = f'Device "{typ}" real with PHID {phid} and DHID {dhid} '
|
||||
txt = f'Device "{typ}" placeholder with PHID {phid} and DHID {dhid} '
|
||||
txt += 'created successfully'
|
||||
assert txt in body
|
||||
|
||||
|
@ -500,7 +500,7 @@ def test_update_monitor(user3: UserClientFlask):
|
|||
assert dev.depth == 0.1
|
||||
assert dev.placeholder.pallet == "l34"
|
||||
|
||||
txt = f'Device "{typ}" real with PHID {phid} and DHID {dhid} '
|
||||
txt = f'Device "{typ}" placeholder with PHID {phid} and DHID {dhid} '
|
||||
txt += 'created successfully'
|
||||
assert txt in body
|
||||
|
||||
|
@ -569,7 +569,7 @@ def test_add_2_monitor(user3: UserClientFlask):
|
|||
assert dev.model == 'lc27t55'
|
||||
assert dev.placeholder.pallet == "l34"
|
||||
|
||||
txt = f'Device "{typ}" real with PHID {phid} and DHID {dhid} '
|
||||
txt = f'Device "{typ}" placeholder with PHID {phid} and DHID {dhid} '
|
||||
txt += 'created successfully'
|
||||
assert txt in body
|
||||
|
||||
|
@ -603,7 +603,7 @@ def test_add_2_monitor(user3: UserClientFlask):
|
|||
|
||||
assert dhid == 'E39W3'
|
||||
|
||||
txt = f'Device "{typ}" real with PHID {phid} and DHID {dhid} '
|
||||
txt = f'Device "{typ}" placeholder with PHID {phid} and DHID {dhid} '
|
||||
txt += 'created successfully'
|
||||
assert txt in body
|
||||
|
||||
|
@ -642,7 +642,7 @@ def test_add_laptop(user3: UserClientFlask):
|
|||
assert phid == '1'
|
||||
assert dhid == 'O48N2'
|
||||
|
||||
txt = f'Device "{typ}" real with PHID {phid} and DHID {dhid} '
|
||||
txt = f'Device "{typ}" placeholder with PHID {phid} and DHID {dhid} '
|
||||
txt += 'created successfully'
|
||||
assert txt in body
|
||||
|
||||
|
@ -672,7 +672,7 @@ def test_add_with_ammount_laptops(user3: UserClientFlask):
|
|||
}
|
||||
body, status = user3.post(uri, data=data)
|
||||
assert status == '200 OK'
|
||||
assert f'{num} real Device "Laptop" created successfully.' in body
|
||||
assert f'{num} placeholders Device "Laptop" created successfully.' in body
|
||||
|
||||
for dev in Device.query.all():
|
||||
assert dev.type == 'Laptop'
|
||||
|
@ -1798,7 +1798,7 @@ def test_edit_laptop(user3: UserClientFlask):
|
|||
assert phid == '1'
|
||||
assert dhid == 'O48N2'
|
||||
|
||||
txt = f'Device "{typ}" real with PHID {phid} and DHID {dhid} '
|
||||
txt = f'Device "{typ}" placeholder with PHID {phid} and DHID {dhid} '
|
||||
txt += 'created successfully'
|
||||
assert txt in body
|
||||
|
||||
|
@ -2116,8 +2116,8 @@ def test_manual_binding(user3: UserClientFlask):
|
|||
# action binding
|
||||
body, status = user3.post(uri, data={})
|
||||
assert status == '200 OK'
|
||||
txt = f"Device real with PHID: {phid_real} and DHID: {dhid_real} "
|
||||
txt += f"bind successfully with device abstract PHID: {phid_abstract} DHID: {dhid_abstract}."
|
||||
txt = f"Device placeholder with PHID: {phid_real} and DHID: {dhid_real} "
|
||||
txt += f"bind successfully with device snapshot PHID: {phid_abstract} DHID: {dhid_abstract}."
|
||||
assert txt in body
|
||||
|
||||
# check new structure
|
||||
|
|
Reference in a new issue