2018-10-03 12:51:22 +00:00
|
|
|
from typing import Callable, Iterable, Tuple
|
|
|
|
|
2018-09-07 10:38:02 +00:00
|
|
|
from teal.resource import Converters, Resource
|
|
|
|
|
2018-07-22 20:42:49 +00:00
|
|
|
from ereuse_devicehub.resources.device import schemas
|
2018-09-30 17:40:28 +00:00
|
|
|
from ereuse_devicehub.resources.device.models import Manufacturer
|
|
|
|
from ereuse_devicehub.resources.device.views import DeviceView, ManufacturerView
|
2018-04-10 15:06:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
class DeviceDef(Resource):
|
2018-07-22 20:42:49 +00:00
|
|
|
SCHEMA = schemas.Device
|
2018-04-10 15:06:39 +00:00
|
|
|
VIEW = DeviceView
|
|
|
|
ID_CONVERTER = Converters.int
|
2018-10-03 12:51:22 +00:00
|
|
|
AUTH = False # We manage this at each view
|
|
|
|
|
|
|
|
def __init__(self, app,
|
|
|
|
import_name=__name__, static_folder=None,
|
|
|
|
static_url_path=None,
|
|
|
|
template_folder='templates',
|
|
|
|
url_prefix=None,
|
|
|
|
subdomain=None,
|
|
|
|
url_defaults=None,
|
|
|
|
root_path=None,
|
|
|
|
cli_commands: Iterable[Tuple[Callable, str or None]] = tuple()):
|
|
|
|
super().__init__(app, import_name, static_folder, static_url_path, template_folder,
|
|
|
|
url_prefix, subdomain, url_defaults, root_path, cli_commands)
|
2018-04-27 17:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ComputerDef(DeviceDef):
|
2018-06-24 14:57:49 +00:00
|
|
|
VIEW = None
|
2018-07-22 20:42:49 +00:00
|
|
|
SCHEMA = schemas.Computer
|
2018-04-27 17:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
class DesktopDef(ComputerDef):
|
2018-06-24 14:57:49 +00:00
|
|
|
VIEW = None
|
2018-07-22 20:42:49 +00:00
|
|
|
SCHEMA = schemas.Desktop
|
2018-04-27 17:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
class LaptopDef(ComputerDef):
|
2018-06-24 14:57:49 +00:00
|
|
|
VIEW = None
|
2018-07-22 20:42:49 +00:00
|
|
|
SCHEMA = schemas.Laptop
|
2018-04-27 17:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ServerDef(ComputerDef):
|
2018-06-24 14:57:49 +00:00
|
|
|
VIEW = None
|
2018-07-22 20:42:49 +00:00
|
|
|
SCHEMA = schemas.Server
|
2018-04-27 17:16:43 +00:00
|
|
|
|
|
|
|
|
2018-06-26 13:35:13 +00:00
|
|
|
class MonitorDef(DeviceDef):
|
2018-06-24 14:57:49 +00:00
|
|
|
VIEW = None
|
2018-07-22 20:42:49 +00:00
|
|
|
SCHEMA = schemas.Monitor
|
2018-04-27 17:16:43 +00:00
|
|
|
|
|
|
|
|
2018-06-26 13:35:13 +00:00
|
|
|
class ComputerMonitorDef(MonitorDef):
|
2018-06-24 14:57:49 +00:00
|
|
|
VIEW = None
|
2018-07-22 20:42:49 +00:00
|
|
|
SCHEMA = schemas.ComputerMonitor
|
2018-06-20 21:18:15 +00:00
|
|
|
|
|
|
|
|
2018-06-26 13:35:13 +00:00
|
|
|
class TelevisionSetDef(MonitorDef):
|
|
|
|
VIEW = None
|
2018-07-22 20:42:49 +00:00
|
|
|
SCHEMA = schemas.TelevisionSet
|
2018-06-26 13:35:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
class MobileDef(DeviceDef):
|
|
|
|
VIEW = None
|
2018-07-22 20:42:49 +00:00
|
|
|
SCHEMA = schemas.Mobile
|
2018-06-26 13:35:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
class SmartphoneDef(MobileDef):
|
|
|
|
VIEW = None
|
2018-07-22 20:42:49 +00:00
|
|
|
SCHEMA = schemas.Smartphone
|
2018-06-26 13:35:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
class TabletDef(MobileDef):
|
|
|
|
VIEW = None
|
2018-07-22 20:42:49 +00:00
|
|
|
SCHEMA = schemas.Tablet
|
2018-06-26 13:35:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
class CellphoneDef(MobileDef):
|
|
|
|
VIEW = None
|
2018-07-22 20:42:49 +00:00
|
|
|
SCHEMA = schemas.Cellphone
|
2018-06-26 13:35:13 +00:00
|
|
|
|
|
|
|
|
2018-04-27 17:16:43 +00:00
|
|
|
class ComponentDef(DeviceDef):
|
2018-06-24 14:57:49 +00:00
|
|
|
VIEW = None
|
2018-07-22 20:42:49 +00:00
|
|
|
SCHEMA = schemas.Component
|
2018-04-27 17:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
class GraphicCardDef(ComponentDef):
|
2018-06-24 14:57:49 +00:00
|
|
|
VIEW = None
|
2018-07-22 20:42:49 +00:00
|
|
|
SCHEMA = schemas.GraphicCard
|
2018-04-27 17:16:43 +00:00
|
|
|
|
|
|
|
|
2018-06-10 16:47:49 +00:00
|
|
|
class DataStorageDef(ComponentDef):
|
2018-06-24 14:57:49 +00:00
|
|
|
VIEW = None
|
2018-07-22 20:42:49 +00:00
|
|
|
SCHEMA = schemas.DataStorage
|
2018-06-10 16:47:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
class HardDriveDef(DataStorageDef):
|
2018-06-24 14:57:49 +00:00
|
|
|
VIEW = None
|
2018-07-22 20:42:49 +00:00
|
|
|
SCHEMA = schemas.HardDrive
|
2018-04-27 17:16:43 +00:00
|
|
|
|
|
|
|
|
2018-06-10 16:47:49 +00:00
|
|
|
class SolidStateDriveDef(DataStorageDef):
|
2018-06-24 14:57:49 +00:00
|
|
|
VIEW = None
|
2018-07-22 20:42:49 +00:00
|
|
|
SCHEMA = schemas.SolidStateDrive
|
2018-06-10 16:47:49 +00:00
|
|
|
|
|
|
|
|
2018-04-27 17:16:43 +00:00
|
|
|
class MotherboardDef(ComponentDef):
|
2018-06-24 14:57:49 +00:00
|
|
|
VIEW = None
|
2018-07-22 20:42:49 +00:00
|
|
|
SCHEMA = schemas.Motherboard
|
2018-04-27 17:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
class NetworkAdapterDef(ComponentDef):
|
2018-06-24 14:57:49 +00:00
|
|
|
VIEW = None
|
2018-07-22 20:42:49 +00:00
|
|
|
SCHEMA = schemas.NetworkAdapter
|
2018-04-27 17:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
class RamModuleDef(ComponentDef):
|
2018-06-24 14:57:49 +00:00
|
|
|
VIEW = None
|
2018-07-22 20:42:49 +00:00
|
|
|
SCHEMA = schemas.RamModule
|
2018-05-11 16:58:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ProcessorDef(ComponentDef):
|
2018-06-24 14:57:49 +00:00
|
|
|
VIEW = None
|
2018-07-22 20:42:49 +00:00
|
|
|
SCHEMA = schemas.Processor
|
2018-06-26 13:35:13 +00:00
|
|
|
|
|
|
|
|
2018-07-02 10:52:54 +00:00
|
|
|
class SoundCardDef(ComponentDef):
|
|
|
|
VIEW = None
|
2018-07-22 20:42:49 +00:00
|
|
|
SCHEMA = schemas.SoundCard
|
2018-07-02 10:52:54 +00:00
|
|
|
|
|
|
|
|
2018-06-26 13:35:13 +00:00
|
|
|
class DisplayDef(ComponentDef):
|
|
|
|
VIEW = None
|
2018-07-22 20:42:49 +00:00
|
|
|
SCHEMA = schemas.Display
|
2018-09-30 17:40:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ManufacturerDef(Resource):
|
|
|
|
VIEW = ManufacturerView
|
|
|
|
SCHEMA = schemas.Manufacturer
|
|
|
|
AUTH = True
|
|
|
|
|
|
|
|
def init_db(self, db: 'db.SQLAlchemy'):
|
|
|
|
"""Loads the manufacturers to the database."""
|
|
|
|
Manufacturer.add_all_to_session(db.session)
|