Update ORM and CLI
This commit is contained in:
@@ -12,8 +12,12 @@ def init_shell(): # pragma: no cover
|
|||||||
|
|
||||||
from sigl.database import db
|
from sigl.database import db
|
||||||
from sigl.domain.models import (
|
from sigl.domain.models import (
|
||||||
|
AccessKey,
|
||||||
|
AccessToken,
|
||||||
|
ListEntry,
|
||||||
Product,
|
Product,
|
||||||
ProductLocation,
|
ProductLocation,
|
||||||
|
ShoppingList,
|
||||||
)
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -26,8 +30,12 @@ def init_shell(): # pragma: no cover
|
|||||||
'session': db.session,
|
'session': db.session,
|
||||||
|
|
||||||
# Models
|
# Models
|
||||||
|
'AccessKey': AccessKey,
|
||||||
|
'AccessToken': AccessToken,
|
||||||
|
'ListEntry': ListEntry,
|
||||||
'Product': Product,
|
'Product': Product,
|
||||||
'ProductLocation': ProductLocation,
|
'ProductLocation': ProductLocation,
|
||||||
|
'ShoppingList': ShoppingList,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -8,9 +8,15 @@ from sigl.domain.models import (
|
|||||||
Product,
|
Product,
|
||||||
ProductLocation,
|
ProductLocation,
|
||||||
)
|
)
|
||||||
|
from sigl.domain.models.accessKey import AccessKey, AccessToken
|
||||||
|
from sigl.domain.models.list import ListEntry, ShoppingList
|
||||||
|
|
||||||
from .globals import db
|
from .globals import db
|
||||||
from .tables import (
|
from .tables import (
|
||||||
|
access_keys,
|
||||||
|
access_tokens,
|
||||||
|
list_entries,
|
||||||
|
lists,
|
||||||
product_locations,
|
product_locations,
|
||||||
products,
|
products,
|
||||||
)
|
)
|
||||||
@@ -21,6 +27,21 @@ __all__ = ('init_orm', )
|
|||||||
def init_orm():
|
def init_orm():
|
||||||
"""Initialize the Sigl ORM."""
|
"""Initialize the Sigl ORM."""
|
||||||
|
|
||||||
|
# Access Keys
|
||||||
|
db.mapper(AccessKey, access_keys, properties={
|
||||||
|
'tokens': db.relationship(
|
||||||
|
AccessToken,
|
||||||
|
backref='accessKey',
|
||||||
|
cascade='all, delete-orphan',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
# Access Tokens
|
||||||
|
db.mapper(AccessToken, access_tokens)
|
||||||
|
|
||||||
|
# List Entries
|
||||||
|
db.mapper(ListEntry, list_entries)
|
||||||
|
|
||||||
# Products
|
# Products
|
||||||
db.mapper(Product, products, properties={
|
db.mapper(Product, products, properties={
|
||||||
'locations': db.relationship(
|
'locations': db.relationship(
|
||||||
@@ -28,7 +49,21 @@ def init_orm():
|
|||||||
backref='product',
|
backref='product',
|
||||||
cascade='all, delete-orphan',
|
cascade='all, delete-orphan',
|
||||||
),
|
),
|
||||||
|
'shoppingLists': db.relationship(
|
||||||
|
ShoppingList,
|
||||||
|
backref='product',
|
||||||
|
cascade='all, delete-orphan',
|
||||||
|
),
|
||||||
})
|
})
|
||||||
|
|
||||||
# Product Locations
|
# Product Locations
|
||||||
db.mapper(ProductLocation, product_locations)
|
db.mapper(ProductLocation, product_locations)
|
||||||
|
|
||||||
|
# Shopping Lists
|
||||||
|
db.mapper(ShoppingList, lists, properties={
|
||||||
|
'entries': db.relationship(
|
||||||
|
ListEntry,
|
||||||
|
backref='shoppingList',
|
||||||
|
cascade='all, delete-orphan',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|||||||
@@ -4,8 +4,15 @@ Simple Grocery List (Sigl) | sigl.app
|
|||||||
Copyright (c) 2022 Asymworks, LLC. All Rights Reserved.
|
Copyright (c) 2022 Asymworks, LLC. All Rights Reserved.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from .accessKey import AccessKey, AccessToken
|
||||||
|
from .list import ListEntry, ShoppingList
|
||||||
from .product import Product, ProductLocation
|
from .product import Product, ProductLocation
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
'Product', 'ProductLocation',
|
'AccessKey',
|
||||||
|
'AccessToken',
|
||||||
|
'ListEntry',
|
||||||
|
'Product',
|
||||||
|
'ProductLocation',
|
||||||
|
'ShoppingList',
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ __all__ = ('AccessKey', 'AccessToken')
|
|||||||
@dataclass
|
@dataclass
|
||||||
class AccessKey:
|
class AccessKey:
|
||||||
"""Sigl Access Key Class.
|
"""Sigl Access Key Class.
|
||||||
|
|
||||||
The Access Key represents a client or group of clients authorized to
|
The Access Key represents a client or group of clients authorized to
|
||||||
interact with their specific Sigl shopping lists and products. Access Keys
|
interact with their specific Sigl shopping lists and products. Access Keys
|
||||||
are generally not revoked or deleted and remain for the lifetime of the
|
are generally not revoked or deleted and remain for the lifetime of the
|
||||||
@@ -42,7 +42,7 @@ class AccessKey:
|
|||||||
@dataclass
|
@dataclass
|
||||||
class AccessToken:
|
class AccessToken:
|
||||||
"""Sigl Access Token Class.
|
"""Sigl Access Token Class.
|
||||||
|
|
||||||
The Access Token represents authorization for a client (identified by an
|
The Access Token represents authorization for a client (identified by an
|
||||||
Access Key) to interact with the Sigl server. The token string, issue time,
|
Access Key) to interact with the Sigl server. The token string, issue time,
|
||||||
and expiry time must match the client-provided JWT for access to be granted.
|
and expiry time must match the client-provided JWT for access to be granted.
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ Copyright (c) 2022 Asymworks, LLC. All Rights Reserved.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import List
|
|
||||||
|
|
||||||
from .mixins import NotesMixin, TimestampMixin
|
from .mixins import NotesMixin, TimestampMixin
|
||||||
from .product import Product
|
from .product import Product
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ Copyright (c) 2022 Asymworks, LLC. All Rights Reserved.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import List
|
|
||||||
|
|
||||||
from .mixins import NotesMixin, TimestampMixin
|
from .mixins import NotesMixin, TimestampMixin
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user