Complete system for getting + saving Product Categories with new database, server, and client architecture.
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -19,7 +19,7 @@ Business object for SQL errors
|
||||
# internal
|
||||
import lib.argument_validation as av
|
||||
from lib import data_types
|
||||
from forms import Form_Basket_Add, Form_Basket_Edit # Form_Product
|
||||
from forms.forms import Form_Basket_Add, Form_Basket_Edit # Form_Product
|
||||
# external
|
||||
from enum import Enum
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
0
business_objects/store/__init__.py
Normal file
0
business_objects/store/__init__.py
Normal file
BIN
business_objects/store/__pycache__/__init__.cpython-312.pyc
Normal file
BIN
business_objects/store/__pycache__/__init__.cpython-312.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
0
business_objects/store/access_level.py
Normal file
0
business_objects/store/access_level.py
Normal file
@@ -19,7 +19,7 @@ Business object for basket
|
||||
# internal
|
||||
import lib.argument_validation as av
|
||||
# from lib import data_types
|
||||
from business_objects.store.product import Product #, Product_Filters
|
||||
from business_objects.store.product import Product #, Filters_Product
|
||||
from business_objects.store.discount import Discount
|
||||
from business_objects.store.delivery_option import Delivery_Option
|
||||
# from forms import Form_Product
|
||||
|
||||
@@ -102,7 +102,7 @@ class Product_Image_Filters():
|
||||
|
||||
def __new__(cls, product_id, get_thumbnail, get_remaining_LQ):
|
||||
# Initialiser - validation
|
||||
_m = 'Product_Filters.__new__'
|
||||
_m = 'Filters_Product.__new__'
|
||||
v_arg_type = 'class attribute'
|
||||
av.val_int(product_id, 'product_id', _m, v_arg_type=v_arg_type)
|
||||
av.val_bool(get_thumbnail, 'get_thumbnail', _m, v_arg_type=v_arg_type)
|
||||
|
||||
@@ -13,7 +13,7 @@ Business object for product
|
||||
# internal
|
||||
import lib.argument_validation as av
|
||||
from lib import data_types
|
||||
from forms import Form_Basket_Add, Form_Basket_Edit, Form_Filters_Permutation
|
||||
from forms.forms import Form_Basket_Add, Form_Basket_Edit, Form_Filters_Permutation
|
||||
from business_objects.store.delivery_option import Delivery_Option
|
||||
from business_objects.store.discount import Discount
|
||||
from business_objects.store.image import Image
|
||||
@@ -62,6 +62,8 @@ class Product(db.Model, Store_Base):
|
||||
id_product = db.Column(db.Integer, primary_key=True)
|
||||
id_category = db.Column(db.Integer)
|
||||
name = db.Column(db.String(255))
|
||||
id_access_level_required = db.Column(db.Integer)
|
||||
active = db.Column(db.Boolean)
|
||||
display_order = db.Column(db.Integer)
|
||||
can_view = db.Column(db.Boolean)
|
||||
can_edit = db.Column(db.Boolean)
|
||||
@@ -87,13 +89,15 @@ class Product(db.Model, Store_Base):
|
||||
v_arg_type = 'class attribute'
|
||||
product = Product()
|
||||
product.id_product = query_row[0]
|
||||
product.id_category = query_row[5]
|
||||
product.id_category = query_row[1]
|
||||
product.name = query_row[2]
|
||||
product.has_variations = av.input_bool(query_row[4], "has_variations", _m, v_arg_type=v_arg_type)
|
||||
product.display_order = query_row[22]
|
||||
product.can_view = av.input_bool(query_row[24], "can_view", _m, v_arg_type=v_arg_type)
|
||||
product.can_edit = av.input_bool(query_row[25], "can_edit", _m, v_arg_type=v_arg_type)
|
||||
product.can_admin = av.input_bool(query_row[26], "can_admin", _m, v_arg_type=v_arg_type)
|
||||
product.has_variations = av.input_bool(query_row[3], "has_variations", _m, v_arg_type=v_arg_type)
|
||||
product.id_access_level_required = query_row[4]
|
||||
product.active = av.input_bool(query_row[5], "active", _m, v_arg_type=v_arg_type)
|
||||
product.display_order = query_row[6]
|
||||
product.can_view = av.input_bool(query_row[7], "can_view", _m, v_arg_type=v_arg_type)
|
||||
product.can_edit = av.input_bool(query_row[8], "can_edit", _m, v_arg_type=v_arg_type)
|
||||
product.can_admin = av.input_bool(query_row[9], "can_admin", _m, v_arg_type=v_arg_type)
|
||||
return product
|
||||
"""
|
||||
def from_permutation(permutation, has_variations = False):
|
||||
@@ -315,12 +319,12 @@ class Product(db.Model, Store_Base):
|
||||
}
|
||||
|
||||
@dataclass
|
||||
class Product_Filters():
|
||||
class Filters_Product():
|
||||
# id_user: str
|
||||
get_all_category: bool
|
||||
get_inactive_category: bool
|
||||
# get_first_category_only: bool
|
||||
ids_category: str
|
||||
get_all_product_category: bool
|
||||
get_inactive_product_category: bool
|
||||
# get_first_product_category_only: bool
|
||||
ids_product_category: str
|
||||
get_all_product: bool
|
||||
get_inactive_product: bool
|
||||
# get_first_product_only: bool
|
||||
@@ -351,10 +355,10 @@ class Product_Filters():
|
||||
def to_json(self):
|
||||
return {
|
||||
'a_id_user': None,
|
||||
'a_get_all_category': self.get_all_category,
|
||||
'a_get_inactive_category': self.get_inactive_category,
|
||||
# 'a_get_first_category_only': self.get_first_category_only,
|
||||
'a_ids_category': self.ids_category,
|
||||
'a_get_all_product_category': self.get_all_product_category,
|
||||
'a_get_inactive_product_category': self.get_inactive_product_category,
|
||||
# 'a_get_first_product_category_only': self.get_first_product_category_only,
|
||||
'a_ids_product_category': self.ids_product_category,
|
||||
'a_get_all_product': self.get_all_product,
|
||||
'a_get_inactive_product': self.get_inactive_product,
|
||||
# 'a_get_first_product_only': self.get_first_product_only,
|
||||
@@ -384,16 +388,16 @@ class Product_Filters():
|
||||
@staticmethod
|
||||
def from_form(form):
|
||||
# if not (form is Form_Filters_Permutation): raise ValueError(f'Invalid form type: {type(form)}')
|
||||
av.val_instance(form, 'form', 'Product_Filters.from_form', Form_Filters_Permutation)
|
||||
av.val_instance(form, 'form', 'Filters_Product.from_form', Form_Filters_Permutation)
|
||||
has_category_filter = not (form.id_category.data == '0' or form.id_category.data == '')
|
||||
has_product_filter = not (form.id_product.data == '0' or form.id_product.data == '')
|
||||
get_permutations_stock_below_min = av.input_bool(form.is_out_of_stock.data, "is_out_of_stock", "Product_Filters.from_form")
|
||||
get_permutations_stock_below_min = av.input_bool(form.is_out_of_stock.data, "is_out_of_stock", "Filters_Product.from_form")
|
||||
print(f'form question: {type(form.is_out_of_stock)}\nbool interpretted: {get_permutations_stock_below_min}\type form: {type(form)}')
|
||||
return Product_Filters(
|
||||
get_all_category = not has_category_filter,
|
||||
get_inactive_category = False,
|
||||
# get_first_category_only = False,
|
||||
ids_category = form.id_category.data,
|
||||
return Filters_Product(
|
||||
get_all_product_category = not has_category_filter,
|
||||
get_inactive_product_category = False,
|
||||
# get_first_product_category_only = False,
|
||||
ids_product_category = form.id_category.data,
|
||||
get_all_product = not has_product_filter,
|
||||
get_inactive_product = False,
|
||||
# get_first_product_only = False,
|
||||
@@ -422,11 +426,11 @@ class Product_Filters():
|
||||
|
||||
@staticmethod
|
||||
def get_default():
|
||||
return Product_Filters(
|
||||
get_all_category = True,
|
||||
get_inactive_category = False,
|
||||
# get_first_category_only = False,
|
||||
ids_category = '',
|
||||
return Filters_Product(
|
||||
get_all_product_category = True,
|
||||
get_inactive_product_category = False,
|
||||
# get_first_product_category_only = False,
|
||||
ids_product_category = '',
|
||||
get_all_product = True,
|
||||
get_inactive_product = False,
|
||||
# get_first_product_only = False,
|
||||
@@ -451,4 +455,55 @@ class Product_Filters():
|
||||
# get_inactive_discount = False,
|
||||
# ids_discount = '',
|
||||
get_products_quantity_stock_below_min = True
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json):
|
||||
return cls(
|
||||
get_all_product_category = json.get('a_get_all_product_category', False),
|
||||
get_inactive_product_category = json.get('a_get_inactive_product_category', False),
|
||||
# get_first_product_category_only = json.get('a_get_first_product_category_only', False),
|
||||
ids_product_category = json.get('a_ids_product_category', ''),
|
||||
get_all_product = json.get('a_get_all_product', False),
|
||||
get_inactive_product = json.get('a_get_inactive_product', False),
|
||||
# get_first_product_only = json.get('a_get_first_product_only', False),
|
||||
ids_product = json.get('a_ids_product', ''),
|
||||
get_all_permutation = json.get('a_get_all_permutation', False),
|
||||
get_inactive_permutation = json.get('a_get_inactive_permutation', False),
|
||||
# get_first_permutation_only = json.get('a_get_first_permutation_only', False),
|
||||
ids_permutation = json.get('a_ids_permutation', ''),
|
||||
get_all_image = json.get('a_get_all_image', False),
|
||||
get_inactive_image = json.get('a_get_inactive_image', False),
|
||||
# get_first_image_only = json.get('a_get_first_image_only', False),
|
||||
ids_image = json.get('a_ids_image', ''),
|
||||
# get_all_region = json.get('a_get_all_region', False),
|
||||
# get_inactive_region = json.get('a_get_inactive_region', False),
|
||||
# get_first_region_only = json.get('a_get_first_region_only', False),
|
||||
# ids_region = json.get('a_ids_region', ''),
|
||||
# get_all_currency = json.get('a_get_all_currency', False),
|
||||
# get_inactive_currency = json.get('a_get_inactive_currency', False),
|
||||
# get_first_currency_only = json.get('a_get_first_currency_only', False),
|
||||
# ids_currency = json.get('a_ids_currency', ''),
|
||||
# get_all_discount = json.get('a_get_all_discount', False),
|
||||
# get_inactive_discount = json.get('a_get_inactive_discount', False),
|
||||
# ids_discount = json.get('a_ids_discount', ''),
|
||||
get_products_quantity_stock_below_min = json.get('a_get_products_quantity_stock_below_min', False)
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def from_filters_product_category(cls, filters_category):
|
||||
return cls(
|
||||
get_all_product_category = True,
|
||||
get_inactive_product_category = filters_category.active_only,
|
||||
ids_product_category = '',
|
||||
get_all_product = True,
|
||||
get_inactive_product = False,
|
||||
ids_product = False,
|
||||
get_all_permutation = True,
|
||||
get_inactive_permutation = False,
|
||||
ids_permutation = '',
|
||||
get_all_image = False,
|
||||
get_inactive_image = False,
|
||||
ids_image = '',
|
||||
get_products_quantity_stock_below_min = False
|
||||
)
|
||||
@@ -7,15 +7,9 @@ Technology: Business Objects
|
||||
Feature: Product Category Business Object
|
||||
|
||||
Description:
|
||||
Business object for product
|
||||
Business object for product category
|
||||
"""
|
||||
|
||||
# IMPORTS
|
||||
# VARIABLE INSTANTIATION
|
||||
# CLASSES
|
||||
# METHODS
|
||||
|
||||
# IMPORTS
|
||||
# internal
|
||||
import lib.argument_validation as av
|
||||
from business_objects.store.product import Product, Product_Permutation, Product_Price
|
||||
@@ -54,16 +48,19 @@ class Enum_Product_Category(Enum):
|
||||
"""
|
||||
|
||||
class Product_Category(db.Model, Store_Base):
|
||||
ATTR_CODE_CATEGORY: ClassVar[str] = 'code-category'
|
||||
ATTR_NAME_CATEGORY: ClassVar[str] = 'name-category'
|
||||
ATTR_DESCRIPTION_CATEGORY: ClassVar[str] = 'description-category'
|
||||
ATTR_DISPLAY_ORDER_CATEGORY: ClassVar[str] = 'display-order-category'
|
||||
|
||||
__tablename__ = 'Shop_Product_Category_Temp'
|
||||
id_category = db.Column(db.Integer, primary_key=True)
|
||||
code = db.Column(db.String(50))
|
||||
name = db.Column(db.String(255))
|
||||
description = db.Column(db.String(4000))
|
||||
id_access_level_required = db.Column(db.Integer)
|
||||
display_order = db.Column(db.Integer)
|
||||
active = db.Column(db.Boolean)
|
||||
can_view = db.Column(db.Boolean)
|
||||
can_edit = db.Column(db.Boolean)
|
||||
can_admin = db.Column(db.Boolean)
|
||||
created_on = db.Column(db.DateTime)
|
||||
created_by = db.Column(db.Integer)
|
||||
"""
|
||||
def __new__(cls, id, name, description, display_order):
|
||||
_m = 'Category.__new__'
|
||||
@@ -88,9 +85,15 @@ class Product_Category(db.Model, Store_Base):
|
||||
def from_DB_product(query_row):
|
||||
category = Product_Category()
|
||||
category.id_category = query_row[0]
|
||||
category.name = query_row[1]
|
||||
category.description = query_row[2]
|
||||
category.display_order = query_row[3]
|
||||
category.code = query_row[1]
|
||||
category.name = query_row[2]
|
||||
category.description = query_row[3]
|
||||
category.id_access_level_required = query_row[4]
|
||||
category.display_order = query_row[5]
|
||||
category.active = query_row[6]
|
||||
category.can_view = query_row[7]
|
||||
category.can_edit = query_row[8]
|
||||
category.can_admin = query_row[9]
|
||||
return category
|
||||
"""
|
||||
def key_product_index_from_ids_product_permutation(id_product, id_permutation):
|
||||
@@ -174,10 +177,12 @@ class Product_Category(db.Model, Store_Base):
|
||||
"""
|
||||
def __repr__(self):
|
||||
return f'''
|
||||
id: {self.id_category}
|
||||
name: {self.name}
|
||||
description: {self.description}
|
||||
id: {self.id_category[0] if isinstance(self.id_category, tuple) else self.id_category}
|
||||
code: {self.code[0] if isinstance(self.code, tuple) else self.code}
|
||||
name: {self.name[0] if isinstance(self.name, tuple) else self.name}
|
||||
description: {self.description[0] if isinstance(self.description, tuple) else self.description}
|
||||
display_order: {self.display_order}
|
||||
active: {self.active}
|
||||
products: {self.products}
|
||||
'''
|
||||
def get_permutation_first(self):
|
||||
@@ -203,42 +208,111 @@ class Product_Category(db.Model, Store_Base):
|
||||
return list_products
|
||||
def to_json(self):
|
||||
return {
|
||||
self.ATTR_ID_PRODUCT_CATEGORY: self.id_category,
|
||||
self.ATTR_CODE_CATEGORY: self.code,
|
||||
self.ATTR_NAME_CATEGORY: self.name,
|
||||
self.ATTR_DESCRIPTION_CATEGORY: self.description,
|
||||
self.ATTR_DISPLAY_ORDER_CATEGORY: self.display_order
|
||||
self.ATTR_ID_PRODUCT_CATEGORY: self.id_category[0] if isinstance(self.id_category, tuple) else self.id_category,
|
||||
self.FLAG_CODE: self.code[0] if isinstance(self.code, tuple) else self.code,
|
||||
self.FLAG_NAME: self.name[0] if isinstance(self.name, tuple) else self.name,
|
||||
self.FLAG_DESCRIPTION: self.description[0] if isinstance(self.description, tuple) else self.description,
|
||||
self.FLAG_DISPLAY_ORDER: self.display_order,
|
||||
self.FLAG_ACTIVE: self.active,
|
||||
self.FLAG_CAN_VIEW: self.can_view,
|
||||
self.FLAG_CAN_EDIT: self.can_edit,
|
||||
self.FLAG_CAN_ADMIN: self.can_admin
|
||||
}
|
||||
@classmethod
|
||||
def from_json(cls, json):
|
||||
print(f' Category.from_json: {json}')
|
||||
category = cls()
|
||||
category.id_category = json[cls.ATTR_ID_PRODUCT_CATEGORY],
|
||||
category.code = json[cls.ATTR_CODE_CATEGORY],
|
||||
category.name = json[cls.ATTR_NAME_CATEGORY],
|
||||
category.description = json[cls.ATTR_DESCRIPTION_CATEGORY],
|
||||
category.display_order = json[cls.ATTR_DISPLAY_ORDER_CATEGORY]
|
||||
category.id_category = json.get(cls.ATTR_ID_PRODUCT_CATEGORY),
|
||||
category.code = json[cls.FLAG_CODE],
|
||||
category.name = json[cls.FLAG_NAME],
|
||||
category.description = json[cls.FLAG_DESCRIPTION],
|
||||
category.display_order = json[cls.FLAG_DISPLAY_ORDER]
|
||||
category.active = json[cls.FLAG_ACTIVE]
|
||||
category.can_view = json.get(cls.FLAG_CAN_VIEW, False)
|
||||
category.can_edit = json.get(cls.FLAG_CAN_EDIT, False)
|
||||
category.can_admin = json.get(cls.FLAG_CAN_ADMIN, False)
|
||||
return category
|
||||
|
||||
def to_json_str(self):
|
||||
return {
|
||||
self.ATTR_ID_PRODUCT_CATEGORY: self.id_category[0] if isinstance(self.id_category, tuple) else self.id_category,
|
||||
self.FLAG_CODE: self.code[0] if isinstance(self.code, tuple) else self.code,
|
||||
self.FLAG_NAME: self.name[0] if isinstance(self.name, tuple) else self.name,
|
||||
self.FLAG_DESCRIPTION: self.description[0] if isinstance(self.description, tuple) else self.description,
|
||||
self.FLAG_DISPLAY_ORDER: self.display_order,
|
||||
self.FLAG_ACTIVE: self.output_bool(self.active),
|
||||
self.FLAG_CAN_VIEW: self.output_bool(self.can_view),
|
||||
self.FLAG_CAN_EDIT: self.output_bool(self.can_edit),
|
||||
self.FLAG_CAN_ADMIN: self.output_bool(self.can_admin)
|
||||
}
|
||||
@staticmethod
|
||||
def output_bool(value):
|
||||
return av.input_bool(value, 'Product_Category bool attribute', 'Product_Category.output_bool')
|
||||
"""
|
||||
class Filters_Product_Category(BaseModel, Store_Base):
|
||||
ids_product_category: str
|
||||
ids_product: str
|
||||
"""
|
||||
""
|
||||
def __new__(cls, product_ids, product_categories):
|
||||
_m = 'Product_Filters.__new__'
|
||||
_m = 'Filters_Product.__new__'
|
||||
v_arg_type = 'class attribute'
|
||||
# av.val_list_instances(product_ids, 'product_ids', _m, str, v_arg_type=v_arg_type)
|
||||
# av.val_list_instances(product_categories, 'product_categories', _m, Product_Category_Enum, v_arg_type=v_arg_type)
|
||||
av.val_str(product_ids, 'product_ids', _m, v_arg_type=v_arg_type)
|
||||
av.val_str(product_categories, 'product_categories', _m, v_arg_type=v_arg_type)
|
||||
return super(Filters_Product_Category, cls).__new__(cls)
|
||||
"""
|
||||
""
|
||||
def __init__(self, ids_product, ids_product_category):
|
||||
super().__init__(ids_product=ids_product, ids_product_category=ids_product_category)
|
||||
"""
|
||||
""
|
||||
# Constructor
|
||||
self.ids = product_ids
|
||||
self.categories = product_categories
|
||||
"""
|
||||
""
|
||||
@classmethod
|
||||
def get_default(cls):
|
||||
return Filters_Product_Category(
|
||||
ids_product_category = '',
|
||||
ids_product = ''
|
||||
)
|
||||
def to_json(self):
|
||||
return {
|
||||
'a_ids_product_category': self.ids_product_category,
|
||||
'a_ids_product': self.ids_product
|
||||
}
|
||||
@classmethod
|
||||
def from_json(cls, json):
|
||||
filters = cls()
|
||||
filters.ids_product_category = json['a_ids_product_category'],
|
||||
filters.ids_product = json['a_ids_product']
|
||||
"""
|
||||
class Filters_Product_Category(BaseModel, Store_Base):
|
||||
is_not_empty_only: bool
|
||||
active_only: bool
|
||||
def __init__(self, is_not_empty_only, active_only):
|
||||
super().__init__(is_not_empty_only=is_not_empty_only, active_only=active_only)
|
||||
@classmethod
|
||||
def get_default(cls):
|
||||
return cls(
|
||||
is_not_empty_only = False,
|
||||
active_only = True
|
||||
)
|
||||
def to_json(self):
|
||||
return {
|
||||
'is_not_empty_only': self.is_not_empty_only,
|
||||
'active_only': self.active_only
|
||||
}
|
||||
@classmethod
|
||||
def from_json(cls, json):
|
||||
return cls(
|
||||
is_not_empty_only = json['is_not_empty_only'],
|
||||
active_only = json['active_only']
|
||||
)
|
||||
@classmethod
|
||||
def from_form(cls, form):
|
||||
return cls(
|
||||
is_not_empty_only = av.input_bool(form.is_not_empty.data, 'is_not_empty', 'Filters_Product_Category.from_form'),
|
||||
active_only = av.input_bool(form.active.data, 'active', 'Filters_Product_Category.from_form')
|
||||
)
|
||||
|
||||
class Container_Product_Category(Store_Base):
|
||||
categories: list
|
||||
@@ -311,7 +385,7 @@ class Container_Product_Category(Store_Base):
|
||||
for category in self.categories:
|
||||
list_rows += category.to_list_rows_permutation()
|
||||
return list_rows
|
||||
def to_list_categories(self):
|
||||
def to_list_category_options(self):
|
||||
list_categories = []
|
||||
for category in self.categories:
|
||||
list_categories.append({'value': category.id_category, 'text': category.name})
|
||||
@@ -327,4 +401,12 @@ class Container_Product_Category(Store_Base):
|
||||
dict_lists_products = {}
|
||||
for category in self.categories:
|
||||
dict_lists_products[category.id_category] = category.to_list_products()
|
||||
return dict_lists_products
|
||||
return dict_lists_products
|
||||
def to_json(self):
|
||||
return {
|
||||
'categories': [category.to_json() for category in self.categories]
|
||||
}
|
||||
def to_json_str(self):
|
||||
return {
|
||||
'categories': [category.to_json_str() for category in self.categories]
|
||||
}
|
||||
@@ -13,7 +13,7 @@ Business object for product permutation
|
||||
# internal
|
||||
import lib.argument_validation as av
|
||||
from lib import data_types
|
||||
from forms import Form_Basket_Add, Form_Basket_Edit, Form_Filters_Permutation
|
||||
from forms.forms import Form_Basket_Add, Form_Basket_Edit, Form_Filters_Permutation
|
||||
from business_objects.store.delivery_option import Delivery_Option
|
||||
from business_objects.store.discount import Discount
|
||||
from business_objects.store.image import Image
|
||||
@@ -55,6 +55,7 @@ class Product_Permutation(db.Model, Store_Base):
|
||||
name_recurrence_interval = db.Column(db.String(255))
|
||||
name_plural_recurrence_interval = db.Column(db.String(256))
|
||||
count_recurrence_interval = db.Column(db.Integer)
|
||||
active = db.Column(db.Boolean)
|
||||
display_order = db.Column(db.Integer)
|
||||
can_view = db.Column(db.Boolean)
|
||||
can_edit = db.Column(db.Boolean)
|
||||
@@ -89,32 +90,30 @@ class Product_Permutation(db.Model, Store_Base):
|
||||
v_arg_type = 'class attribute'
|
||||
print(f'query_row: {query_row}')
|
||||
permutation = Product_Permutation()
|
||||
permutation.id_product = query_row[0]
|
||||
permutation.id_permutation = query_row[1]
|
||||
# permutation.name = query_row[2]
|
||||
permutation.id_permutation = query_row[0]
|
||||
permutation.id_product = query_row[1]
|
||||
permutation.id_category = query_row[2]
|
||||
permutation.description = query_row[3]
|
||||
# permutation.price_GBP_full = query_row[4]
|
||||
# permutation.price_GBP_min = query_row[5]
|
||||
permutation.id_currency_cost = query_row[7]
|
||||
permutation.code_currency_cost = query_row[8]
|
||||
permutation.symbol_currency_cost = query_row[9]
|
||||
permutation.cost_local = query_row[6]
|
||||
permutation.has_variations = query_row[4]
|
||||
permutation.id_category = query_row[5]
|
||||
permutation.latency_manufacture = query_row[11]
|
||||
permutation.quantity_min = query_row[12]
|
||||
permutation.quantity_max = query_row[13]
|
||||
permutation.quantity_step = query_row[14]
|
||||
permutation.quantity_stock = query_row[15]
|
||||
permutation.id_stripe_product = query_row[16]
|
||||
permutation.is_subscription = av.input_bool(query_row[17], "is_subscription", _m, v_arg_type=v_arg_type)
|
||||
permutation.name_recurrence_interval = query_row[18]
|
||||
permutation.name_plural_recurrence_interval = query_row[19]
|
||||
permutation.count_recurrence_interval = query_row[20]
|
||||
permutation.display_order = query_row[23]
|
||||
permutation.can_view = av.input_bool(query_row[24], "can_view", _m, v_arg_type=v_arg_type)
|
||||
permutation.can_edit = av.input_bool(query_row[25], "can_edit", _m, v_arg_type=v_arg_type)
|
||||
permutation.can_admin = av.input_bool(query_row[26], "can_admin", _m, v_arg_type=v_arg_type)
|
||||
permutation.cost_local = query_row[4]
|
||||
permutation.id_currency_cost = query_row[5]
|
||||
permutation.code_currency_cost = query_row[6]
|
||||
permutation.symbol_currency_cost = query_row[7]
|
||||
# permutation.profit_local_min = query_row[8]
|
||||
permutation.latency_manufacture = query_row[9]
|
||||
permutation.quantity_min = query_row[10]
|
||||
permutation.quantity_max = query_row[11]
|
||||
permutation.quantity_step = query_row[12]
|
||||
permutation.quantity_stock = query_row[13]
|
||||
permutation.id_stripe_product = query_row[14]
|
||||
permutation.is_subscription = av.input_bool(query_row[15], "is_subscription", _m, v_arg_type=v_arg_type)
|
||||
permutation.name_recurrence_interval = query_row[16]
|
||||
permutation.name_plural_recurrence_interval = query_row[17]
|
||||
permutation.count_recurrence_interval = query_row[18]
|
||||
permutation.active = query_row[19]
|
||||
permutation.display_order = query_row[20]
|
||||
permutation.can_view = av.input_bool(query_row[21], "can_view", _m, v_arg_type=v_arg_type)
|
||||
permutation.can_edit = av.input_bool(query_row[22], "can_edit", _m, v_arg_type=v_arg_type)
|
||||
permutation.can_admin = av.input_bool(query_row[23], "can_admin", _m, v_arg_type=v_arg_type)
|
||||
return permutation
|
||||
|
||||
def from_DB_Stripe_product(query_row):
|
||||
|
||||
@@ -11,7 +11,7 @@ Feature: Stock Item Business Object
|
||||
# internal
|
||||
import lib.argument_validation as av
|
||||
from lib import data_types
|
||||
from forms import Form_Filters_Stock_Item
|
||||
from forms.forms import Form_Filters_Stock_Item
|
||||
from business_objects.store.product_price import Product_Price
|
||||
# from business_objects.discount import Discount
|
||||
from business_objects.store.store_base import Store_Base
|
||||
@@ -272,10 +272,10 @@ class Stock_Item_Filters():
|
||||
@staticmethod
|
||||
def from_form(form):
|
||||
# if not (form is Form_Filters_Permutations): raise ValueError(f'Invalid form type: {type(form)}')
|
||||
av.val_instance(form, 'form', 'Product_Filters.from_form', Form_Filters_Stock_Item)
|
||||
av.val_instance(form, 'form', 'Filters_Product.from_form', Form_Filters_Stock_Item)
|
||||
has_category_filter = not (form.id_category.data == '0' or form.id_category.data == '')
|
||||
has_product_filter = not (form.id_product.data == '0' or form.id_product.data == '')
|
||||
get_permutations_stock_below_min = av.input_bool(form.is_out_of_stock.data, "is_out_of_stock", "Product_Filters.from_form")
|
||||
get_permutations_stock_below_min = av.input_bool(form.is_out_of_stock.data, "is_out_of_stock", "Filters_Product.from_form")
|
||||
print(f'form question: {type(form.is_out_of_stock)}\nbool interpretted: {get_permutations_stock_below_min}\type form: {type(form)}')
|
||||
return Stock_Item_Filters(
|
||||
get_all_category = not has_category_filter,
|
||||
|
||||
@@ -15,20 +15,27 @@ Abstract business object for store objects
|
||||
from typing import ClassVar
|
||||
|
||||
class Store_Base():
|
||||
ATTR_ID_CURRENCY: ClassVar[str] = 'id-currency'
|
||||
# ATTR_ID_CURRENCY_COST: ClassVar[str] = 'id-currency-cost'
|
||||
ATTR_ID_DELIVERY_REGION: ClassVar[str] = 'id-delivery-region'
|
||||
ATTR_ID_DISCOUNT: ClassVar[str] = 'id-discount'
|
||||
ATTR_ID_IMAGE: ClassVar[str] = 'id-image'
|
||||
ATTR_ID_LOCATION_STORAGE: ClassVar[str] = 'id-location-storage'
|
||||
ATTR_ID_PRODUCT: ClassVar[str] = 'id-product'
|
||||
ATTR_ID_PRODUCT_CATEGORY: ClassVar[str] = 'id-category'
|
||||
ATTR_ID_PRODUCT_PERMUTATION: ClassVar[str] = 'id-permutation'
|
||||
ATTR_ID_PRODUCT_PRICE: ClassVar[str] = 'id-price'
|
||||
ATTR_ID_PRODUCT_VARIATION: ClassVar[str] = 'id-variation'
|
||||
ATTR_ID_CURRENCY: ClassVar[str] = 'id_currency'
|
||||
# ATTR_ID_CURRENCY_COST: ClassVar[str] = 'id_currency_cost'
|
||||
ATTR_ID_DELIVERY_REGION: ClassVar[str] = 'id_delivery_region'
|
||||
ATTR_ID_DISCOUNT: ClassVar[str] = 'id_discount'
|
||||
ATTR_ID_IMAGE: ClassVar[str] = 'id_image'
|
||||
ATTR_ID_LOCATION_STORAGE: ClassVar[str] = 'id_location_storage'
|
||||
ATTR_ID_PRODUCT: ClassVar[str] = 'id_product'
|
||||
ATTR_ID_PRODUCT_CATEGORY: ClassVar[str] = 'id_category'
|
||||
ATTR_ID_PRODUCT_PERMUTATION: ClassVar[str] = 'id_permutation'
|
||||
ATTR_ID_PRODUCT_PRICE: ClassVar[str] = 'id_price'
|
||||
ATTR_ID_PRODUCT_VARIATION: ClassVar[str] = 'id_variation'
|
||||
ATTR_ID_PRODUCT_VARIATION_TYPE: ClassVar[str] = 'id_variation_type'
|
||||
ATTR_ID_STOCK_ITEM: ClassVar[str] = 'id-stock-item'
|
||||
ATTR_ID_STOCK_ITEM: ClassVar[str] = 'id_stock_item'
|
||||
FLAG_ACTIVE: ClassVar[str] = 'active'
|
||||
FLAG_CAN_ADMIN: ClassVar[str] = 'can_admin'
|
||||
FLAG_CAN_EDIT: ClassVar[str] = 'can_edit'
|
||||
FLAG_CAN_VIEW: ClassVar[str] = 'can_view'
|
||||
FLAG_CODE: ClassVar[str] = 'code'
|
||||
FLAG_DESCRIPTION: ClassVar[str] = 'description'
|
||||
FLAG_DISPLAY_ORDER: ClassVar[str] = 'display_order'
|
||||
FLAG_NAME: ClassVar[str] = 'name'
|
||||
|
||||
def __init_subclass__(cls, **kwargs):
|
||||
super().__init_subclass__(**kwargs)
|
||||
@@ -54,4 +61,5 @@ class Store_Base():
|
||||
def from_json(cls, json):
|
||||
pass
|
||||
def to_json(self):
|
||||
pass
|
||||
pass
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ Business objects for Stripe
|
||||
# internal
|
||||
import lib.argument_validation as av
|
||||
from lib import data_types
|
||||
from forms import Form_Basket_Add, Form_Basket_Edit # Form_Product
|
||||
from forms.forms import Form_Basket_Add, Form_Basket_Edit # Form_Product
|
||||
from extensions import db
|
||||
|
||||
# external
|
||||
|
||||
@@ -9,7 +9,7 @@ Feature: User Business Object
|
||||
|
||||
# internal
|
||||
import lib.argument_validation as av
|
||||
from forms import Form_Filters_User
|
||||
from forms.forms import Form_Filters_User
|
||||
from extensions import db
|
||||
# external
|
||||
from dataclasses import dataclass
|
||||
|
||||
Reference in New Issue
Block a user