feat(MySQL): Get Many stored procedures created for product variations with variation types and product prices with discounts and delivery options.
This commit is contained in:
@@ -16,18 +16,17 @@ Data model for store product view
|
||||
|
||||
# IMPORTS
|
||||
# internal
|
||||
from business_objects.store.product import Product, Parameters_Product
|
||||
from business_objects.store.product_category import Product_Category_Container
|
||||
from datastores.datastore_store_product import DataStore_Store_Product
|
||||
from forms.store.product import Filters_Product
|
||||
from models.model_view_store import Model_View_Store
|
||||
from datastores.datastore_store_base import DataStore_Store_Base
|
||||
# from routes import bp_home
|
||||
from business_objects.store.product import Product, Filters_Product
|
||||
import lib.argument_validation as av
|
||||
# external
|
||||
from typing import ClassVar
|
||||
|
||||
|
||||
# VARIABLE INSTANTIATION
|
||||
|
||||
|
||||
# CLASSES
|
||||
"""
|
||||
class Model_View_Store_Product(Model_View_Store):
|
||||
# categories: list # (str)
|
||||
# category_products: dict { category_enum_id: List[Product] }
|
||||
@@ -44,7 +43,7 @@ class Model_View_Store_Product(Model_View_Store):
|
||||
super().__init__(hash_page_current=hash_page_current, id_currency=id_currency, id_region_delivery=id_region_delivery, is_included_VAT=is_included_VAT)
|
||||
print('supered')
|
||||
|
||||
category_list = DataStore_Store_Base().get_many_product(Filters_Product(
|
||||
category_list = DataStore_Store_Base().get_many_product(Parameters_Product(
|
||||
self.info_user['sub'],
|
||||
True, '', False,
|
||||
True, '', False, False,
|
||||
@@ -57,10 +56,69 @@ class Model_View_Store_Product(Model_View_Store):
|
||||
print('connection to db successful')
|
||||
# self.categories = categories
|
||||
# self.category_index = category_index
|
||||
"""
|
||||
""
|
||||
if (category_list.get_category_count() > 0):
|
||||
self.product = category_list.get_permutation_first()
|
||||
else:
|
||||
self.product = None
|
||||
print('selected permutation selected')
|
||||
"""
|
||||
""
|
||||
"""
|
||||
|
||||
|
||||
class Model_View_Store_Product(Model_View_Store):
|
||||
category_list: Product_Category_Container = None
|
||||
category_list_filters: Product_Category_Container = None
|
||||
currencies: list = None
|
||||
currency_options: list = None
|
||||
filters_product: Parameters_Product = None
|
||||
form_filters: Filters_Product
|
||||
list_options_product: list = None
|
||||
product_blank: Product = None
|
||||
units_measurement: list = None
|
||||
units_measurement_time: list = None
|
||||
# variation_container: Product_Variation_Container = None
|
||||
variations: list = None
|
||||
variation_types: list = None
|
||||
|
||||
@property
|
||||
def title(self):
|
||||
return 'Products'
|
||||
|
||||
def __init__(self, form_filters, hash_page_current=Model_View_Store.HASH_PAGE_STORE_PRODUCTS):
|
||||
_m = 'Model_View_Store_Permutation.__init__'
|
||||
print(f'{_m}\nstarting...')
|
||||
super().__init__(hash_page_current=hash_page_current, form_filters=form_filters)
|
||||
parameters_product = Parameters_Product.from_form_filters_product(self.form_filters)
|
||||
datastore_store = DataStore_Store_Product()
|
||||
self.category_list, errors = datastore_store.get_many_product(parameters_product)
|
||||
self.category_list_filters, errors_filters = datastore_store.get_many_product(
|
||||
Parameters_Product(
|
||||
get_all_product_category = True,
|
||||
get_inactive_product_category = False,
|
||||
ids_product_category = '',
|
||||
get_all_product = True,
|
||||
get_inactive_product = False,
|
||||
ids_product = '',
|
||||
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 = parameters_product.get_products_quantity_stock_below_min
|
||||
)
|
||||
)
|
||||
print(f'category filters: {self.category_list_filters.categories}')
|
||||
self.form_filters.id_category.choices = [('0', 'All')] + [(str(category.id_category), category.name) for category in self.category_list_filters.categories]
|
||||
print(f'category options: {self.form_filters.id_category.choices}')
|
||||
self.variation_types, self.variations, errors = self.get_many_product_variation()
|
||||
self.units_measurement = self.get_many_unit_measurement()
|
||||
self.units_measurement_time = [unit_measurement for unit_measurement in self.units_measurement if unit_measurement.is_unit_of_time]
|
||||
self.currencies = self.get_many_currency()
|
||||
self.currency_options = [currency.to_json_option() for currency in self.currencies]
|
||||
|
||||
@staticmethod
|
||||
def save_products(comment, list_products):
|
||||
_m = 'Model_View_Store_Product.save_products'
|
||||
DataStore_Store_Product.save_products(comment, list_products)
|
||||
Reference in New Issue
Block a user