Merge pull request #334 from eReuse/feature/3757-backup-dhid-phid-abstract
Feature/3757 backup dhid phid abstract
This commit is contained in:
commit
04297d5437
|
@ -279,6 +279,11 @@ class BindingView(GenericMixin):
|
||||||
self.abstract_dhid = self.old_device.devicehub_id
|
self.abstract_dhid = self.old_device.devicehub_id
|
||||||
self.abstract_phid = self.old_placeholder.phid
|
self.abstract_phid = self.old_placeholder.phid
|
||||||
|
|
||||||
|
# to do a backup of abstract_dhid and abstract_phid in
|
||||||
|
# workbench device
|
||||||
|
self.abstract_device.dhid_bk = self.abstract_dhid
|
||||||
|
self.abstract_device.phid_bk = self.abstract_phid
|
||||||
|
|
||||||
def post(self):
|
def post(self):
|
||||||
for plog in PlaceholdersLog.query.filter_by(
|
for plog in PlaceholdersLog.query.filter_by(
|
||||||
placeholder_id=self.old_placeholder.id
|
placeholder_id=self.old_placeholder.id
|
||||||
|
@ -379,6 +384,17 @@ class UnBindingView(GenericMixin):
|
||||||
c.binding.device.parent = new_device
|
c.binding.device.parent = new_device
|
||||||
|
|
||||||
placeholder = Placeholder(device=new_device, binding=device, is_abstract=True)
|
placeholder = Placeholder(device=new_device, binding=device, is_abstract=True)
|
||||||
|
if (
|
||||||
|
device.dhid_bk
|
||||||
|
and not Device.query.filter_by(devicehub_id=device.dhid_bk).first()
|
||||||
|
):
|
||||||
|
new_device.devicehub_id = device.dhid_bk
|
||||||
|
if (
|
||||||
|
device.phid_bk
|
||||||
|
and not Placeholder.query.filter_by(phid=device.phid_bk).first()
|
||||||
|
):
|
||||||
|
placeholder.phid = device.phid_bk
|
||||||
|
|
||||||
db.session.add(placeholder)
|
db.session.add(placeholder)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
"""backup dhid
|
||||||
|
|
||||||
|
Revision ID: 6b0880832b78
|
||||||
|
Revises: d7ea9a3b2da1
|
||||||
|
Create Date: 2022-09-07 12:53:25.827186
|
||||||
|
|
||||||
|
"""
|
||||||
|
import citext
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from alembic import context, op
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = '6b0880832b78'
|
||||||
|
down_revision = 'd7ea9a3b2da1'
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def get_inv():
|
||||||
|
INV = context.get_x_argument(as_dictionary=True).get('inventory')
|
||||||
|
if not INV:
|
||||||
|
raise ValueError("Inventory value is not specified")
|
||||||
|
return INV
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
op.add_column(
|
||||||
|
'device',
|
||||||
|
sa.Column('dhid_bk', citext.CIText(), unique=False, nullable=True),
|
||||||
|
schema=f'{get_inv()}',
|
||||||
|
)
|
||||||
|
op.add_column(
|
||||||
|
'device',
|
||||||
|
sa.Column('phid_bk', citext.CIText(), unique=False, nullable=True),
|
||||||
|
schema=f'{get_inv()}',
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
op.drop_column('device', 'dhid_bk', schema=f'{get_inv()}')
|
||||||
|
op.drop_column('device', 'phid_bk', schema=f'{get_inv()}')
|
|
@ -173,6 +173,8 @@ class Device(Thing):
|
||||||
db.CIText(), nullable=True, unique=True, default=create_code
|
db.CIText(), nullable=True, unique=True, default=create_code
|
||||||
)
|
)
|
||||||
devicehub_id.comment = "device have a unique code."
|
devicehub_id.comment = "device have a unique code."
|
||||||
|
dhid_bk = db.Column(db.CIText(), nullable=True, unique=False)
|
||||||
|
phid_bk = db.Column(db.CIText(), nullable=True, unique=False)
|
||||||
active = db.Column(Boolean, default=True)
|
active = db.Column(Boolean, default=True)
|
||||||
|
|
||||||
_NON_PHYSICAL_PROPS = {
|
_NON_PHYSICAL_PROPS = {
|
||||||
|
@ -200,6 +202,8 @@ class Device(Thing):
|
||||||
'devicehub_id',
|
'devicehub_id',
|
||||||
'system_uuid',
|
'system_uuid',
|
||||||
'active',
|
'active',
|
||||||
|
'phid_bk',
|
||||||
|
'dhid_bk',
|
||||||
}
|
}
|
||||||
|
|
||||||
__table_args__ = (
|
__table_args__ = (
|
||||||
|
|
|
@ -46,11 +46,11 @@
|
||||||
<h5 class="card-title text-center pb-0 fs-4">Workbench 2022</h5>
|
<h5 class="card-title text-center pb-0 fs-4">Workbench 2022</h5>
|
||||||
<div class="row pt-3">
|
<div class="row pt-3">
|
||||||
<div class="col-5">
|
<div class="col-5">
|
||||||
<a href="{{ iso.demo.url }}/{{ iso.demo.iso }}" class="btn btn-primary">{{ iso.demo.iso }}</a>
|
<a href="{{ iso.demo.url }}{{ iso.demo.iso }}" class="btn btn-primary">{{ iso.demo.iso }}</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<p class="small">
|
<p class="small">
|
||||||
Download Checksum: <a class="help" href="{{ iso.demo.url }}/SHA512SUMS">SHA512SUMS</a> |
|
Download Checksum: <a class="help" href="{{ iso.demo.url }}SHA512SUM">SHA512SUM</a> |
|
||||||
<a href="https://help.usody.com/es/setup/setup-pendrive/" target="_blank" class="help">Help</a></p>
|
<a href="https://help.usody.com/es/setup/setup-pendrive/" target="_blank" class="help">Help</a></p>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
@ -113,14 +113,14 @@
|
||||||
<br />
|
<br />
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-5">
|
<div class="col-5">
|
||||||
<a href="{{ v.url }}/{{ v.iso }}" class="btn btn-primary" style="width: 200px;">Get ISO file</a>
|
<a href="{{ v.url }}{{ v.iso }}" class="btn btn-primary" style="width: 200px;">Get ISO file</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<p class="small">
|
<p class="small">
|
||||||
{{ v.iso }}
|
{{ v.iso }}
|
||||||
</p>
|
</p>
|
||||||
<p class="small">
|
<p class="small">
|
||||||
Download Checksum: <a class="help" href="{{ v.url }}/SHA512SUMS">SHA512SUMS</a> |
|
Download Checksum: <a class="help" href="{{ v.url }}SHA512SUM">SHA512SUM</a> |
|
||||||
<a href="https://help.usody.com/es/setup/setup-pendrive/" target="_blank" class="help">Help</a></p>
|
<a href="https://help.usody.com/es/setup/setup-pendrive/" target="_blank" class="help">Help</a></p>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -9,6 +9,6 @@ isos = {
|
||||||
},
|
},
|
||||||
"v14": {
|
"v14": {
|
||||||
'iso': "USODY_14.0.0.iso",
|
'iso': "USODY_14.0.0.iso",
|
||||||
'url': 'http://releases.usody.com/v14/'
|
'url': 'http://releases.usody.com/v14/',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -2148,6 +2148,8 @@ def test_unbinding(user3: UserClientFlask):
|
||||||
user3.get(uri)
|
user3.get(uri)
|
||||||
|
|
||||||
old_placeholder = dev_wb.binding
|
old_placeholder = dev_wb.binding
|
||||||
|
old_phid = old_placeholder.phid
|
||||||
|
old_dhid = dev_wb.dhid
|
||||||
|
|
||||||
# page binding
|
# page binding
|
||||||
dhid = dev_wb.dhid
|
dhid = dev_wb.dhid
|
||||||
|
@ -2171,7 +2173,8 @@ def test_unbinding(user3: UserClientFlask):
|
||||||
# check new structure
|
# check new structure
|
||||||
|
|
||||||
assert dev.placeholder.binding is None
|
assert dev.placeholder.binding is None
|
||||||
assert dev_wb.binding.phid == '2'
|
assert dev_wb.binding.phid == old_phid
|
||||||
|
assert dev_wb.dhid == old_dhid
|
||||||
assert old_placeholder.device.model == dev_wb.binding.device.model
|
assert old_placeholder.device.model == dev_wb.binding.device.model
|
||||||
assert old_placeholder.device != dev_wb.binding.device
|
assert old_placeholder.device != dev_wb.binding.device
|
||||||
assert Placeholder.query.filter_by(id=old_placeholder.id).first() is None
|
assert Placeholder.query.filter_by(id=old_placeholder.id).first() is None
|
||||||
|
|
Reference in New Issue