#3397 add columns of status in the devices list
This commit is contained in:
parent
5026768eb5
commit
1b5f6412f0
|
@ -332,6 +332,35 @@ class Device(Thing):
|
|||
with suppress(LookupError, ValueError):
|
||||
return self.last_action_of(*states.Trading.actions())
|
||||
|
||||
@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
|
||||
"""
|
||||
from ereuse_devicehub.resources.device import states
|
||||
|
||||
with suppress(LookupError, ValueError):
|
||||
return self.last_action_of(*states.Usage.actions())
|
||||
|
||||
@property
|
||||
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
|
||||
"""
|
||||
from ereuse_devicehub.resources.device import states
|
||||
|
||||
with suppress(LookupError, ValueError):
|
||||
# import pdb; pdb.set_trace()
|
||||
return self.last_action_of(*states.Physical.actions())
|
||||
|
||||
@property
|
||||
def status(self):
|
||||
"""Show the actual status of device for this owner.
|
||||
|
|
|
@ -33,6 +33,7 @@ class Trading(State):
|
|||
:cvar ProductDisposed: The device has been removed
|
||||
from the facility. It does not mean end-of-life.
|
||||
"""
|
||||
|
||||
Reserved = e.Reserve
|
||||
Trade = e.Trade
|
||||
Confirm = e.Confirm
|
||||
|
@ -55,12 +56,15 @@ class Physical(State):
|
|||
:cvar Preparing: The device is going to be or being prepared.
|
||||
:cvar Prepared: 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
|
||||
DataWipe = e.DataWipe
|
||||
|
||||
|
||||
class Traking(State):
|
||||
|
@ -68,22 +72,24 @@ class Traking(State):
|
|||
|
||||
:cvar Receive: The device changes hands
|
||||
"""
|
||||
|
||||
# Receive = e.Receive
|
||||
pass
|
||||
|
||||
|
||||
|
||||
class Usage(State):
|
||||
"""Usage states.
|
||||
|
||||
:cvar Allocate: The device is allocate in other Agent (organization, person ...)
|
||||
:cvar Deallocate: The device is deallocate and return to the owner
|
||||
:cvar InUse: The device is being reported to be in active use.
|
||||
:cvar InUse: The device is being reported to be in active use.
|
||||
"""
|
||||
|
||||
Allocate = e.Allocate
|
||||
Deallocate = e.Deallocate
|
||||
InUse = e.Live
|
||||
|
||||
|
||||
|
||||
class Status(State):
|
||||
"""Define status of device for one user.
|
||||
:cvar Use: The device is in use for one final user.
|
||||
|
@ -91,6 +97,7 @@ class Status(State):
|
|||
:cvar Recycling: The device is sended to recycling.
|
||||
:cvar Management: The device is owned by one Manager.
|
||||
"""
|
||||
|
||||
Use = e.Use
|
||||
Refurbish = e.Refurbish
|
||||
Recycling = e.Recycling
|
||||
|
|
|
@ -334,7 +334,9 @@
|
|||
<th scope="col">Title</th>
|
||||
<th scope="col">DHID</th>
|
||||
<th scope="col">Unique Identifiers</th>
|
||||
<th scope="col">Status</th>
|
||||
<th scope="col">Lifecycle Status</th>
|
||||
<th scope="col">Allocated Status</th>
|
||||
<th scope="col">Physical Status</th>
|
||||
<th scope="col" data-type="date" data-format="DD-MM-YYYY">Update</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
@ -370,6 +372,8 @@
|
|||
{% endfor %}
|
||||
</td>
|
||||
<td>{% if dev.status %}{{ dev.status.type }}{% endif %}</td>
|
||||
<td>{% if dev.allocated_status %}{{ dev.allocated_status.type }}{% endif %}</td>
|
||||
<td>{% if dev.physical_status %}{{ dev.physical_status.type }}{% endif %}</td>
|
||||
<td>{{ dev.updated.strftime('%H:%M %d-%m-%Y') }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
|
Reference in a new issue