2018-10-13 12:53:46 +00:00
|
|
|
from enum import Enum
|
|
|
|
|
2018-10-16 09:13:21 +00:00
|
|
|
import inflection
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
from ereuse_devicehub.resources.action import models as e
|
2018-10-13 12:53:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
class State(Enum):
|
2019-03-26 09:55:38 +00:00
|
|
|
"""A mutable property of a device result of applying an
|
|
|
|
:ref:`actions:Action` to it.
|
|
|
|
"""
|
|
|
|
|
2018-10-13 12:53:46 +00:00
|
|
|
@classmethod
|
2019-05-11 14:27:22 +00:00
|
|
|
def actions(cls):
|
|
|
|
"""Actions participating in this state."""
|
2018-10-13 12:53:46 +00:00
|
|
|
return (s.value for s in cls)
|
|
|
|
|
2018-10-16 09:13:21 +00:00
|
|
|
def __str__(self):
|
2018-10-16 14:30:10 +00:00
|
|
|
return inflection.humanize(inflection.underscore(self.name))
|
2018-10-16 09:13:21 +00:00
|
|
|
|
2018-10-13 12:53:46 +00:00
|
|
|
|
|
|
|
class Trading(State):
|
2019-06-19 11:35:26 +00:00
|
|
|
"""Trading states.
|
2019-02-03 16:12:53 +00:00
|
|
|
|
|
|
|
:cvar Reserved: The device has been reserved.
|
2021-03-24 13:17:18 +00:00
|
|
|
:cvar Trade: The devices has been changed of owner.
|
2019-02-03 16:12:53 +00:00
|
|
|
:cvar Cancelled: The device has been cancelled.
|
|
|
|
:cvar Sold: The device has been sold.
|
|
|
|
:cvar Donated: The device is donated.
|
|
|
|
:cvar Renting: The device is in renting
|
|
|
|
:cvar ToBeDisposed: The device is disposed.
|
|
|
|
This is the end of life of a device.
|
|
|
|
:cvar ProductDisposed: The device has been removed
|
|
|
|
from the facility. It does not mean end-of-life.
|
|
|
|
"""
|
2022-05-13 10:17:14 +00:00
|
|
|
|
2018-10-13 12:53:46 +00:00
|
|
|
Reserved = e.Reserve
|
2021-03-24 13:17:18 +00:00
|
|
|
Trade = e.Trade
|
2021-06-03 17:05:57 +00:00
|
|
|
Confirm = e.Confirm
|
|
|
|
Revoke = e.Revoke
|
2018-10-13 12:53:46 +00:00
|
|
|
Cancelled = e.CancelTrade
|
|
|
|
Sold = e.Sell
|
|
|
|
Donated = e.Donate
|
|
|
|
Renting = e.Rent
|
|
|
|
# todo add Pay = e.Pay
|
|
|
|
ToBeDisposed = e.ToDisposeProduct
|
|
|
|
ProductDisposed = e.DisposeProduct
|
2019-07-07 19:36:09 +00:00
|
|
|
Available = e.MakeAvailable
|
2018-10-13 12:53:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Physical(State):
|
2019-06-19 11:35:26 +00:00
|
|
|
"""Physical states.
|
2019-02-03 16:12:53 +00:00
|
|
|
|
|
|
|
: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.
|
2019-07-07 19:36:09 +00:00
|
|
|
:cvar Ready: The device is in working conditions.
|
2022-05-13 10:17:14 +00:00
|
|
|
:cvar DataWipe: Do DataWipe over the device.
|
2019-02-03 16:12:53 +00:00
|
|
|
"""
|
2022-05-13 10:17:14 +00:00
|
|
|
|
2018-10-13 12:53:46 +00:00
|
|
|
ToBeRepaired = e.ToRepair
|
|
|
|
Repaired = e.Repair
|
|
|
|
Preparing = e.ToPrepare
|
|
|
|
Prepared = e.Prepare
|
2019-07-07 19:36:09 +00:00
|
|
|
Ready = e.Ready
|
2022-05-13 10:17:14 +00:00
|
|
|
DataWipe = e.DataWipe
|
2020-11-19 14:25:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Traking(State):
|
|
|
|
"""Traking states.
|
|
|
|
|
|
|
|
:cvar Receive: The device changes hands
|
|
|
|
"""
|
2022-05-13 10:17:14 +00:00
|
|
|
|
2020-11-20 17:16:56 +00:00
|
|
|
# Receive = e.Receive
|
|
|
|
pass
|
2020-11-19 14:25:56 +00:00
|
|
|
|
2022-05-13 10:17:14 +00:00
|
|
|
|
2020-11-19 14:25:56 +00:00
|
|
|
class Usage(State):
|
|
|
|
"""Usage states.
|
|
|
|
|
|
|
|
:cvar Allocate: The device is allocate in other Agent (organization, person ...)
|
2020-11-23 10:43:30 +00:00
|
|
|
:cvar Deallocate: The device is deallocate and return to the owner
|
2022-05-13 10:17:14 +00:00
|
|
|
:cvar InUse: The device is being reported to be in active use.
|
2020-11-19 14:25:56 +00:00
|
|
|
"""
|
2022-05-13 10:17:14 +00:00
|
|
|
|
2020-11-19 14:25:56 +00:00
|
|
|
Allocate = e.Allocate
|
2020-11-23 10:43:30 +00:00
|
|
|
Deallocate = e.Deallocate
|
2018-10-13 12:53:46 +00:00
|
|
|
InUse = e.Live
|
2021-09-28 11:05:58 +00:00
|
|
|
|
2022-05-13 10:17:14 +00:00
|
|
|
|
2021-09-28 11:05:58 +00:00
|
|
|
class Status(State):
|
|
|
|
"""Define status of device for one user.
|
|
|
|
:cvar Use: The device is in use for one final user.
|
|
|
|
:cvar Refurbish: The device is owned by one refurbisher.
|
|
|
|
:cvar Recycling: The device is sended to recycling.
|
|
|
|
:cvar Management: The device is owned by one Manager.
|
|
|
|
"""
|
2022-05-13 10:17:14 +00:00
|
|
|
|
2021-09-28 11:05:58 +00:00
|
|
|
Use = e.Use
|
|
|
|
Refurbish = e.Refurbish
|
|
|
|
Recycling = e.Recycling
|
|
|
|
Management = e.Management
|