2018-04-27 17:16:43 +00:00
|
|
|
from distutils.version import StrictVersion
|
2018-07-22 20:42:49 +00:00
|
|
|
from itertools import chain
|
2018-06-10 16:47:49 +00:00
|
|
|
from typing import Set
|
2018-04-27 17:16:43 +00:00
|
|
|
|
2018-08-08 19:25:53 +00:00
|
|
|
from ereuse_devicehub.resources import agent, device, event, inventory, lot, tag, user
|
2018-07-14 14:41:22 +00:00
|
|
|
from ereuse_devicehub.resources.enums import PriceSoftware, RatingSoftware
|
2018-06-24 14:57:49 +00:00
|
|
|
from teal.auth import TokenAuth
|
2018-04-10 15:06:39 +00:00
|
|
|
from teal.config import Config
|
2018-08-03 16:15:08 +00:00
|
|
|
from teal.enums import Currency
|
2018-07-22 20:42:49 +00:00
|
|
|
from teal.utils import import_resource
|
2018-04-10 15:06:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
class DevicehubConfig(Config):
|
2018-07-22 20:42:49 +00:00
|
|
|
RESOURCE_DEFINITIONS = set(chain(import_resource(device),
|
|
|
|
import_resource(event),
|
|
|
|
import_resource(user),
|
|
|
|
import_resource(tag),
|
2018-08-03 16:15:08 +00:00
|
|
|
import_resource(inventory),
|
2018-08-08 19:25:53 +00:00
|
|
|
import_resource(agent),
|
|
|
|
import_resource(lot)))
|
2018-06-10 16:47:49 +00:00
|
|
|
PASSWORD_SCHEMES = {'pbkdf2_sha256'} # type: Set[str]
|
2018-06-21 16:10:19 +00:00
|
|
|
SQLALCHEMY_DATABASE_URI = 'postgresql://dhub:ereuse@localhost/devicehub' # type: str
|
2018-07-14 14:41:22 +00:00
|
|
|
SCHEMA = 'dhub'
|
2018-07-02 10:52:54 +00:00
|
|
|
MIN_WORKBENCH = StrictVersion('11.0a1') # type: StrictVersion
|
2018-05-30 10:49:40 +00:00
|
|
|
"""
|
2018-07-14 14:41:22 +00:00
|
|
|
the minimum version of ereuse.org workbench that this devicehub
|
2018-06-26 13:36:21 +00:00
|
|
|
accepts. we recommend not changing this value.
|
2018-05-30 10:49:40 +00:00
|
|
|
"""
|
|
|
|
ORGANIZATION_NAME = None # type: str
|
|
|
|
ORGANIZATION_TAX_ID = None # type: str
|
|
|
|
"""
|
|
|
|
The organization using this Devicehub.
|
|
|
|
|
|
|
|
It is used by default, for example, when creating tags.
|
|
|
|
"""
|
2018-06-24 14:57:49 +00:00
|
|
|
API_DOC_CONFIG_TITLE = 'Devicehub'
|
|
|
|
API_DOC_CONFIG_VERSION = '0.2'
|
|
|
|
API_DOC_CONFIG_COMPONENTS = {
|
|
|
|
'securitySchemes': {
|
|
|
|
'bearerAuth': TokenAuth.API_DOCS
|
|
|
|
}
|
|
|
|
}
|
|
|
|
API_DOC_CLASS_DISCRIMINATOR = 'type'
|
2018-05-30 10:49:40 +00:00
|
|
|
|
2018-07-14 14:41:22 +00:00
|
|
|
WORKBENCH_RATE_SOFTWARE = RatingSoftware.ECost
|
|
|
|
WORKBENCH_RATE_VERSION = StrictVersion('1.0')
|
|
|
|
PHOTOBOX_RATE_SOFTWARE = RatingSoftware.ECost
|
|
|
|
PHOTOBOX_RATE_VERSION = StrictVersion('1.0')
|
|
|
|
"""
|
|
|
|
Official versions for WorkbenchRate and PhotoboxRate
|
|
|
|
"""
|
|
|
|
PRICE_SOFTWARE = PriceSoftware.Ereuse
|
|
|
|
PRICE_VERSION = StrictVersion('1.0')
|
|
|
|
PRICE_CURRENCY = Currency.EUR
|
|
|
|
"""
|
|
|
|
Official versions
|
|
|
|
"""
|
|
|
|
|
2018-05-30 10:49:40 +00:00
|
|
|
def __init__(self, db: str = None) -> None:
|
|
|
|
if not self.ORGANIZATION_NAME or not self.ORGANIZATION_TAX_ID:
|
|
|
|
raise ValueError('You need to set the main organization parameters.')
|
|
|
|
super().__init__(db)
|