#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 @property
def allocated_status(self): def allocated_status(self):
"""Show the actual status of device for this owner. """Show the actual status of device.
The status depend of one of this 4 actions: The status depend of one of this 3 actions:
- Use - Allocate
- Refurbish - Deallocate
- Recycling - InUse (Live register)
- Management
""" """
from ereuse_devicehub.resources.device import states from ereuse_devicehub.resources.device import states
@ -350,10 +349,11 @@ class Device(Thing):
def physical_status(self): def physical_status(self):
"""Show the actual status of device for this owner. """Show the actual status of device for this owner.
The status depend of one of this 4 actions: The status depend of one of this 4 actions:
- Use - ToPrepare
- Refurbish - Prepare
- Recycling - DataWipe
- Management - ToRepair
- Ready
""" """
from ereuse_devicehub.resources.device import states from ereuse_devicehub.resources.device import states
@ -589,6 +589,20 @@ class Device(Thing):
args[POLYMORPHIC_ON] = cls.type args[POLYMORPHIC_ON] = cls.type
return args 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): def set_hid(self):
with suppress(TypeError): with suppress(TypeError):
self.hid = Naming.hid( self.hid = Naming.hid(

View File

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

View File

@ -154,6 +154,37 @@
</tbody> </tbody>
</table> </table>
</div> </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> <h4>Public traceability log of the device</h4>
<div class="text-right"> <div class="text-right">
<small>Latest one.</small> <small>Latest one.</small>
@ -162,10 +193,14 @@
{% for action in device.public_actions %} {% for action in device.public_actions %}
<li> <li>
<strong> <strong>
{{ action.type }} {{ device.is_status(action) }} {{ action.type }}
</strong> </strong>
{{ action }} {% if device.is_status(action) %}
{{ action }} {{ action.type }}
{% else %}
{{ action }}
{% endif %}
<br> <br>
<div class="text-muted"> <div class="text-muted">
<small> <small>