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.domain.models import (
|
||||
AccessKey,
|
||||
AccessToken,
|
||||
ListEntry,
|
||||
Product,
|
||||
ProductLocation,
|
||||
ShoppingList,
|
||||
)
|
||||
|
||||
return {
|
||||
@@ -26,8 +30,12 @@ def init_shell(): # pragma: no cover
|
||||
'session': db.session,
|
||||
|
||||
# Models
|
||||
'AccessKey': AccessKey,
|
||||
'AccessToken': AccessToken,
|
||||
'ListEntry': ListEntry,
|
||||
'Product': Product,
|
||||
'ProductLocation': ProductLocation,
|
||||
'ShoppingList': ShoppingList,
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -8,9 +8,15 @@ from sigl.domain.models import (
|
||||
Product,
|
||||
ProductLocation,
|
||||
)
|
||||
from sigl.domain.models.accessKey import AccessKey, AccessToken
|
||||
from sigl.domain.models.list import ListEntry, ShoppingList
|
||||
|
||||
from .globals import db
|
||||
from .tables import (
|
||||
access_keys,
|
||||
access_tokens,
|
||||
list_entries,
|
||||
lists,
|
||||
product_locations,
|
||||
products,
|
||||
)
|
||||
@@ -21,6 +27,21 @@ __all__ = ('init_orm', )
|
||||
def init_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
|
||||
db.mapper(Product, products, properties={
|
||||
'locations': db.relationship(
|
||||
@@ -28,7 +49,21 @@ def init_orm():
|
||||
backref='product',
|
||||
cascade='all, delete-orphan',
|
||||
),
|
||||
'shoppingLists': db.relationship(
|
||||
ShoppingList,
|
||||
backref='product',
|
||||
cascade='all, delete-orphan',
|
||||
),
|
||||
})
|
||||
|
||||
# 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.
|
||||
"""
|
||||
|
||||
from .accessKey import AccessKey, AccessToken
|
||||
from .list import ListEntry, ShoppingList
|
||||
from .product import Product, ProductLocation
|
||||
|
||||
__all__ = (
|
||||
'Product', 'ProductLocation',
|
||||
'AccessKey',
|
||||
'AccessToken',
|
||||
'ListEntry',
|
||||
'Product',
|
||||
'ProductLocation',
|
||||
'ShoppingList',
|
||||
)
|
||||
|
||||
@@ -13,7 +13,7 @@ __all__ = ('AccessKey', 'AccessToken')
|
||||
@dataclass
|
||||
class AccessKey:
|
||||
"""Sigl Access Key Class.
|
||||
|
||||
|
||||
The Access Key represents a client or group of clients authorized to
|
||||
interact with their specific Sigl shopping lists and products. Access Keys
|
||||
are generally not revoked or deleted and remain for the lifetime of the
|
||||
@@ -42,7 +42,7 @@ class AccessKey:
|
||||
@dataclass
|
||||
class AccessToken:
|
||||
"""Sigl Access Token Class.
|
||||
|
||||
|
||||
The Access Token represents authorization for a client (identified by an
|
||||
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.
|
||||
|
||||
@@ -5,7 +5,6 @@ Copyright (c) 2022 Asymworks, LLC. All Rights Reserved.
|
||||
"""
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import List
|
||||
|
||||
from .mixins import NotesMixin, TimestampMixin
|
||||
from .product import Product
|
||||
|
||||
@@ -5,7 +5,6 @@ Copyright (c) 2022 Asymworks, LLC. All Rights Reserved.
|
||||
"""
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import List
|
||||
|
||||
from .mixins import NotesMixin, TimestampMixin
|
||||
|
||||
|
||||
Reference in New Issue
Block a user