This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
devicehub-teal/ereuse_devicehub/resources/device/__init__.py

147 lines
3.0 KiB
Python
Raw Normal View History

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
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):
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):
VIEW = None
SCHEMA = schemas.Computer
2018-04-27 17:16:43 +00:00
class DesktopDef(ComputerDef):
VIEW = None
SCHEMA = schemas.Desktop
2018-04-27 17:16:43 +00:00
class LaptopDef(ComputerDef):
VIEW = None
SCHEMA = schemas.Laptop
2018-04-27 17:16:43 +00:00
class ServerDef(ComputerDef):
VIEW = None
SCHEMA = schemas.Server
2018-04-27 17:16:43 +00:00
2018-06-26 13:35:13 +00:00
class MonitorDef(DeviceDef):
VIEW = None
SCHEMA = schemas.Monitor
2018-04-27 17:16:43 +00:00
2018-06-26 13:35:13 +00:00
class ComputerMonitorDef(MonitorDef):
VIEW = None
SCHEMA = schemas.ComputerMonitor
2018-06-20 21:18:15 +00:00
2018-06-26 13:35:13 +00:00
class TelevisionSetDef(MonitorDef):
VIEW = None
SCHEMA = schemas.TelevisionSet
2018-06-26 13:35:13 +00:00
class MobileDef(DeviceDef):
VIEW = None
SCHEMA = schemas.Mobile
2018-06-26 13:35:13 +00:00
class SmartphoneDef(MobileDef):
VIEW = None
SCHEMA = schemas.Smartphone
2018-06-26 13:35:13 +00:00
class TabletDef(MobileDef):
VIEW = None
SCHEMA = schemas.Tablet
2018-06-26 13:35:13 +00:00
class CellphoneDef(MobileDef):
VIEW = None
SCHEMA = schemas.Cellphone
2018-06-26 13:35:13 +00:00
2018-04-27 17:16:43 +00:00
class ComponentDef(DeviceDef):
VIEW = None
SCHEMA = schemas.Component
2018-04-27 17:16:43 +00:00
class GraphicCardDef(ComponentDef):
VIEW = None
SCHEMA = schemas.GraphicCard
2018-04-27 17:16:43 +00:00
2018-06-10 16:47:49 +00:00
class DataStorageDef(ComponentDef):
VIEW = None
SCHEMA = schemas.DataStorage
2018-06-10 16:47:49 +00:00
class HardDriveDef(DataStorageDef):
VIEW = None
SCHEMA = schemas.HardDrive
2018-04-27 17:16:43 +00:00
2018-06-10 16:47:49 +00:00
class SolidStateDriveDef(DataStorageDef):
VIEW = None
SCHEMA = schemas.SolidStateDrive
2018-06-10 16:47:49 +00:00
2018-04-27 17:16:43 +00:00
class MotherboardDef(ComponentDef):
VIEW = None
SCHEMA = schemas.Motherboard
2018-04-27 17:16:43 +00:00
class NetworkAdapterDef(ComponentDef):
VIEW = None
SCHEMA = schemas.NetworkAdapter
2018-04-27 17:16:43 +00:00
class RamModuleDef(ComponentDef):
VIEW = None
SCHEMA = schemas.RamModule
class ProcessorDef(ComponentDef):
VIEW = None
SCHEMA = schemas.Processor
2018-06-26 13:35:13 +00:00
2018-07-02 10:52:54 +00:00
class SoundCardDef(ComponentDef):
VIEW = None
SCHEMA = schemas.SoundCard
2018-07-02 10:52:54 +00:00
2018-06-26 13:35:13 +00:00
class DisplayDef(ComponentDef):
VIEW = None
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)