#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):
|
with suppress(LookupError, ValueError):
|
||||||
return self.last_action_of(*states.Trading.actions())
|
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
|
@property
|
||||||
def status(self):
|
def status(self):
|
||||||
"""Show the actual status of device for this owner.
|
"""Show the actual status of device for this owner.
|
||||||
|
|
|
@ -33,6 +33,7 @@ class Trading(State):
|
||||||
:cvar ProductDisposed: The device has been removed
|
:cvar ProductDisposed: The device has been removed
|
||||||
from the facility. It does not mean end-of-life.
|
from the facility. It does not mean end-of-life.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
Reserved = e.Reserve
|
Reserved = e.Reserve
|
||||||
Trade = e.Trade
|
Trade = e.Trade
|
||||||
Confirm = e.Confirm
|
Confirm = e.Confirm
|
||||||
|
@ -55,12 +56,15 @@ class Physical(State):
|
||||||
:cvar Preparing: The device is going to be or being prepared.
|
:cvar Preparing: The device is going to be or being prepared.
|
||||||
:cvar Prepared: 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.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
ToBeRepaired = e.ToRepair
|
ToBeRepaired = e.ToRepair
|
||||||
Repaired = e.Repair
|
Repaired = e.Repair
|
||||||
Preparing = e.ToPrepare
|
Preparing = e.ToPrepare
|
||||||
Prepared = e.Prepare
|
Prepared = e.Prepare
|
||||||
Ready = e.Ready
|
Ready = e.Ready
|
||||||
|
DataWipe = e.DataWipe
|
||||||
|
|
||||||
|
|
||||||
class Traking(State):
|
class Traking(State):
|
||||||
|
@ -68,6 +72,7 @@ class Traking(State):
|
||||||
|
|
||||||
:cvar Receive: The device changes hands
|
:cvar Receive: The device changes hands
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Receive = e.Receive
|
# Receive = e.Receive
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -79,6 +84,7 @@ class Usage(State):
|
||||||
:cvar Deallocate: The device is deallocate and return to the owner
|
: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
|
Allocate = e.Allocate
|
||||||
Deallocate = e.Deallocate
|
Deallocate = e.Deallocate
|
||||||
InUse = e.Live
|
InUse = e.Live
|
||||||
|
@ -91,6 +97,7 @@ class Status(State):
|
||||||
:cvar Recycling: The device is sended to recycling.
|
:cvar Recycling: The device is sended to recycling.
|
||||||
:cvar Management: The device is owned by one Manager.
|
:cvar Management: The device is owned by one Manager.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
Use = e.Use
|
Use = e.Use
|
||||||
Refurbish = e.Refurbish
|
Refurbish = e.Refurbish
|
||||||
Recycling = e.Recycling
|
Recycling = e.Recycling
|
||||||
|
|
|
@ -334,7 +334,9 @@
|
||||||
<th scope="col">Title</th>
|
<th scope="col">Title</th>
|
||||||
<th scope="col">DHID</th>
|
<th scope="col">DHID</th>
|
||||||
<th scope="col">Unique Identifiers</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>
|
<th scope="col" data-type="date" data-format="DD-MM-YYYY">Update</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
@ -370,6 +372,8 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</td>
|
</td>
|
||||||
<td>{% if dev.status %}{{ dev.status.type }}{% endif %}</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>
|
<td>{{ dev.updated.strftime('%H:%M %d-%m-%Y') }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
Reference in New Issue