diff --git a/ereuse_devicehub/auth.py b/ereuse_devicehub/auth.py index baa23885..5820c326 100644 --- a/ereuse_devicehub/auth.py +++ b/ereuse_devicehub/auth.py @@ -1,9 +1,9 @@ from sqlalchemy.exc import DataError +from teal.auth import TokenAuth +from teal.db import ResourceNotFound from werkzeug.exceptions import Unauthorized from ereuse_devicehub.resources.user.models import User -from teal.auth import TokenAuth -from teal.db import ResourceNotFound class Auth(TokenAuth): diff --git a/ereuse_devicehub/client.py b/ereuse_devicehub/client.py index 420e6388..7aa538aa 100644 --- a/ereuse_devicehub/client.py +++ b/ereuse_devicehub/client.py @@ -1,13 +1,13 @@ from inspect import isclass from typing import Any, Dict, Iterable, Tuple, Type, Union +from ereuse_utils.test import JSON from flask import Response +from teal.client import Client as TealClient +from teal.marshmallow import ValidationError from werkzeug.exceptions import HTTPException from ereuse_devicehub.resources import models, schemas -from ereuse_utils.test import JSON -from teal.client import Client as TealClient -from teal.marshmallow import ValidationError class Client(TealClient): diff --git a/ereuse_devicehub/config.py b/ereuse_devicehub/config.py index a0505213..936ed280 100644 --- a/ereuse_devicehub/config.py +++ b/ereuse_devicehub/config.py @@ -2,13 +2,14 @@ from distutils.version import StrictVersion from itertools import chain from typing import Set -from ereuse_devicehub.resources import agent, device, event, inventory, lot, tag, user -from ereuse_devicehub.resources.enums import PriceSoftware, RatingSoftware from teal.auth import TokenAuth from teal.config import Config from teal.enums import Currency from teal.utils import import_resource +from ereuse_devicehub.resources import agent, device, event, inventory, lot, tag, user +from ereuse_devicehub.resources.enums import PriceSoftware, RatingSoftware + class DevicehubConfig(Config): RESOURCE_DEFINITIONS = set(chain(import_resource(device), diff --git a/ereuse_devicehub/devicehub.py b/ereuse_devicehub/devicehub.py index a99cc8e3..915fcde1 100644 --- a/ereuse_devicehub/devicehub.py +++ b/ereuse_devicehub/devicehub.py @@ -1,13 +1,13 @@ from typing import Type from flask_sqlalchemy import SQLAlchemy +from teal.config import Config as ConfigClass +from teal.teal import Teal from ereuse_devicehub.auth import Auth from ereuse_devicehub.client import Client from ereuse_devicehub.db import db from ereuse_devicehub.dummy.dummy import Dummy -from teal.config import Config as ConfigClass -from teal.teal import Teal class Devicehub(Teal): diff --git a/ereuse_devicehub/marshmallow.py b/ereuse_devicehub/marshmallow.py index c21d240d..2ff78d99 100644 --- a/ereuse_devicehub/marshmallow.py +++ b/ereuse_devicehub/marshmallow.py @@ -1,9 +1,9 @@ from marshmallow.fields import missing_ - -from ereuse_devicehub.db import db from teal.db import SQLAlchemy from teal.marshmallow import NestedOn as TealNestedOn +from ereuse_devicehub.db import db + class NestedOn(TealNestedOn): __doc__ = TealNestedOn.__doc__ diff --git a/ereuse_devicehub/resources/agent/__init__.py b/ereuse_devicehub/resources/agent/__init__.py index c85167f2..ac4e6169 100644 --- a/ereuse_devicehub/resources/agent/__init__.py +++ b/ereuse_devicehub/resources/agent/__init__.py @@ -1,10 +1,10 @@ import click from flask import current_app as app +from teal.db import SQLAlchemy +from teal.resource import Converters, Resource from ereuse_devicehub.db import db from ereuse_devicehub.resources.agent import models, schemas -from teal.db import SQLAlchemy -from teal.resource import Converters, Resource class AgentDef(Resource): diff --git a/ereuse_devicehub/resources/agent/models.py b/ereuse_devicehub/resources/agent/models.py index b7218eb7..775ca359 100644 --- a/ereuse_devicehub/resources/agent/models.py +++ b/ereuse_devicehub/resources/agent/models.py @@ -8,13 +8,13 @@ from sqlalchemy.dialects.postgresql import UUID from sqlalchemy.ext.declarative import declared_attr from sqlalchemy.orm import backref, relationship from sqlalchemy_utils import EmailType, PhoneNumberType - -from ereuse_devicehub.resources.models import STR_SIZE, STR_SM_SIZE, Thing -from ereuse_devicehub.resources.user.models import User from teal import enums from teal.db import INHERIT_COND, POLYMORPHIC_ID, \ POLYMORPHIC_ON +from ereuse_devicehub.resources.models import STR_SIZE, STR_SM_SIZE, Thing +from ereuse_devicehub.resources.user.models import User + class JoinedTableMixin: # noinspection PyMethodParameters diff --git a/ereuse_devicehub/resources/agent/models.pyi b/ereuse_devicehub/resources/agent/models.pyi index e4b5853e..379c2fad 100644 --- a/ereuse_devicehub/resources/agent/models.pyi +++ b/ereuse_devicehub/resources/agent/models.pyi @@ -4,12 +4,12 @@ from typing import List, Set from sqlalchemy import Column from sqlalchemy.orm import relationship from sqlalchemy_utils import PhoneNumber +from teal import enums from ereuse_devicehub.resources.event.models import Event, Trade from ereuse_devicehub.resources.models import Thing from ereuse_devicehub.resources.tag.model import Tag from ereuse_devicehub.resources.user import User -from teal import enums class Agent(Thing): @@ -40,7 +40,7 @@ class Organization(Agent): def __init__(self, name: str, **kwargs): super().__init__(**kwargs) self.members = ... # type: Set[Membership] - self.tags = ... # type: Set[Tag] + self.tags = ... # type: Set[Tag] @classmethod def get_default_org_id(cls) -> uuid.UUID: diff --git a/ereuse_devicehub/resources/agent/schemas.py b/ereuse_devicehub/resources/agent/schemas.py index 3e4736c7..6b5d1365 100644 --- a/ereuse_devicehub/resources/agent/schemas.py +++ b/ereuse_devicehub/resources/agent/schemas.py @@ -1,11 +1,11 @@ from marshmallow import fields as ma_fields, validate as ma_validate from marshmallow.fields import Email +from teal import enums +from teal.marshmallow import EnumField, Phone from ereuse_devicehub.marshmallow import NestedOn from ereuse_devicehub.resources.models import STR_SIZE, STR_SM_SIZE from ereuse_devicehub.resources.schemas import Thing -from teal import enums -from teal.marshmallow import EnumField, Phone class Agent(Thing): diff --git a/ereuse_devicehub/resources/device/__init__.py b/ereuse_devicehub/resources/device/__init__.py index 4c4d6e12..497fd0b3 100644 --- a/ereuse_devicehub/resources/device/__init__.py +++ b/ereuse_devicehub/resources/device/__init__.py @@ -1,6 +1,7 @@ +from teal.resource import Converters, Resource + from ereuse_devicehub.resources.device import schemas from ereuse_devicehub.resources.device.views import DeviceView -from teal.resource import Converters, Resource class DeviceDef(Resource): diff --git a/ereuse_devicehub/resources/device/models.py b/ereuse_devicehub/resources/device/models.py index 9e280b99..644ddf1b 100644 --- a/ereuse_devicehub/resources/device/models.py +++ b/ereuse_devicehub/resources/device/models.py @@ -3,6 +3,7 @@ from itertools import chain from operator import attrgetter from typing import Dict, Set +from ereuse_utils.naming import Naming from sqlalchemy import BigInteger, Boolean, Column, Enum as DBEnum, Float, ForeignKey, Integer, \ Sequence, SmallInteger, Unicode, inspect from sqlalchemy.ext.declarative import declared_attr @@ -10,13 +11,12 @@ from sqlalchemy.orm import ColumnProperty, backref, relationship, validates from sqlalchemy.util import OrderedSet from sqlalchemy_utils import ColorType from stdnum import imei, meid +from teal.db import CASCADE, POLYMORPHIC_ID, POLYMORPHIC_ON, ResourceNotFound, check_range +from teal.marshmallow import ValidationError from ereuse_devicehub.resources.enums import ComputerChassis, DataStorageInterface, DisplayTech, \ RamFormat, RamInterface from ereuse_devicehub.resources.models import STR_BIG_SIZE, STR_SIZE, STR_SM_SIZE, Thing -from ereuse_utils.naming import Naming -from teal.db import CASCADE, POLYMORPHIC_ID, POLYMORPHIC_ON, ResourceNotFound, check_range -from teal.marshmallow import ValidationError class Device(Thing): diff --git a/ereuse_devicehub/resources/device/models.pyi b/ereuse_devicehub/resources/device/models.pyi index 3efe9e6c..6d86d728 100644 --- a/ereuse_devicehub/resources/device/models.pyi +++ b/ereuse_devicehub/resources/device/models.pyi @@ -26,7 +26,7 @@ class Device(Thing): height = ... # type: Column depth = ... # type: Column color = ... # type: Column - parents = ... # type: relationship + parents = ... # type: relationship def __init__(self, **kwargs) -> None: super().__init__(**kwargs) @@ -47,7 +47,7 @@ class Device(Thing): self.events_one = ... # type: Set[EventWithOneDevice] self.images = ... # type: ImageList self.tags = ... # type: Set[Tag] - self.parents = ... # type: Set[Lot] + self.parents = ... # type: Set[Lot] class DisplayMixin: diff --git a/ereuse_devicehub/resources/device/schemas.py b/ereuse_devicehub/resources/device/schemas.py index 79e0f28f..f7eab413 100644 --- a/ereuse_devicehub/resources/device/schemas.py +++ b/ereuse_devicehub/resources/device/schemas.py @@ -3,6 +3,7 @@ from marshmallow.fields import Boolean, Float, Integer, Str from marshmallow.validate import Length, OneOf, Range from sqlalchemy.util import OrderedSet from stdnum import imei, meid +from teal.marshmallow import EnumField, ValidationError from ereuse_devicehub.marshmallow import NestedOn from ereuse_devicehub.resources.device import models as m @@ -10,7 +11,6 @@ from ereuse_devicehub.resources.enums import ComputerChassis, DataStorageInterfa RamFormat, RamInterface from ereuse_devicehub.resources.models import STR_BIG_SIZE, STR_SIZE from ereuse_devicehub.resources.schemas import Thing, UnitCodes -from teal.marshmallow import EnumField, ValidationError class Device(Thing): diff --git a/ereuse_devicehub/resources/device/sync.py b/ereuse_devicehub/resources/device/sync.py index 223d8c47..c12ff822 100644 --- a/ereuse_devicehub/resources/device/sync.py +++ b/ereuse_devicehub/resources/device/sync.py @@ -5,14 +5,14 @@ from typing import Iterable, Set from sqlalchemy import inspect from sqlalchemy.exc import IntegrityError from sqlalchemy.util import OrderedSet +from teal.db import ResourceNotFound +from teal.marshmallow import ValidationError from ereuse_devicehub.db import db from ereuse_devicehub.resources.device.exceptions import NeedsId from ereuse_devicehub.resources.device.models import Component, Computer, Device from ereuse_devicehub.resources.event.models import Remove from ereuse_devicehub.resources.tag.model import Tag -from teal.db import ResourceNotFound -from teal.marshmallow import ValidationError class Sync: diff --git a/ereuse_devicehub/resources/device/views.py b/ereuse_devicehub/resources/device/views.py index 645b9fd1..7e6edacd 100644 --- a/ereuse_devicehub/resources/device/views.py +++ b/ereuse_devicehub/resources/device/views.py @@ -1,6 +1,7 @@ -from ereuse_devicehub.resources.device.models import Device from teal.resource import View +from ereuse_devicehub.resources.device.models import Device + class DeviceView(View): diff --git a/ereuse_devicehub/resources/event/__init__.py b/ereuse_devicehub/resources/event/__init__.py index 4d092541..75ffe1ef 100644 --- a/ereuse_devicehub/resources/event/__init__.py +++ b/ereuse_devicehub/resources/event/__init__.py @@ -1,9 +1,10 @@ from typing import Callable, Iterable, Tuple +from teal.resource import Converters, Resource + from ereuse_devicehub.resources.device.sync import Sync from ereuse_devicehub.resources.event import schemas from ereuse_devicehub.resources.event.views import EventView, SnapshotView -from teal.resource import Converters, Resource class EventDef(Resource): diff --git a/ereuse_devicehub/resources/event/models.pyi b/ereuse_devicehub/resources/event/models.pyi index 57413512..070ef28c 100644 --- a/ereuse_devicehub/resources/event/models.pyi +++ b/ereuse_devicehub/resources/event/models.pyi @@ -9,6 +9,9 @@ from boltons.urlutils import URL from sqlalchemy import Column from sqlalchemy.orm import relationship from sqlalchemy_utils import Currency +from teal import enums +from teal.db import Model +from teal.enums import Country from ereuse_devicehub.resources.agent.models import Agent from ereuse_devicehub.resources.device.models import Component, Computer, Device @@ -18,9 +21,6 @@ from ereuse_devicehub.resources.enums import AppearanceRange, Bios, Functionalit from ereuse_devicehub.resources.image.models import Image from ereuse_devicehub.resources.models import Thing from ereuse_devicehub.resources.user.models import User -from teal import enums -from teal.db import Model -from teal.enums import Country class Event(Thing): diff --git a/ereuse_devicehub/resources/event/schemas.py b/ereuse_devicehub/resources/event/schemas.py index b5080b15..1063565c 100644 --- a/ereuse_devicehub/resources/event/schemas.py +++ b/ereuse_devicehub/resources/event/schemas.py @@ -6,6 +6,9 @@ from marshmallow.fields import Boolean, DateTime, Decimal, Float, Integer, List, TimeDelta, URL, UUID from marshmallow.validate import Length, Range from sqlalchemy.util import OrderedSet +from teal.enums import Country, Currency, Subdivision +from teal.marshmallow import EnumField, IP, Version +from teal.resource import Schema from ereuse_devicehub.marshmallow import NestedOn from ereuse_devicehub.resources.agent.schemas import Agent @@ -17,9 +20,6 @@ from ereuse_devicehub.resources.event import models as m from ereuse_devicehub.resources.models import STR_BIG_SIZE, STR_SIZE from ereuse_devicehub.resources.schemas import Thing from ereuse_devicehub.resources.user.schemas import User -from teal.enums import Country, Currency, Subdivision -from teal.marshmallow import EnumField, IP, Version -from teal.resource import Schema class Event(Thing): diff --git a/ereuse_devicehub/resources/image/models.py b/ereuse_devicehub/resources/image/models.py index 5c45f9ea..08f5591a 100644 --- a/ereuse_devicehub/resources/image/models.py +++ b/ereuse_devicehub/resources/image/models.py @@ -4,12 +4,12 @@ from sqlalchemy import BigInteger, Column, Enum as DBEnum, ForeignKey, Unicode from sqlalchemy.dialects.postgresql import UUID from sqlalchemy.orm import backref, relationship from sqlalchemy.util import OrderedSet +from teal.db import CASCADE_OWN from ereuse_devicehub.db import db from ereuse_devicehub.resources.device.models import Device from ereuse_devicehub.resources.enums import ImageMimeTypes, Orientation from ereuse_devicehub.resources.models import STR_BIG_SIZE, Thing -from teal.db import CASCADE_OWN class ImageList(Thing): diff --git a/ereuse_devicehub/resources/inventory.py b/ereuse_devicehub/resources/inventory.py index 10171804..e3977cf9 100644 --- a/ereuse_devicehub/resources/inventory.py +++ b/ereuse_devicehub/resources/inventory.py @@ -4,14 +4,14 @@ from marshmallow import Schema as MarshmallowSchema from marshmallow.fields import Float, Integer, Nested, Str from marshmallow.validate import Range from sqlalchemy import Column +from teal.query import Between, FullTextSearch, ILike, Join, Or, Query, Sort, SortField +from teal.resource import Resource, View from ereuse_devicehub.resources.device.models import Device from ereuse_devicehub.resources.event.models import Rate from ereuse_devicehub.resources.lot.models import Lot from ereuse_devicehub.resources.schemas import Thing from ereuse_devicehub.resources.tag import Tag -from teal.query import Between, FullTextSearch, ILike, Join, Or, Query, Sort, SortField -from teal.resource import Resource, View class Inventory(Thing): diff --git a/ereuse_devicehub/resources/lot/__init__.py b/ereuse_devicehub/resources/lot/__init__.py index cd69c849..176ed4d5 100644 --- a/ereuse_devicehub/resources/lot/__init__.py +++ b/ereuse_devicehub/resources/lot/__init__.py @@ -1,9 +1,10 @@ import pathlib +from teal.resource import Converters, Resource + from ereuse_devicehub.db import db from ereuse_devicehub.resources.lot import schemas from ereuse_devicehub.resources.lot.views import LotView -from teal.resource import Converters, Resource class LotDef(Resource): diff --git a/ereuse_devicehub/resources/lot/models.pyi b/ereuse_devicehub/resources/lot/models.pyi index b8f60afe..21aa00b3 100644 --- a/ereuse_devicehub/resources/lot/models.pyi +++ b/ereuse_devicehub/resources/lot/models.pyi @@ -15,7 +15,7 @@ class Lot(Thing): name = ... # type: Column closed = ... # type: Column devices = ... # type: relationship - paths = ... # type: relationship + paths = ... # type: relationship def __init__(self, name: str, closed: bool = closed.default.arg) -> None: super().__init__() diff --git a/ereuse_devicehub/resources/lot/views.py b/ereuse_devicehub/resources/lot/views.py index e2a8dcaf..f6ebfb9f 100644 --- a/ereuse_devicehub/resources/lot/views.py +++ b/ereuse_devicehub/resources/lot/views.py @@ -1,10 +1,10 @@ import uuid from flask import current_app as app, request +from teal.resource import View from ereuse_devicehub.db import db from ereuse_devicehub.resources.lot.models import Lot -from teal.resource import View class LotView(View): diff --git a/ereuse_devicehub/resources/schemas.py b/ereuse_devicehub/resources/schemas.py index ee658d3c..31601d18 100644 --- a/ereuse_devicehub/resources/schemas.py +++ b/ereuse_devicehub/resources/schemas.py @@ -2,9 +2,9 @@ from enum import Enum from marshmallow import post_load from marshmallow.fields import DateTime, List, String, URL +from teal.resource import Schema from ereuse_devicehub.resources import models as m -from teal.resource import Schema class UnitCodes(Enum): diff --git a/ereuse_devicehub/resources/tag/__init__.py b/ereuse_devicehub/resources/tag/__init__.py index 8f5e3e0f..e6935d72 100644 --- a/ereuse_devicehub/resources/tag/__init__.py +++ b/ereuse_devicehub/resources/tag/__init__.py @@ -1,13 +1,13 @@ from typing import Tuple from click import argument, option +from teal.resource import Resource +from teal.teal import Teal from ereuse_devicehub.db import db from ereuse_devicehub.resources.tag import schema from ereuse_devicehub.resources.tag.model import Tag from ereuse_devicehub.resources.tag.view import TagView, get_device_from_tag -from teal.resource import Resource -from teal.teal import Teal class TagDef(Resource): diff --git a/ereuse_devicehub/resources/tag/model.py b/ereuse_devicehub/resources/tag/model.py index 1bb01364..a810f3fc 100644 --- a/ereuse_devicehub/resources/tag/model.py +++ b/ereuse_devicehub/resources/tag/model.py @@ -1,12 +1,12 @@ from sqlalchemy import BigInteger, Column, ForeignKey, Unicode, UniqueConstraint from sqlalchemy.dialects.postgresql import UUID from sqlalchemy.orm import backref, relationship, validates +from teal.db import DB_CASCADE_SET_NULL, URL +from teal.marshmallow import ValidationError from ereuse_devicehub.resources.agent.models import Organization from ereuse_devicehub.resources.device.models import Device from ereuse_devicehub.resources.models import Thing -from teal.db import DB_CASCADE_SET_NULL, URL -from teal.marshmallow import ValidationError class Tag(Thing): diff --git a/ereuse_devicehub/resources/tag/schema.py b/ereuse_devicehub/resources/tag/schema.py index 00ca28eb..356f4d7b 100644 --- a/ereuse_devicehub/resources/tag/schema.py +++ b/ereuse_devicehub/resources/tag/schema.py @@ -1,9 +1,9 @@ from marshmallow.fields import String +from teal.marshmallow import URL from ereuse_devicehub.marshmallow import NestedOn from ereuse_devicehub.resources.device.schemas import Device from ereuse_devicehub.resources.schemas import Thing -from teal.marshmallow import URL class Tag(Thing): diff --git a/ereuse_devicehub/resources/tag/view.py b/ereuse_devicehub/resources/tag/view.py index 03b9cb89..55f823fb 100644 --- a/ereuse_devicehub/resources/tag/view.py +++ b/ereuse_devicehub/resources/tag/view.py @@ -1,11 +1,11 @@ from flask import Response, current_app as app, request from marshmallow.fields import List, String, URL +from teal.marshmallow import ValidationError +from teal.resource import Schema, View from webargs.flaskparser import parser from ereuse_devicehub.resources.device.models import Device from ereuse_devicehub.resources.tag import Tag -from teal.marshmallow import ValidationError -from teal.resource import Schema, View class TagView(View): diff --git a/ereuse_devicehub/resources/user/__init__.py b/ereuse_devicehub/resources/user/__init__.py index b22d52ce..9a980faa 100644 --- a/ereuse_devicehub/resources/user/__init__.py +++ b/ereuse_devicehub/resources/user/__init__.py @@ -1,10 +1,10 @@ from click import argument, option +from teal.resource import Converters, Resource from ereuse_devicehub.db import db from ereuse_devicehub.resources.user import schemas from ereuse_devicehub.resources.user.models import User from ereuse_devicehub.resources.user.views import UserView, login -from teal.resource import Converters, Resource class UserDef(Resource): diff --git a/ereuse_devicehub/resources/user/views.py b/ereuse_devicehub/resources/user/views.py index 6369a9b1..7053eea7 100644 --- a/ereuse_devicehub/resources/user/views.py +++ b/ereuse_devicehub/resources/user/views.py @@ -1,11 +1,11 @@ from uuid import UUID from flask import g, request +from teal.resource import View from ereuse_devicehub.resources.user.exceptions import WrongCredentials from ereuse_devicehub.resources.user.models import User from ereuse_devicehub.resources.user.schemas import User as UserS -from teal.resource import View class UserView(View):