diff --git a/ereuse_devicehub/resources/device/models.py b/ereuse_devicehub/resources/device/models.py index 70ce4e3d..746ce2b8 100644 --- a/ereuse_devicehub/resources/device/models.py +++ b/ereuse_devicehub/resources/device/models.py @@ -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( diff --git a/ereuse_devicehub/resources/device/states.py b/ereuse_devicehub/resources/device/states.py index 99603f2a..30578704 100644 --- a/ereuse_devicehub/resources/device/states.py +++ b/ereuse_devicehub/resources/device/states.py @@ -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): diff --git a/ereuse_devicehub/resources/device/templates/devices/layout.html b/ereuse_devicehub/resources/device/templates/devices/layout.html index de46ecf3..716d3159 100644 --- a/ereuse_devicehub/resources/device/templates/devices/layout.html +++ b/ereuse_devicehub/resources/device/templates/devices/layout.html @@ -154,6 +154,37 @@ +

Actual Status

+
    +
  1. + + Lifecycle Status + + — + {% if device.status %} + {{ device.status.type }} + {% endif %} +
  2. +
  3. + + Allocate Status + + — + {% if device.allocated_status %} + {{ device.allocated_status.type }} + {% endif %} +
  4. +
  5. + + Physical Status + + — + {% if device.physical_status %} + {{ device.physical_status.type }} + {% endif %} +
  6. +
+

Public traceability log of the device

Latest one. @@ -162,10 +193,14 @@ {% for action in device.public_actions %}
  • - {{ action.type }} + {{ device.is_status(action) }} {{ action.type }} — - {{ action }} + {% if device.is_status(action) %} + {{ action }} {{ action.type }} + {% else %} + {{ action }} + {% endif %}