new concept of status abstract of a device
This commit is contained in:
parent
ded8a23075
commit
1996e8fa7a
|
@ -2,6 +2,7 @@ from citext import CIText
|
||||||
from flask import g
|
from flask import g
|
||||||
from sqlalchemy import BigInteger, Column, Sequence, SmallInteger
|
from sqlalchemy import BigInteger, Column, Sequence, SmallInteger
|
||||||
from sqlalchemy.dialects.postgresql import UUID
|
from sqlalchemy.dialects.postgresql import UUID
|
||||||
|
from sqlalchemy.orm import backref
|
||||||
|
|
||||||
from ereuse_devicehub.db import db
|
from ereuse_devicehub.db import db
|
||||||
from ereuse_devicehub.resources.action.models import Snapshot
|
from ereuse_devicehub.resources.action.models import Snapshot
|
||||||
|
@ -56,7 +57,11 @@ class PlaceholdersLog(Thing):
|
||||||
|
|
||||||
placeholder_id = Column(BigInteger, db.ForeignKey(Placeholder.id), nullable=True)
|
placeholder_id = Column(BigInteger, db.ForeignKey(Placeholder.id), nullable=True)
|
||||||
placeholder = db.relationship(
|
placeholder = db.relationship(
|
||||||
Placeholder, primaryjoin=placeholder_id == Placeholder.id
|
Placeholder,
|
||||||
|
backref=backref(
|
||||||
|
'placeholder_logs', lazy=True, cascade="all, delete-orphan", uselist=True
|
||||||
|
),
|
||||||
|
primaryjoin=placeholder_id == Placeholder.id,
|
||||||
)
|
)
|
||||||
owner_id = db.Column(
|
owner_id = db.Column(
|
||||||
UUID(as_uuid=True),
|
UUID(as_uuid=True),
|
||||||
|
|
|
@ -666,6 +666,15 @@ class Device(Thing):
|
||||||
action = next(e for e in reversed(actions) if e.type == 'VisualTest')
|
action = next(e for e in reversed(actions) if e.type == 'VisualTest')
|
||||||
action.functionality_range = value
|
action.functionality_range = value
|
||||||
|
|
||||||
|
def is_abstract(self):
|
||||||
|
if not self.placeholder:
|
||||||
|
return ''
|
||||||
|
if self.placeholder.is_abstract:
|
||||||
|
return 'Abstract'
|
||||||
|
if self.placeholder.binding:
|
||||||
|
return 'Twin'
|
||||||
|
return 'Real'
|
||||||
|
|
||||||
def is_status(self, action):
|
def is_status(self, action):
|
||||||
from ereuse_devicehub.resources.device import states
|
from ereuse_devicehub.resources.device import states
|
||||||
|
|
||||||
|
@ -883,7 +892,9 @@ class Placeholder(Thing):
|
||||||
)
|
)
|
||||||
device = db.relationship(
|
device = db.relationship(
|
||||||
Device,
|
Device,
|
||||||
backref=backref('placeholder', lazy=True, cascade="all, delete-orphan", uselist=False),
|
backref=backref(
|
||||||
|
'placeholder', lazy=True, cascade="all, delete-orphan", uselist=False
|
||||||
|
),
|
||||||
primaryjoin=device_id == Device.id,
|
primaryjoin=device_id == Device.id,
|
||||||
)
|
)
|
||||||
device_id.comment = "datas of the placeholder"
|
device_id.comment = "datas of the placeholder"
|
||||||
|
|
|
@ -448,7 +448,7 @@
|
||||||
{{ dev.binding and dev.binding.phid or dev.placeholder and dev.placeholder.phid or '' }}
|
{{ dev.binding and dev.binding.phid or dev.placeholder and dev.placeholder.phid or '' }}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{{ dev.binding and dev.binding.is_abstract and '✓' or dev.placeholder and dev.placeholder.is_abstract and '✓' or '' }}
|
{{ dev.is_abstract() }}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{% for t in dev.tags | sort(attribute="id") %}
|
{% for t in dev.tags | sort(attribute="id") %}
|
||||||
|
|
Reference in a new issue