feat(web): Store Product UI created and hooked up for viewing, editing, and saving.
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -204,6 +204,7 @@ class Model_View_Base(BaseModel, ABC):
|
||||
session: None = None
|
||||
is_page_store: bool = None
|
||||
is_user_logged_in: bool = None
|
||||
user: User = None
|
||||
access_levels: list = None
|
||||
|
||||
model_config = ConfigDict(arbitrary_types_allowed=True)
|
||||
@@ -253,6 +254,7 @@ class Model_View_Base(BaseModel, ABC):
|
||||
|
||||
datastore_user = DataStore_User()
|
||||
user = datastore_user.get_user_session()
|
||||
self.user = user
|
||||
self.is_user_logged_in = user.is_logged_in
|
||||
|
||||
def output_bool(self, boolean):
|
||||
@@ -318,13 +320,13 @@ class Model_View_Base(BaseModel, ABC):
|
||||
return {getattr(obj, key): obj.to_json() for obj in list_objects}
|
||||
@staticmethod
|
||||
def convert_list_objects_to_dict_by_attribute_key_default(list_objects):
|
||||
if len(list_objects) == 0:
|
||||
if list_objects is None or len(list_objects) == 0:
|
||||
return {}
|
||||
obj_class = list_objects[0].__class__
|
||||
return Model_View_Base.convert_list_objects_to_dict_by_attribute_key(list_objects, getattr(obj_class, obj_class.FLAG_NAME_ATTR_OPTION_VALUE))
|
||||
@staticmethod
|
||||
def convert_list_objects_to_dict_json_by_attribute_key_default(list_objects):
|
||||
if len(list_objects) == 0:
|
||||
if list_objects is None or len(list_objects) == 0:
|
||||
return {}
|
||||
obj_class = list_objects[0].__class__
|
||||
return Model_View_Base.convert_list_objects_to_dict_json_by_attribute_key(list_objects, getattr(obj_class, obj_class.FLAG_NAME_ATTR_OPTION_VALUE))
|
||||
|
||||
@@ -104,9 +104,9 @@ class Model_View_Store(Model_View_Base):
|
||||
HASH_STORE_BASKET_LOAD : ClassVar[str] = '/store/basket_load'
|
||||
HASH_GET_STORE_PRODUCT: ClassVar[str] = '/store/product_get'
|
||||
HASH_GET_STORE_PRODUCT_CATEGORY: ClassVar[str] = '/store/category_get'
|
||||
HASH_SAVE_STORE_PRODUCT: ClassVar[str] = '/store/save_product'
|
||||
HASH_GET_STORE_PRODUCT_PERMUTATION: ClassVar[str] = '/store/permutation_get'
|
||||
HASH_GET_STORE_STOCK_ITEM: ClassVar[str] = '/store/stock_item_get'
|
||||
HASH_SAVE_STORE_PRODUCT: ClassVar[str] = '/store/save_product'
|
||||
HASH_SAVE_STORE_PRODUCT_CATEGORY: ClassVar[str] = '/store/save_category'
|
||||
HASH_SAVE_STORE_PRODUCT_PERMUTATION: ClassVar[str] = '/store/save_permutation'
|
||||
HASH_SAVE_STORE_STOCK_ITEM: ClassVar[str] = '/store/save_stock_item'
|
||||
|
||||
@@ -19,6 +19,7 @@ Data model for store product view
|
||||
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.access_level import Filters_Access_Level
|
||||
from forms.store.product import Filters_Product
|
||||
from models.model_view_store import Model_View_Store
|
||||
# from routes import bp_home
|
||||
@@ -86,12 +87,17 @@ class Model_View_Store_Product(Model_View_Store):
|
||||
return 'Products'
|
||||
|
||||
def __init__(self, form_filters, hash_page_current=Model_View_Store.HASH_PAGE_STORE_PRODUCTS):
|
||||
_m = 'Model_View_Store_Permutation.__init__'
|
||||
_m = 'Model_View_Store_Product.__init__'
|
||||
print(f'{_m}\nstarting...')
|
||||
super().__init__(hash_page_current=hash_page_current, form_filters=form_filters)
|
||||
self.access_levels = self.get_many_access_level(Filters_Access_Level())
|
||||
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, errors = datastore_store.get_many_product(parameters_product)
|
||||
countProducts = 0
|
||||
for category in self.category_list.categories:
|
||||
countProducts += len(category.products)
|
||||
print(f'category count: {len(self.category_list.categories)}\nproduct count: {countProducts}')
|
||||
self.category_list_filters, errors_filters = datastore_store.get_many_product(
|
||||
Parameters_Product(
|
||||
get_all_product_category = True,
|
||||
@@ -110,7 +116,7 @@ class Model_View_Store_Product(Model_View_Store):
|
||||
)
|
||||
)
|
||||
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]
|
||||
self.form_filters.id_category.choices += [(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()
|
||||
@@ -118,7 +124,8 @@ class Model_View_Store_Product(Model_View_Store):
|
||||
self.currencies = self.get_many_currency()
|
||||
self.currency_options = [currency.to_json_option() for currency in self.currencies]
|
||||
|
||||
print(f'category count: {len(self.category_list.categories)}\nproduct count: {countProducts}')
|
||||
@staticmethod
|
||||
def save_products(comment, list_products):
|
||||
_m = 'Model_View_Store_Product.save_products'
|
||||
DataStore_Store_Product.save_products(comment, list_products)
|
||||
return DataStore_Store_Product.save_products(comment, list_products)
|
||||
Reference in New Issue
Block a user