#3402 change public page of device

This commit is contained in:
Cayo Puigdefabregas 2022-05-13 17:17:57 +02:00
parent 11913d68c3
commit dd081532ba
3 changed files with 68 additions and 21 deletions

View File

@ -334,12 +334,11 @@ class Device(Thing):
@property
def allocated_status(self):
"""Show the actual status of device for this owner.
The status depend of one of this 4 actions:
- Use
- Refurbish
- Recycling
- Management
"""Show the actual status of device.
The status depend of one of this 3 actions:
- Allocate
- Deallocate
- InUse (Live register)
"""
from ereuse_devicehub.resources.device import states
@ -350,10 +349,11 @@ class Device(Thing):
def physical_status(self):
"""Show the actual status of device for this owner.
The status depend of one of this 4 actions:
- Use
- Refurbish
- Recycling
- Management
- ToPrepare
- Prepare
- DataWipe
- ToRepair
- Ready
"""
from ereuse_devicehub.resources.device import states
@ -589,6 +589,20 @@ class Device(Thing):
args[POLYMORPHIC_ON] = cls.type
return args
def is_status(self, action):
from ereuse_devicehub.resources.device import states
if action.type in states.Usage.__members__:
return "Allocate State: "
if action.type in states.Status.__members__:
return "Lifecycle State: "
if action.type in states.Physical.__members__:
return "Physical State: "
return ""
def set_hid(self):
with suppress(TypeError):
self.hid = Naming.hid(

View File

@ -51,20 +51,18 @@ class Trading(State):
class Physical(State):
"""Physical states.
:cvar ToBeRepaired: The device has been selected for reparation.
:cvar Repaired: The device has been repaired.
:cvar Preparing: The device is going to be or being prepared.
:cvar Prepared: The device has been prepared.
:cvar Repair: The device has been repaired.
:cvar ToPrepare: The device is going to be or being prepared.
:cvar Prepare: The device has been prepared.
:cvar Ready: The device is in working conditions.
:cvar DataWipe: Do DataWipe over the device.
"""
ToBeRepaired = e.ToRepair
Repaired = e.Repair
Preparing = e.ToPrepare
Prepared = e.Prepare
Ready = e.Ready
ToPrepare = e.ToPrepare
Prepare = e.Prepare
DataWipe = e.DataWipe
ToRepair = e.ToRepair
Ready = e.Ready
class Traking(State):

View File

@ -154,6 +154,37 @@
</tbody>
</table>
</div>
<h4>Actual Status</h4>
<ol>
<li>
<strong>
Lifecycle Status
</strong>
{% if device.status %}
{{ device.status.type }}
{% endif %}
</li>
<li>
<strong>
Allocate Status
</strong>
{% if device.allocated_status %}
{{ device.allocated_status.type }}
{% endif %}
</li>
<li>
<strong>
Physical Status
</strong>
{% if device.physical_status %}
{{ device.physical_status.type }}
{% endif %}
</li>
</ol>
<h4>Public traceability log of the device</h4>
<div class="text-right">
<small>Latest one.</small>
@ -162,10 +193,14 @@
{% for action in device.public_actions %}
<li>
<strong>
{{ action.type }}
{{ device.is_status(action) }} {{ action.type }}
</strong>
{{ action }}
{% if device.is_status(action) %}
{{ action }} {{ action.type }}
{% else %}
{{ action }}
{% endif %}
<br>
<div class="text-muted">
<small>