1. Refactoring form objects and database objects to use inheritance and abstract base class for consistency and reduced redundancy.\n2. Contact us page button links updated to resolve error of missing link causing page refresh instead of expected functionality.
This commit is contained in:
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.
@@ -13,8 +13,9 @@ Datastore for Store
|
||||
# internal
|
||||
# from routes import bp_home
|
||||
import lib.argument_validation as av
|
||||
from business_objects.store.access_level import Access_Level, Filters_Access_Level
|
||||
from business_objects.store.basket import Basket, Basket_Item
|
||||
from business_objects.store.product_category import Container_Product_Category, Product_Category
|
||||
from business_objects.store.product_category import Product_Category_Container, Product_Category
|
||||
from business_objects.store.currency import Currency
|
||||
from business_objects.store.image import Image
|
||||
from business_objects.store.delivery_option import Delivery_Option
|
||||
@@ -26,7 +27,7 @@ from business_objects.sql_error import SQL_Error
|
||||
from business_objects.store.stock_item import Stock_Item, Stock_Item_Filters
|
||||
from business_objects.user import User, User_Filters, User_Permission_Evaluation
|
||||
from business_objects.store.product_variation import Product_Variation, Product_Variation_Filters, Product_Variation_List
|
||||
from helpers.helper_db_mysql import Helper_DB_MySQL
|
||||
# from helpers.helper_db_mysql import Helper_DB_MySQL
|
||||
# from models.model_view_store_checkout import Model_View_Store_Checkout # circular!
|
||||
from extensions import db
|
||||
# external
|
||||
@@ -164,17 +165,52 @@ class DataStore_Base(BaseModel):
|
||||
def get_user_auth0():
|
||||
return User.from_json_auth0(session.get(current_app.config['ID_TOKEN_USER']))
|
||||
@staticmethod
|
||||
def upload_bulk(objects, objectType, batch_size):
|
||||
def upload_bulk(permanent_table_name, records, batch_size):
|
||||
_m = 'DataStore_Base.upload_bulk'
|
||||
print(f'{_m}\nstarting...')
|
||||
try:
|
||||
for i in range(0, len(objects), batch_size):
|
||||
batch = objects[i:i+batch_size]
|
||||
for i in range(0, len(records), batch_size):
|
||||
batch = records[i:i+batch_size]
|
||||
data = [object.to_json() for object in batch]
|
||||
print(f'batch: {batch}\ndata: {data}')
|
||||
db.session.bulk_insert_mappings(objectType, data)
|
||||
db.session.bulk_insert_mappings(permanent_table_name, data)
|
||||
db.session.commit()
|
||||
except Exception as e:
|
||||
print(f'{_m}\n{e}')
|
||||
db.session.rollback()
|
||||
raise e
|
||||
raise e
|
||||
@classmethod
|
||||
def get_many_access_level(cls, filters):
|
||||
_m = 'DataStore_Store_Base.get_many_access_level'
|
||||
av.val_instance(filters, 'filters', _m, Filters_Access_Level)
|
||||
argument_dict = filters.to_json()
|
||||
# user = cls.get_user_session()
|
||||
# argument_dict['a_id_user'] = 1 # 'auth0|6582b95c895d09a70ba10fef' # id_user
|
||||
print(f'argument_dict: {argument_dict}')
|
||||
print('executing p_shop_get_many_access_level')
|
||||
result = cls.db_procedure_execute('p_shop_get_many_access_level', argument_dict)
|
||||
cursor = result.cursor
|
||||
print('data received')
|
||||
|
||||
# access_levels
|
||||
result_set_1 = cursor.fetchall()
|
||||
print(f'raw access levels: {result_set_1}')
|
||||
access_levels = []
|
||||
for row in result_set_1:
|
||||
new_access_level = Access_Level.from_DB_access_level(row)
|
||||
access_levels.append(new_access_level)
|
||||
|
||||
# Errors
|
||||
cursor.nextset()
|
||||
result_set_e = cursor.fetchall()
|
||||
print(f'raw errors: {result_set_e}')
|
||||
errors = []
|
||||
if len(result_set_e) > 0:
|
||||
errors = [SQL_Error.from_DB_record(row) for row in result_set_e] # (row[0], row[1])
|
||||
for error in errors:
|
||||
print(f"Error [{error.code}]: {error.msg}")
|
||||
|
||||
DataStore_Base.db_cursor_clear(cursor)
|
||||
cursor.close()
|
||||
|
||||
return access_levels, errors
|
||||
@@ -13,8 +13,9 @@ Datastore for Store
|
||||
# internal
|
||||
# from routes import bp_home
|
||||
import lib.argument_validation as av
|
||||
# from business_objects.store.access_level import Access_Level, Filters_Access_Level
|
||||
from business_objects.store.basket import Basket, Basket_Item
|
||||
from business_objects.store.product_category import Container_Product_Category, Product_Category
|
||||
from business_objects.store.product_category import Product_Category_Container, Product_Category
|
||||
from business_objects.store.currency import Currency
|
||||
from business_objects.store.image import Image
|
||||
from business_objects.store.delivery_option import Delivery_Option
|
||||
@@ -27,7 +28,7 @@ from business_objects.store.stock_item import Stock_Item, Stock_Item_Filters
|
||||
from business_objects.user import User, User_Filters, User_Permission_Evaluation
|
||||
from business_objects.store.product_variation import Product_Variation, Product_Variation_Filters, Product_Variation_List
|
||||
from datastores.datastore_base import DataStore_Base
|
||||
from helpers.helper_db_mysql import Helper_DB_MySQL
|
||||
# from helpers.helper_db_mysql import Helper_DB_MySQL
|
||||
# from models.model_view_store_checkout import Model_View_Store_Checkout # circular!
|
||||
from extensions import db
|
||||
# external
|
||||
@@ -69,7 +70,7 @@ class DataStore_Store_Base(DataStore_Base):
|
||||
print('data received')
|
||||
|
||||
|
||||
category_list = Container_Product_Category()
|
||||
category_list = Product_Category_Container()
|
||||
# Categories
|
||||
result_set_1 = cursor.fetchall()
|
||||
print(f'raw categories: {result_set_1}')
|
||||
@@ -77,10 +78,10 @@ class DataStore_Store_Base(DataStore_Base):
|
||||
# categories = []
|
||||
# category_index = {}
|
||||
for row in result_set_1:
|
||||
new_category = Product_Category.from_DB_product(row) # Product_Category(row[0], row[1], row[2], row[3])
|
||||
new_category = Product_Category.from_DB_get_many_product_catalogue(row) # Product_Category(row[0], row[1], row[2], row[3])
|
||||
# category_index[new_category.id_category] = len(categories)
|
||||
# categories.append(new_category)
|
||||
category_list.add_category(new_category)
|
||||
category_list.add_product_category(new_category)
|
||||
# print(f'categories: {[c.id_category for c in categories]}')
|
||||
|
||||
# Products
|
||||
@@ -90,7 +91,7 @@ class DataStore_Store_Base(DataStore_Base):
|
||||
# products = [] # [Product(**row) for row in result_set_2]
|
||||
# product_index = {}
|
||||
for row in result_set_2:
|
||||
new_product = Product.from_DB_product(row) # (row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8], row[9], row[10], row[11], row[12], row[13], row[14], row[15], row[16], row[17], row[18], row[19])
|
||||
new_product = Product.from_DB_get_many_product_catalogue(row) # (row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8], row[9], row[10], row[11], row[12], row[13], row[14], row[15], row[16], row[17], row[18], row[19])
|
||||
index_category = category_list.get_index_category_from_id(new_product.id_category)
|
||||
category = category_list.categories[index_category]
|
||||
category_list.add_product(new_product)
|
||||
@@ -104,10 +105,10 @@ class DataStore_Store_Base(DataStore_Base):
|
||||
permutations = [] # [Product(**row) for row in result_set_2]
|
||||
# permutation_index = {}
|
||||
for row in result_set_3:
|
||||
new_permutation = Product_Permutation.from_DB_product(row) # (row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8], row[9], row[10], row[11], row[12], row[13], row[14], row[15], row[16], row[17], row[18], row[19])
|
||||
new_permutation = Product_Permutation.from_DB_get_many_product_catalogue(row) # (row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8], row[9], row[10], row[11], row[12], row[13], row[14], row[15], row[16], row[17], row[18], row[19])
|
||||
index_category = category_list.get_index_category_from_id(new_permutation.id_category)
|
||||
category = category_list.categories[index_category]
|
||||
category_list.add_permutation(new_permutation)
|
||||
category_list.add_product_permutation(new_permutation)
|
||||
print(f'category_list: {category_list}')
|
||||
|
||||
# Product_Variations
|
||||
@@ -117,13 +118,13 @@ class DataStore_Store_Base(DataStore_Base):
|
||||
# variations = [Product_Variation(**row) for row in result_set_4]
|
||||
variations = []
|
||||
for row in result_set_4:
|
||||
new_variation = Product_Variation.from_DB_product(row) # (row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7])
|
||||
new_variation = Product_Variation.from_DB_get_many_product_catalogue(row) # (row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7])
|
||||
variations.append(new_variation)
|
||||
# products[product_index[new_variation.id_product]].variations.append(new_variation)
|
||||
# index_category = category_index[new_variation.id_category]
|
||||
# index_product = categories[index_category].index_product_from_ids_product_permutation(new_variation.id_product, new_variation.id_permutation)
|
||||
# categories[index_category].products[index_product].variations.append(new_variation)
|
||||
category_list.add_variation(new_variation)
|
||||
category_list.add_product_variation(new_variation)
|
||||
# print(f'variations: {variations}')
|
||||
# print(f'products: {[p.id_product for p in products]}')
|
||||
|
||||
@@ -134,7 +135,7 @@ class DataStore_Store_Base(DataStore_Base):
|
||||
# images = [Image(**row) for row in result_set_5]
|
||||
images = []
|
||||
for row in result_set_5:
|
||||
new_image = Image.from_DB_product(row) # (row[0], row[1], row[2], row[3], row[4])
|
||||
new_image = Image.from_DB_get_many_product_catalogue(row) # (row[0], row[1], row[2], row[3], row[4])
|
||||
images.append(new_image)
|
||||
# products[product_index[new_image.id_product]].images.append(new_image)
|
||||
"""
|
||||
@@ -142,7 +143,7 @@ class DataStore_Store_Base(DataStore_Base):
|
||||
index_product = categories[index_category].index_product_from_ids_product_permutation(new_image.id_product, new_image.id_permutation)
|
||||
categories[index_category].products[index_product].images.append(new_image)
|
||||
"""
|
||||
category_list.add_image(new_image)
|
||||
category_list.add_product_image(new_image)
|
||||
# print(f'images: {images}')
|
||||
# print(f'products: {[p.id_product for p in products]}')
|
||||
|
||||
@@ -156,7 +157,7 @@ class DataStore_Store_Base(DataStore_Base):
|
||||
for error in errors:
|
||||
print(f"Error [{error.code}]: {error.msg}")
|
||||
|
||||
category_list.get_all_variation_trees()
|
||||
category_list.get_all_product_variation_trees()
|
||||
"""
|
||||
for category in category_list.categories:
|
||||
print(f'category: {category.name}')
|
||||
@@ -283,7 +284,7 @@ class DataStore_Store_Base(DataStore_Base):
|
||||
variations = Product_Variation_List()
|
||||
for row in result_set:
|
||||
new_variation = Product_Variation.from_DB_variation(row)
|
||||
variations.add_variation(new_variation)
|
||||
variations.add_product_variation(new_variation)
|
||||
|
||||
errors = []
|
||||
cursor.nextset()
|
||||
@@ -298,4 +299,5 @@ class DataStore_Store_Base(DataStore_Base):
|
||||
|
||||
cursor.close()
|
||||
|
||||
return variations, errors
|
||||
return variations, errors
|
||||
|
||||
@@ -14,7 +14,7 @@ Datastore for Store Baskets
|
||||
# from routes import bp_home
|
||||
import lib.argument_validation as av
|
||||
from business_objects.store.basket import Basket, Basket_Item
|
||||
from business_objects.store.product_category import Container_Product_Category, Product_Category
|
||||
from business_objects.store.product_category import Product_Category_Container, Product_Category
|
||||
from business_objects.store.currency import Currency
|
||||
from business_objects.store.image import Image
|
||||
from business_objects.store.delivery_option import Delivery_Option
|
||||
@@ -27,7 +27,7 @@ from business_objects.store.stock_item import Stock_Item, Stock_Item_Filters
|
||||
from business_objects.user import User, User_Filters, User_Permission_Evaluation
|
||||
from business_objects.store.product_variation import Product_Variation, Product_Variation_Filters, Product_Variation_List
|
||||
from datastores.datastore_store_base import DataStore_Store_Base
|
||||
from helpers.helper_db_mysql import Helper_DB_MySQL
|
||||
# from helpers.helper_db_mysql import Helper_DB_MySQL
|
||||
# from models.model_view_store_checkout import Model_View_Store_Checkout # circular!
|
||||
from extensions import db
|
||||
# external
|
||||
|
||||
129
datastores/datastore_store_product.py
Normal file
129
datastores/datastore_store_product.py
Normal file
@@ -0,0 +1,129 @@
|
||||
"""
|
||||
Project: PARTS Website
|
||||
Author: Edward Middleton-Smith
|
||||
Precision And Research Technology Systems Limited
|
||||
|
||||
Technology: DataStores
|
||||
Feature: Store Product DataStore
|
||||
|
||||
Description:
|
||||
Datastore for Store Products
|
||||
"""
|
||||
|
||||
# internal
|
||||
import lib.argument_validation as av
|
||||
from business_objects.store.basket import Basket, Basket_Item
|
||||
from business_objects.store.product_category import Product_Category_Container, Product_Category
|
||||
from business_objects.store.currency import Currency
|
||||
from business_objects.store.image import Image
|
||||
from business_objects.store.delivery_option import Delivery_Option
|
||||
from business_objects.store.delivery_region import Delivery_Region
|
||||
from business_objects.store.discount import Discount
|
||||
from business_objects.store.order import Order
|
||||
from business_objects.store.product import Product, Product_Permutation, Product_Price, Filters_Product
|
||||
from business_objects.sql_error import SQL_Error
|
||||
from business_objects.store.stock_item import Stock_Item, Stock_Item_Filters
|
||||
from business_objects.user import User, User_Filters, User_Permission_Evaluation
|
||||
from business_objects.store.product_variation import Product_Variation, Product_Variation_Filters, Product_Variation_List
|
||||
# from datastores.datastore_base import Table_Shop_Product_Category, Table_Shop_Product_Category_Temp
|
||||
from datastores.datastore_store_base import DataStore_Store_Base
|
||||
from helpers.helper_db_mysql import Helper_DB_MySQL
|
||||
# from models.model_view_store_checkout import Model_View_Store_Checkout # circular!
|
||||
from extensions import db
|
||||
# external
|
||||
# from abc import ABC, abstractmethod, abstractproperty
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
from sqlalchemy import text
|
||||
import stripe
|
||||
import os
|
||||
from flask import Flask, session, current_app
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
from typing import ClassVar
|
||||
from datetime import datetime
|
||||
|
||||
# db = SQLAlchemy()
|
||||
|
||||
"""
|
||||
class Table_Shop_Product_Category(db.Model):
|
||||
__tablename__ = 'Shop_Product_Category'
|
||||
id_category: int = db.Column(db.Integer, primary_key=True)
|
||||
code: str = db.Column(db.String(50))
|
||||
name: str = db.Column(db.String(255))
|
||||
description: str = db.Column(db.String(4000))
|
||||
active: bool = db.Column(db.Boolean)
|
||||
display_order: int = db.Column(db.Integer)
|
||||
created_on: datetime = db.Column(db.DateTime)
|
||||
created_by: int = db.Column(db.Integer)
|
||||
id_change_set: int = db.Column(db.Integer)
|
||||
"""
|
||||
class Row_Shop_Product_Temp(db.Model):
|
||||
__tablename__ = 'Shop_Product_Temp'
|
||||
__table_args__ = { 'extend_existing': True }
|
||||
id_product: int = db.Column(db.Integer, primary_key=True)
|
||||
id_category: int = db.Column(db.Integer)
|
||||
name: str = db.Column(db.String(50))
|
||||
has_variations: str = db.Column(db.String(255))
|
||||
id_access_level_required: int = db.Column(db.Integer)
|
||||
active: bool = db.Column(db.Boolean)
|
||||
display_order: int = db.Column(db.Integer)
|
||||
guid: str = db.Column(db.BINARY(36))
|
||||
|
||||
@classmethod
|
||||
def from_product(cls, product):
|
||||
row = cls()
|
||||
row.id_product = product.id_product[0] if isinstance(product.id_product, tuple) else product.id_product
|
||||
row.id_category = product.id_category[0] if isinstance(product.id_category, tuple) else product.id_category
|
||||
row.name = product.name[0] if isinstance(product.name, tuple) else product.name
|
||||
row.id_access_level_required = product.id_access_level_required[0] if isinstance(product.id_access_level_required, tuple) else product.id_access_level_required
|
||||
row.active = product.active
|
||||
row.display_order = product.display_order
|
||||
return row
|
||||
def to_json(self):
|
||||
return {
|
||||
'id_category': self.id_category,
|
||||
'name': self.name,
|
||||
'id_access_level_required': self.id_access_level_required,
|
||||
'active': self.active,
|
||||
'display_order': self.display_order,
|
||||
'guid': self.guid,
|
||||
}
|
||||
|
||||
|
||||
class DataStore_Store_Product(DataStore_Store_Base):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
@classmethod
|
||||
def save_categories(cls, comment, categories):
|
||||
_m = 'DataStore_Store_Product_Category.save_categories'
|
||||
print(f'{_m}\nstarting...')
|
||||
print(f'comment: {comment}\ncategories: {categories}')
|
||||
# av.val_str(comment, 'comment', _m)
|
||||
# av.val_list_instances(categories, 'categories', _m, Product_Category, 1)
|
||||
|
||||
guid = Helper_DB_MySQL.create_guid()
|
||||
user = cls.get_user_session()
|
||||
rows = []
|
||||
id_category_new = 0
|
||||
for category in categories:
|
||||
row = Row_Shop_Product_Temp.from_product(category)
|
||||
if row.id_category == '':
|
||||
id_category_new -= 1
|
||||
row.id_category = id_category_new
|
||||
else:
|
||||
print(f'row.id_category: {row.id_category}')
|
||||
row.guid = guid
|
||||
rows.append(row)
|
||||
|
||||
print(f'rows: {rows}')
|
||||
|
||||
DataStore_Store_Base.upload_bulk(rows, Row_Shop_Product_Temp, 1000)
|
||||
|
||||
argument_dict_list = {
|
||||
'a_id_user': user.id_user,
|
||||
'a_guid': guid,
|
||||
'a_comment': comment,
|
||||
}
|
||||
save_result = cls.db_procedure_execute('p_shop_save_product', argument_dict_list)
|
||||
save_result.close()
|
||||
print('save procedure executed')
|
||||
|
||||
@@ -13,7 +13,7 @@ Datastore for Store Product Categories
|
||||
# internal
|
||||
import lib.argument_validation as av
|
||||
from business_objects.store.basket import Basket, Basket_Item
|
||||
from business_objects.store.product_category import Container_Product_Category, Product_Category
|
||||
from business_objects.store.product_category import Product_Category_Container, Product_Category
|
||||
from business_objects.store.currency import Currency
|
||||
from business_objects.store.image import Image
|
||||
from business_objects.store.delivery_option import Delivery_Option
|
||||
@@ -63,11 +63,12 @@ class Row_Shop_Product_Category_Temp(db.Model):
|
||||
code: str = db.Column(db.String(50))
|
||||
name: str = db.Column(db.String(255))
|
||||
description: str = db.Column(db.String(4000))
|
||||
id_access_level_required: int = db.Column(db.Integer)
|
||||
active: bool = db.Column(db.Boolean)
|
||||
display_order: int = db.Column(db.Integer)
|
||||
guid: str = db.Column(db.BINARY(36))
|
||||
created_on: datetime = db.Column(db.DateTime)
|
||||
created_by: int = db.Column(db.Integer)
|
||||
# created_on: datetime = db.Column(db.DateTime)
|
||||
# created_by: int = db.Column(db.Integer)
|
||||
|
||||
@classmethod
|
||||
def from_product_category(cls, product_category):
|
||||
@@ -76,6 +77,7 @@ class Row_Shop_Product_Category_Temp(db.Model):
|
||||
row.code = product_category.code[0] if isinstance(product_category.code, tuple) else product_category.code
|
||||
row.name = product_category.name[0] if isinstance(product_category.name, tuple) else product_category.name
|
||||
row.description = product_category.description[0] if isinstance(product_category.description, tuple) else product_category.description
|
||||
row.id_access_level_required = product_category.id_access_level_required[0] if isinstance(product_category.id_access_level_required, tuple) else product_category.id_access_level_required
|
||||
row.active = product_category.active
|
||||
row.display_order = product_category.display_order
|
||||
"""
|
||||
@@ -90,12 +92,15 @@ class Row_Shop_Product_Category_Temp(db.Model):
|
||||
'code': self.code,
|
||||
'name': self.name,
|
||||
'description': self.description,
|
||||
'id_access_level_required': self.id_access_level_required,
|
||||
'active': self.active,
|
||||
'display_order': self.display_order,
|
||||
'guid': self.guid,
|
||||
'created_on': self.created_on,
|
||||
'created_by': self.created_by
|
||||
}
|
||||
"""
|
||||
'created_on': self.created_on,
|
||||
'created_by': self.created_by
|
||||
"""
|
||||
|
||||
|
||||
class DataStore_Store_Product_Category(DataStore_Store_Base):
|
||||
@@ -115,7 +120,8 @@ class DataStore_Store_Product_Category(DataStore_Store_Base):
|
||||
rows = []
|
||||
id_category_new = 0
|
||||
for category in categories:
|
||||
row = Row_Shop_Product_Category_Temp.from_product_category(category)
|
||||
# row = Row_Shop_Product_Category_Temp.from_product_category(category)
|
||||
row = category.to_temporary_record()
|
||||
# id_tmp =
|
||||
if row.id_category == '':
|
||||
id_category_new -= 1
|
||||
@@ -123,8 +129,8 @@ class DataStore_Store_Product_Category(DataStore_Store_Base):
|
||||
else:
|
||||
print(f'row.id_category: {row.id_category}')
|
||||
row.guid = guid
|
||||
row.created_on = now
|
||||
row.created_by = user.id_user
|
||||
# row.created_on = now
|
||||
# row.created_by = user.id_user
|
||||
rows.append(row)
|
||||
|
||||
print(f'rows: {rows}')
|
||||
@@ -141,7 +147,7 @@ class DataStore_Store_Product_Category(DataStore_Store_Base):
|
||||
cursor.close()
|
||||
print('cursor closed')
|
||||
"""
|
||||
DataStore_Store_Base.upload_bulk(rows, Row_Shop_Product_Category_Temp, 1000)
|
||||
DataStore_Store_Base.upload_bulk(rows, Product_Category.__tablename__, 1000)
|
||||
|
||||
argument_dict_list = {
|
||||
'a_id_user': user.id_user,
|
||||
|
||||
@@ -13,7 +13,7 @@ Datastore for Store Product Permutations
|
||||
# internal
|
||||
import lib.argument_validation as av
|
||||
from business_objects.store.basket import Basket, Basket_Item
|
||||
from business_objects.store.product_category import Container_Product_Category, Product_Category
|
||||
from business_objects.store.product_category import Product_Category_Container, Product_Category
|
||||
from business_objects.store.currency import Currency
|
||||
from business_objects.store.image import Image
|
||||
from business_objects.store.delivery_option import Delivery_Option
|
||||
@@ -26,7 +26,7 @@ from business_objects.store.stock_item import Stock_Item, Stock_Item_Filters
|
||||
from business_objects.user import User, User_Filters, User_Permission_Evaluation
|
||||
from business_objects.store.product_variation import Product_Variation, Product_Variation_Filters, Product_Variation_List
|
||||
from datastores.datastore_store_base import DataStore_Store_Base
|
||||
from helpers.helper_db_mysql import Helper_DB_MySQL
|
||||
# from helpers.helper_db_mysql import Helper_DB_MySQL
|
||||
# from models.model_view_store_checkout import Model_View_Store_Checkout # circular!
|
||||
from extensions import db
|
||||
# external
|
||||
|
||||
@@ -14,7 +14,7 @@ Datastore for Store Product Variations
|
||||
# from routes import bp_home
|
||||
import lib.argument_validation as av
|
||||
from business_objects.store.basket import Basket, Basket_Item
|
||||
from business_objects.store.product_category import Container_Product_Category, Product_Category
|
||||
from business_objects.store.product_category import Product_Category_Container, Product_Category
|
||||
from business_objects.store.currency import Currency
|
||||
from business_objects.store.image import Image
|
||||
from business_objects.store.delivery_option import Delivery_Option
|
||||
@@ -27,7 +27,7 @@ from business_objects.store.stock_item import Stock_Item, Stock_Item_Filters
|
||||
from business_objects.user import User, User_Filters, User_Permission_Evaluation
|
||||
from business_objects.store.product_variation import Product_Variation, Product_Variation_Filters, Product_Variation_List
|
||||
from datastores.datastore_store_base import DataStore_Store_Base
|
||||
from helpers.helper_db_mysql import Helper_DB_MySQL
|
||||
# from helpers.helper_db_mysql import Helper_DB_MySQL
|
||||
# from models.model_view_store_checkout import Model_View_Store_Checkout # circular!
|
||||
from extensions import db
|
||||
# external
|
||||
@@ -83,7 +83,7 @@ class DataStore_Store_Product_Variation(DataStore_Store_Base):
|
||||
variations = Product_Variation_List()
|
||||
for row in result_set:
|
||||
new_variation = Product_Variation.from_DB_variation(row)
|
||||
variations.add_variation(new_variation)
|
||||
variations.add_product_variation(new_variation)
|
||||
|
||||
errors = []
|
||||
cursor.nextset()
|
||||
|
||||
@@ -14,7 +14,7 @@ Datastore for Store Stock Items
|
||||
# from routes import bp_home
|
||||
import lib.argument_validation as av
|
||||
from business_objects.store.basket import Basket, Basket_Item
|
||||
from business_objects.store.product_category import Container_Product_Category, Product_Category
|
||||
from business_objects.store.product_category import Product_Category_Container, Product_Category
|
||||
from business_objects.store.currency import Currency
|
||||
from business_objects.store.image import Image
|
||||
from business_objects.store.delivery_option import Delivery_Option
|
||||
@@ -27,7 +27,7 @@ from business_objects.store.stock_item import Stock_Item, Stock_Item_Filters
|
||||
from business_objects.user import User, User_Filters, User_Permission_Evaluation
|
||||
from business_objects.store.product_variation import Product_Variation, Product_Variation_Filters, Product_Variation_List
|
||||
from datastores.datastore_store_base import DataStore_Store_Base
|
||||
from helpers.helper_db_mysql import Helper_DB_MySQL
|
||||
# from helpers.helper_db_mysql import Helper_DB_MySQL
|
||||
# from models.model_view_store_checkout import Model_View_Store_Checkout # circular!
|
||||
from extensions import db
|
||||
# external
|
||||
@@ -73,7 +73,7 @@ class DataStore_Store_Stock_Item(DataStore_Store_Base):
|
||||
|
||||
def input_many_stock_item(cursor):
|
||||
_m = 'DataStore_Store_Stock_Item.input_many_stock_item'
|
||||
category_list = Container_Product_Category()
|
||||
category_list = Product_Category_Container()
|
||||
# Categories
|
||||
result_set_1 = cursor.fetchall()
|
||||
print(f'raw categories: {result_set_1}')
|
||||
@@ -95,12 +95,12 @@ class DataStore_Store_Stock_Item(DataStore_Store_Base):
|
||||
except KeyError:
|
||||
permutation = Product_Permutation.from_DB_stock_item(row)
|
||||
permutation.add_stock_item(new_stock_item)
|
||||
product.add_permutation(permutation)
|
||||
product.add_product_permutation(permutation)
|
||||
except KeyError:
|
||||
product = Product.from_DB_stock_item(row)
|
||||
permutation = Product_Permutation.from_DB_stock_item(row)
|
||||
permutation.add_stock_item(new_stock_item)
|
||||
product.add_permutation(permutation)
|
||||
product.add_product_permutation(permutation)
|
||||
category_list.add_product(product)
|
||||
"""
|
||||
except KeyError:
|
||||
@@ -109,10 +109,10 @@ class DataStore_Store_Stock_Item(DataStore_Store_Base):
|
||||
product = Product.from_DB_stock_item(row)
|
||||
permutation = Product_Permutation.from_DB_stock_item(row)
|
||||
permutation.add_stock_item(new_stock_item)
|
||||
product.add_permutation(permutation)
|
||||
product.add_product_permutation(permutation)
|
||||
new_category.add_product(product)
|
||||
"""
|
||||
category_list.add_category(new_category)
|
||||
category_list.add_product_category(new_category)
|
||||
try:
|
||||
index_product = category.get_index_product_from_id(new_stock_item.id_product)
|
||||
product = category.products[index_product]
|
||||
@@ -125,7 +125,7 @@ class DataStore_Store_Stock_Item(DataStore_Store_Base):
|
||||
permutation.add_stock_item(new_stock_item)
|
||||
except KeyError:
|
||||
new_permutation = Product_Permutation.from_DB_stock_item(row)
|
||||
product.add_permutation(new_permutation)
|
||||
product.add_product_permutation(new_permutation)
|
||||
category_list.add_stock_item(new_stock_item)
|
||||
|
||||
# Product_Variations
|
||||
@@ -133,9 +133,9 @@ class DataStore_Store_Stock_Item(DataStore_Store_Base):
|
||||
result_set_3 = cursor.fetchall()
|
||||
variations = []
|
||||
for row in result_set_3:
|
||||
new_variation = Product_Variation.from_DB_product(row)
|
||||
new_variation = Product_Variation.from_DB_get_many_product_catalogue(row)
|
||||
variations.append(new_variation)
|
||||
category_list.add_variation(new_variation)
|
||||
category_list.add_product_variation(new_variation)
|
||||
|
||||
# Errors
|
||||
cursor.nextset()
|
||||
@@ -147,7 +147,7 @@ class DataStore_Store_Stock_Item(DataStore_Store_Base):
|
||||
for error in errors:
|
||||
print(f"Error [{error.code}]: {error.msg}")
|
||||
|
||||
category_list.get_all_variation_trees()
|
||||
category_list.get_all_product_variation_trees()
|
||||
"""
|
||||
for category in category_list.categories:
|
||||
print(f'category: {category.name}')
|
||||
|
||||
@@ -14,7 +14,7 @@ Datastore for Store Stripe service
|
||||
# from routes import bp_home
|
||||
import lib.argument_validation as av
|
||||
from business_objects.store.basket import Basket, Basket_Item
|
||||
from business_objects.store.product_category import Container_Product_Category, Product_Category
|
||||
from business_objects.store.product_category import Product_Category_Container, Product_Category
|
||||
from business_objects.store.currency import Currency
|
||||
from business_objects.store.image import Image
|
||||
from business_objects.store.delivery_option import Delivery_Option
|
||||
@@ -27,7 +27,7 @@ from business_objects.store.stock_item import Stock_Item, Stock_Item_Filters
|
||||
from business_objects.user import User, User_Filters, User_Permission_Evaluation
|
||||
from business_objects.store.product_variation import Product_Variation, Product_Variation_Filters, Product_Variation_List
|
||||
from datastores.datastore_store_base import DataStore_Store_Base
|
||||
from helpers.helper_db_mysql import Helper_DB_MySQL
|
||||
# from helpers.helper_db_mysql import Helper_DB_MySQL
|
||||
# from models.model_view_store_checkout import Model_View_Store_Checkout # circular!
|
||||
from extensions import db
|
||||
# external
|
||||
|
||||
@@ -14,7 +14,7 @@ Datastore for Users
|
||||
# from routes import bp_home
|
||||
import lib.argument_validation as av
|
||||
from business_objects.store.basket import Basket, Basket_Item
|
||||
from business_objects.store.product_category import Container_Product_Category, Product_Category
|
||||
from business_objects.store.product_category import Product_Category_Container, Product_Category
|
||||
from business_objects.store.currency import Currency
|
||||
from business_objects.store.image import Image
|
||||
from business_objects.store.delivery_option import Delivery_Option
|
||||
@@ -27,7 +27,7 @@ from business_objects.store.stock_item import Stock_Item, Stock_Item_Filters
|
||||
from business_objects.user import User, User_Filters, User_Permission_Evaluation
|
||||
from business_objects.store.product_variation import Product_Variation, Product_Variation_Filters, Product_Variation_List
|
||||
from datastores.datastore_base import DataStore_Base
|
||||
from helpers.helper_db_mysql import Helper_DB_MySQL
|
||||
# from helpers.helper_db_mysql import Helper_DB_MySQL
|
||||
# from models.model_view_store_checkout import Model_View_Store_Checkout # circular!
|
||||
from extensions import db
|
||||
# external
|
||||
|
||||
Reference in New Issue
Block a user