1.started removal of CDNs.\n 2. Improved modular structure for all parts of project including database.

This commit is contained in:
2024-08-30 23:27:28 +01:00
parent 18977c8cac
commit f9cd9ec33a
2895 changed files with 490579 additions and 7561 deletions

Binary file not shown.

View File

@@ -0,0 +1,25 @@
"""
Project: PARTS Website
Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: View Models
Feature: Store Permutations View Model
Description:
Data model for store permutations view
"""
# internal
from models.model_view_base import Model_View_Base
# external
from pydantic import BaseModel
from typing import ClassVar
class Model_View_Admin(Model_View_Base):
def __init__(self, hash_page_current, **kwargs):
_m = 'Model_View_Admin.__init__'
print(f'{_m}\nstarting')
super().__init__(hash_page_current=hash_page_current, **kwargs)

View File

@@ -0,0 +1,27 @@
"""
Project: PARTS Website
Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: View Models
Feature: Admin Home View Model
Description:
Data model for admin home view
"""
# internal
from models.model_view_admin import Model_View_Admin
# external
from pydantic import BaseModel
from typing import ClassVar
class Model_View_Admin_Home(Model_View_Admin):
@property
def title(self):
return 'Admin Home'
def __init__(self, hash_page_current=Model_View_Admin.HASH_PAGE_ADMIN_HOME):
super().__init__(hash_page_current=hash_page_current)

View File

@@ -19,12 +19,12 @@ Base data model for views
# from routes import bp_home
import lib.argument_validation as av
from forms import Form_Is_Included_VAT, Form_Delivery_Region, Form_Currency
from datastores.datastore_store import DataStore_Store
from datastores.datastore_user import DataStore_User
from business_objects.user import User, User_Filters
# external
from abc import ABC, abstractmethod
from flask_sqlalchemy import SQLAlchemy
from flask import Flask, session
from flask import Flask, session, current_app
from pydantic import BaseModel, ConfigDict
from typing import ClassVar
@@ -39,9 +39,9 @@ class Model_View_Base(BaseModel, ABC):
ATTR_VALUE_PREVIOUS: ClassVar[str] = 'previous-value'
FLAG_ACTIVE: ClassVar[str] = 'active'
FLAG_ADD: ClassVar[str] = 'add'
FLAG_BUTTON_CANCEL: ClassVar[str] = 'button-cancel'
FLAG_BUTTON_MODAL_CLOSE: ClassVar[str] = 'button-overlay-close'
FLAG_BUTTON_SUBMIT: ClassVar[str] = 'button-submit'
FLAG_CANCEL: ClassVar[str] = 'button-cancel'
# FLAG_CONTACT_US: ClassVar[str] = 'button-contact'
FLAG_CLOSE_TEMPORARY_ELEMENT: ClassVar[str] = 'button-temporary-element-close'
FLAG_CARD: ClassVar[str] = 'card'
FLAG_COLLAPSED: ClassVar[str] = 'collapsed'
FLAG_COLLAPSIBLE: ClassVar[str] = 'collapsible'
@@ -50,31 +50,62 @@ class Model_View_Base(BaseModel, ABC):
FLAG_CONTAINER_INPUT: ClassVar[str] = FLAG_CONTAINER + '-input'
FLAG_DELETE: ClassVar[str] = 'delete'
FLAG_DETAIL: ClassVar[str] = 'detail'
FLAG_DIALOG: ClassVar[str] = 'dialog' # try <dialog> element
FLAG_DIRTY: ClassVar[str] = 'dirty'
FLAG_ERROR: ClassVar[str] = 'error'
FLAG_EXPANDED: ClassVar[str] = 'expanded'
FLAG_HAMBURGER: ClassVar[str] = 'hamburger'
FLAG_IMAGE_LOGO: ClassVar[str] = 'image-logo'
FLAG_INITIALISED: ClassVar[str] = 'initialised'
FLAG_MODAL: ClassVar[str] = 'modal'
FLAG_NAV_ADMIN_HOME: ClassVar[str] = 'navAdminHome'
FLAG_NAV_ADMIN_STORE_STRIPE_PRICES: ClassVar[str] = 'navAdminStoreStripePrices'
FLAG_NAV_ADMIN_STORE_STRIPE_PRODUCTS: ClassVar[str] = 'navAdminStoreStripeProducts'
FLAG_NAV_CONTACT: ClassVar[str] = 'navContact'
FLAG_NAV_HOME: ClassVar[str] = 'navHome'
FLAG_NAV_SERVICES: ClassVar[str] = 'navServices'
FLAG_NAV_STORE_HOME: ClassVar[str] = 'navStoreHome'
FLAG_NAV_STORE_PRODUCTS: ClassVar[str] = 'navStoreProducts'
FLAG_NAV_STORE_PRODUCT_CATEGORIES: ClassVar[str] = 'navStoreProductCategories'
FLAG_NAV_STORE_PRODUCT_PERMUTATIONS: ClassVar[str] = 'navStoreProductPermutations'
FLAG_NAV_STORE_PRODUCT_PRICES: ClassVar[str] = 'navStoreProductPrices'
FLAG_NAV_STORE_PRODUCT_VARIATIONS: ClassVar[str] = 'navStoreProductVariations'
FLAG_NAV_STORE_STOCK_ITEMS: ClassVar[str] = 'navStoreStockItems'
FLAG_NAV_USER_ACCOUNT: ClassVar[str] = 'navUserAccount'
FLAG_NAV_USER_ADMIN: ClassVar[str] = 'navUserAdmin'
FLAG_NAV_USER_LOGIN: ClassVar[str] = 'navUserLogin'
FLAG_NAV_USER_LOGOUT: ClassVar[str] = 'navUserLogout'
FLAG_OVERLAY: ClassVar[str] = 'overlay'
FLAG_TEMPORARY_ELEMENT: ClassVar[str] = 'temporary-element'
FLAG_PAGE_BODY: ClassVar[str] = 'page-body'
FLAG_ROW: ClassVar[str] = 'row'
FLAG_ROW_NEW: ClassVar[str] = 'row-new'
FLAG_SCROLLABLE: ClassVar[str] = 'scrollable'
FLAG_SUBMIT: ClassVar[str] = 'submit'
FLAG_SUBMITTED: ClassVar[str] = 'submitted'
# flagIsDatePicker: ClassVar[str] = 'is-date-picker'
HASH_APPLY_FILTERS_STORE_PRODUCT_PERMUTATION: ClassVar[str] = '/store/permutation_filter'
HASH_CALLBACK_LOGIN: ClassVar[str] = '/callback-login'
HASH_PAGE_ACCESSIBILITY_REPORT: ClassVar[str] = '/accessibility-report'
HASH_PAGE_ACCESSIBILITY_STATEMENT: ClassVar[str] = '/accessibility-statement'
HASH_PAGE_ADMIN: ClassVar[str] = '/admin'
HASH_PAGE_ADMIN_HOME: ClassVar[str] = '/admin'
HASH_PAGE_CONTACT: ClassVar[str] = '/contact'
HASH_PAGE_ERROR_NO_PERMISSION: ClassVar[str] = '/error'
HASH_PAGE_HOME: ClassVar[str] = '/'
HASH_PAGE_LICENSE: ClassVar[str] = '/license'
HASH_PAGE_PRIVACY_POLICY: ClassVar[str] = '/privacy-policy'
HASH_PAGE_DATA_RETENTION_SCHEDULE: ClassVar[str] = '/retention-schedule'
HASH_PAGE_SERVICES: ClassVar[str] = '/services'
# HASH_PAGE_STORE_ADMIN: ClassVar[str] = '/store/admin'
HASH_PAGE_STORE_BASKET: ClassVar[str] = '/store/basket'
HASH_PAGE_STORE_HOME: ClassVar[str] = '/store'
HASH_PAGE_STORE_PRODUCTS: ClassVar[str] = '/store/product'
HASH_PAGE_STORE_PRODUCT_PERMUTATIONS: ClassVar[str] = '/store/permutation'
HASH_PAGE_STORE_PRODUCT_CATEGORIES: ClassVar[str] = '/store/categories'
HASH_PAGE_STORE_PRODUCTS: ClassVar[str] = '/store/products'
HASH_PAGE_STORE_PRODUCT_PERMUTATIONS: ClassVar[str] = '/store/permutations'
HASH_PAGE_STORE_PRODUCT_PRICES: ClassVar[str] = '/store/prices'
HASH_PAGE_STORE_PRODUCT_VARIATIONS: ClassVar[str] = '/store/variations'
HASH_PAGE_STORE_STOCK_ITEMS: ClassVar[str] = '/store/stock_items'
HASH_PAGE_STORE_SUPPLIER: ClassVar[str] = '/store/supplier'
HASH_PAGE_USER_ACCOUNT: ClassVar[str] = '/user'
HASH_PAGE_USER_ADMIN: ClassVar[str] = '/user/admin'
HASH_PAGE_USER_LOGIN: ClassVar[str] = '/login'
@@ -92,19 +123,25 @@ class Model_View_Base(BaseModel, ABC):
ID_LABEL_ERROR: ClassVar[str] = 'labelError'
ID_MODAL_SERVICES: ClassVar[str] = 'modalServices'
ID_MODAL_TECHNOLOGIES: ClassVar[str] = 'modalTechnologies'
ID_NAV_ADMIN_HOME: ClassVar[str] = 'navAdminHome'
ID_NAV_CONTACT: ClassVar[str] = 'navContact'
ID_NAV_HOME: ClassVar[str] = 'navHome'
ID_NAV_SERVICES: ClassVar[str] = 'navServices'
ID_NAV_STORE_ADMIN: ClassVar[str] = 'navStoreAdmin'
ID_NAV_STORE_HOME: ClassVar[str] = 'navStoreHome'
ID_NAV_STORE_PERMUTATIONS: ClassVar[str] = 'navStorePermutations'
ID_NAV_STORE_PRODUCT: ClassVar[str] = 'navStoreProduct'
ID_NAV_STORE_STOCK_ITEMS: ClassVar[str] = 'navStoreStockItems'
ID_NAV_USER_ACCOUNT: ClassVar[str] = 'navUserAccount'
ID_NAV_USER_ADMIN: ClassVar[str] = 'navUserAdmin'
ID_NAV_USER_LOGIN: ClassVar[str] = 'navUserLogin'
ID_NAV_USER_LOGOUT: ClassVar[str] = 'navUserLogout'
"""
ID_BUTTON_NAV_ADMIN_HOME: ClassVar[str] = 'navAdminHome'
ID_BUTTON_NAV_ADMIN_STORE_STRIPE_PRICE: ClassVar[str] = 'navAdminStoreStripePrice'
ID_BUTTON_NAV_ADMIN_STORE_STRIPE_PRODUCT: ClassVar[str] = 'navAdminStoreStripeProduct'
# ID_BUTTON_NAV_CONTACT: ClassVar[str] = 'navContact'
ID_BUTTON_NAV_HOME: ClassVar[str] = 'navHome'
ID_BUTTON_NAV_SERVICES: ClassVar[str] = 'navServices'
ID_BUTTON_NAV_STORE_HOME: ClassVar[str] = 'navStoreHome'
ID_BUTTON_NAV_STORE_PRODUCT: ClassVar[str] = 'navStoreProduct'
ID_BUTTON_NAV_STORE_PRODUCT_CATEGORIES: ClassVar[str] = 'navStoreProductCategories'
ID_BUTTON_NAV_STORE_PRODUCT_PERMUTATIONS: ClassVar[str] = 'navStoreProductPermutations'
ID_BUTTON_NAV_STORE_PRODUCT_PRICES: ClassVar[str] = 'navStoreProductPrices'
ID_BUTTON_NAV_STORE_PRODUCT_VARIATIONS: ClassVar[str] = 'navStoreProductVariations'
ID_BUTTON_NAV_STORE_STOCK_ITEMS: ClassVar[str] = 'navStoreStockItems'
ID_BUTTON_NAV_USER_ACCOUNT: ClassVar[str] = 'navUserAccount'
ID_BUTTON_NAV_USER_ADMIN: ClassVar[str] = 'navUserAdmin'
ID_BUTTON_NAV_USER_LOGIN: ClassVar[str] = 'navUserLogin'
ID_BUTTON_NAV_USER_LOGOUT: ClassVar[str] = 'navUserLogout'
"""
ID_OVERLAY_CONFIRM: ClassVar[str] = 'overlayConfirm'
ID_OVERLAY_HAMBURGER: ClassVar[str] = 'overlayHamburger'
ID_PAGE_BODY: ClassVar[str] = 'pageBody'
@@ -129,11 +166,12 @@ class Model_View_Base(BaseModel, ABC):
form_delivery_region: Form_Delivery_Region
form_currency: Form_Currency
# app: Flask
db: SQLAlchemy
"""
# """
app: Flask
db: SQLAlchemy
hash_page_current: str
# """
app: Flask = None
session: None = None
is_page_store: bool = None
is_user_logged_in: bool = None
@@ -155,7 +193,7 @@ class Model_View_Base(BaseModel, ABC):
av.val_instance(db, 'db', _m, SQLAlchemy, v_arg_type=v_arg_type)
return super(Model_View_Base, cls).__new__(cls)
"""
def __init__(self, app, db, **kwargs):
def __init__(self, hash_page_current, **kwargs):
# Constructor
"""
_m = 'Model_View_Base.__init__'
@@ -163,7 +201,7 @@ class Model_View_Base(BaseModel, ABC):
print(f'{_m}\nstarting')
av.val_instance(db, 'db', _m, SQLAlchemy, v_arg_type=v_arg_type)
"""
BaseModel.__init__(self, app=app, db=db, **kwargs)
BaseModel.__init__(self, hash_page_current=hash_page_current, **kwargs)
"""
self.db = db
self.session = session
@@ -174,7 +212,8 @@ class Model_View_Base(BaseModel, ABC):
self.id_user = info_user['sub'] if self.is_user_logged_in else ''
self.app = app
"""
with app.app_context():
self.app = current_app
with self.app.app_context():
self.session = session
# self.form_is_included_VAT = Form_Is_Included_VAT()
# self.form_delivery_region = Form_Delivery_Region()
@@ -182,23 +221,23 @@ class Model_View_Base(BaseModel, ABC):
self.is_page_store = False
print(f'session: {self.session}')
datastore_store = DataStore_Store(self.app, self.db)
user = datastore_store.get_user_session()
datastore_user = DataStore_User()
user = datastore_user.get_user_session()
self.is_user_logged_in = user.is_logged_in
def output_bool(self, boolean):
return str(boolean).lower()
def get_url_host(self):
return self.app.config.URL_HOST
return self.app.config['URL_HOST']
def get_user_session(self):
datastore_store = DataStore_Store(self.app, self.db)
return datastore_store.get_user_session()
datastore_user = DataStore_User()
return datastore_user.get_user_session()
"""
def get_is_admin_store_user(self):
datastore_store = DataStore_Store(self.app, self.db)
datastore_store = DataStore_Store()
user = datastore_store.get_user_session()
if not user.is_logged_in: return False
filters_user = User_Filters.from_user(user) # get_default(datastore_store)
@@ -212,7 +251,7 @@ class Model_View_Base(BaseModel, ABC):
return user.can_admin_store
def get_is_admin_user_user(self):
datastore_store = DataStore_Store(self.app, self.db)
datastore_store = DataStore_Store()
user = datastore_store.get_user_session()
if not user.is_logged_in: return False
filters_user = User_Filters.from_user(user) # .get_default(datastore_store)

View File

@@ -32,6 +32,6 @@ class Model_View_Contact(Model_View_Base):
def title(self):
return 'Contact'
def __init__(self, app, db, form_contact, **kwargs):
super().__init__(app=app, db=db, form_contact=form_contact, **kwargs)
def __init__(self, form_contact, hash_page_current=Model_View_Base.HASH_PAGE_CONTACT, **kwargs):
super().__init__(hash_page_current=hash_page_current, form_contact=form_contact, **kwargs)
# self.form = form

View File

@@ -30,14 +30,8 @@ class Model_View_Home(Model_View_Base):
@property
def title(self):
return 'Home'
"""
def __new__(cls, db, info_user, app):
# Initialiser - validation
print(f'info_user: {info_user}')
return super(Model_View_Home, cls).__new__(cls, db, info_user, app)
"""
def __init__(self, app, db):
def __init__(self, hash_page_current=Model_View_Base.HASH_PAGE_HOME):
# Constructor
super().__init__(app=app, db=db)
super().__init__(hash_page_current=hash_page_current)

View File

@@ -21,7 +21,7 @@ class Model_View_Services(Model_View_Base):
def title(self):
return 'Services'
def __init__(self, app, db):
def __init__(self, hash_page_current=Model_View_Base.HASH_PAGE_SERVICES):
# Constructor
super().__init__(app=app, db=db)
super().__init__(hash_page_current=hash_page_current)

View File

@@ -18,14 +18,16 @@ Parent data model for store views
# internal
# from context import models
from models.model_view_base import Model_View_Base
from business_objects.product import Product, Product_Filters, Product_Permutation # Product_Image_Filters,
from business_objects.image import Resolution_Level_Enum
from business_objects.store.product import Product, Product_Filters, Product_Permutation # Product_Image_Filters,
from business_objects.store.image import Resolution_Level_Enum
import lib.argument_validation as av
from datastores.datastore_store import DataStore_Store
from datastores.datastore_store_base import DataStore_Store_Base
from datastores.datastore_user import DataStore_User
from datastores.datastore_store_basket import DataStore_Store_Basket
from forms import Form_Basket_Edit, Form_Is_Included_VAT, Form_Delivery_Region, Form_Currency
from business_objects.basket import Basket_Item, Basket
from business_objects.category import Category
from business_objects.variation import Variation_Filters, Variation
from business_objects.store.basket import Basket_Item, Basket
from business_objects.store.product_category import Product_Category
from business_objects.store.product_variation import Product_Variation_Filters, Product_Variation
# external
from flask import send_file, jsonify
from flask_sqlalchemy import SQLAlchemy
@@ -39,15 +41,14 @@ from typing import ClassVar
class Model_View_Store(Model_View_Base):
# Global constants
ATTR_FORM_TYPE: ClassVar[str] = 'form-type'
ATTR_ID_CATEGORY: ClassVar[str] = Product.ATTR_ID_CATEGORY
ATTR_ID_CATEGORY: ClassVar[str] = Product.ATTR_ID_PRODUCT_CATEGORY
# ATTR_ID_PRODUCT_CATEGORY : ClassVar[str] = 'id-product-category'
ATTR_ID_PRODUCT : ClassVar[str] = Product.ATTR_ID_PRODUCT # 'id-product'
ATTR_ID_PERMUTATION : ClassVar[str] = Product.ATTR_ID_PERMUTATION # 'id-permutation'
ATTR_ID_VARIATION : ClassVar[str] = Variation.ATTR_ID_VARIATION # 'id-variation'
ATTR_ID_VARIATION_TYPE : ClassVar[str] = Variation.ATTR_ID_VARIATION_TYPE # 'id-variation-type'
FLAG_BUTTON_BASKET_ADD : ClassVar[str] = Model_View_Base.FLAG_BUTTON_SUBMIT + '.buttonAdd2Basket'
ATTR_ID_PERMUTATION : ClassVar[str] = Product.ATTR_ID_PRODUCT_PERMUTATION # 'id-permutation'
ATTR_ID_VARIATION : ClassVar[str] = Product_Variation.ATTR_ID_PRODUCT_VARIATION # 'id-variation'
ATTR_ID_VARIATION_TYPE : ClassVar[str] = Product_Variation.ATTR_ID_PRODUCT_VARIATION_TYPE # 'id-variation-type'
FLAG_BUTTON_BASKET_ADD : ClassVar[str] = Model_View_Base.FLAG_SUBMIT + '.buttonAdd2Basket'
FLAG_BUTTON_BUY_NOW : ClassVar[str] = 'buttonBuyNow'
FLAG_CATEGORY: ClassVar[str] = 'category'
FLAG_COST_LOCAL_VAT_INCL: ClassVar[str] = 'cost-local-VAT-incl'
FLAG_CURRENCY: ClassVar[str] = 'currency'
FLAG_DATE_CONSUMED: ClassVar[str] = 'date-consumed'
@@ -58,12 +59,13 @@ class Model_View_Store(Model_View_Base):
FLAG_IS_OUT_OF_STOCK: ClassVar[str] = 'is-out-of-stock'
FLAG_LOCATION_STORAGE: ClassVar[str] = 'storage-location'
FLAG_PRODUCT: ClassVar[str] = 'product'
FLAG_PRODUCT_CATEGORY: ClassVar[str] = 'category'
FLAG_QUANTITY_MAX: ClassVar[str] = Product_Permutation.FLAG_QUANTITY_MAX # 'quantity-max'
FLAG_QUANTITY_MIN: ClassVar[str] = Product_Permutation.FLAG_QUANTITY_MIN # 'quantity-min'
FLAG_QUANTITY_STOCK: ClassVar[str] = Product_Permutation.FLAG_QUANTITY_STOCK # 'quantity-stock'
FLAG_PLANT_STORAGE: ClassVar[str] = 'plant-storage'
FLAG_REGION_STORAGE: ClassVar[str] = 'region-storage'
FLAG_VARIATIONS: ClassVar[str] = Product.FLAG_VARIATIONS # 'variations'
FLAG_VARIATIONS: ClassVar[str] = 'variations'
HASH_PAGE_STORE_BASKET : ClassVar[str] = '/store/basket'
HASH_STORE_BASKET_ADD : ClassVar[str] = '/store/basket_add'
HASH_STORE_BASKET_DELETE : ClassVar[str] = '/store/basket_delete'
@@ -78,6 +80,7 @@ class Model_View_Store(Model_View_Base):
ID_BUTTON_CHECKOUT : ClassVar[str] = 'buttonCheckout'
ID_BUTTON_BASKET_ADD : ClassVar[str] = 'buttonBasketAdd'
ID_BUTTON_BUY_NOW : ClassVar[str] = 'buttonBuyNow'
ID_CATEGORY_DEFAULT: ClassVar[str] = 1
ID_CURRENCY : ClassVar[str] = Form_Currency.id_id_currency # 'id_currency'
ID_CURRENCY_DEFAULT : ClassVar[str] = 1
ID_LABEL_BASKET_EMPTY : ClassVar[str] = 'basketEmpty'
@@ -93,9 +96,10 @@ class Model_View_Store(Model_View_Base):
KEY_ID_REGION_DELIVERY : ClassVar[str] = Basket.KEY_ID_REGION_DELIVERY # 'id_region_delivery'
KEY_IS_INCLUDED_VAT : ClassVar[str] = Basket.KEY_IS_INCLUDED_VAT # 'is_included_VAT'
KEY_ITEMS : ClassVar[str] = Basket.KEY_ITEMS # 'items'
KEY_NAME_VARIATION : ClassVar[str] = Variation.KEY_NAME_VARIATION
KEY_NAME_VARIATION_TYPE : ClassVar[str] = Variation.KEY_NAME_VARIATION_TYPE
KEY_NAME_VARIATION : ClassVar[str] = Product_Variation.KEY_NAME_VARIATION
KEY_NAME_VARIATION_TYPE : ClassVar[str] = Product_Variation.KEY_NAME_VARIATION_TYPE
KEY_PRICE : ClassVar[str] = 'price'
KEY_PRODUCT_CATEGORY: ClassVar[str] = 'category'
KEY_QUANTITY : ClassVar[str] = 'quantity'
KEY_VALUE_DEFAULT : ClassVar[str] = 'default'
TYPE_FORM_BASKET_ADD : ClassVar[str] = 'Form_Basket_Add'
@@ -126,11 +130,11 @@ class Model_View_Store(Model_View_Base):
return super().__new__(cls, db, info_user, app) # Model_View_Store, cls
"""
def __init__(self, app, db, **kwargs): # , id_currency, id_region_delivery, is_included_VAT):
def __init__(self, hash_page_current, **kwargs): # , id_currency, id_region_delivery, is_included_VAT):
# Constructor
_m = 'Model_View_Store.__init__'
print(f'{_m}\nstarting')
super().__init__(app=app, db=db, **kwargs)
super().__init__(hash_page_current=hash_page_current, **kwargs)
self.is_page_store = True
"""
self.basket = Basket(id_currency, id_region_delivery, is_included_VAT)
@@ -152,8 +156,8 @@ class Model_View_Store(Model_View_Base):
self.form_delivery_region.id_region_delivery.data = str(self.id_region_delivery) if len(regions) > 0 else None
"""
def get_many_product_category(self, product_filters): # category_ids = '', product_ids = '', get_all_category = True, get_all_product = True, max_products_per_category = -1):
_m = 'Model_View_Store.get_many_product_category'
def get_many_product(self, product_filters): # category_ids = '', product_ids = '', get_all_category = True, get_all_product = True, max_products_per_category = -1):
_m = 'Model_View_Store.get_many_product'
av.val_instance(product_filters, 'product_filters', _m, Product_Filters)
"""
av.val_str(category_ids, 'category_ids', _m)
@@ -165,7 +169,7 @@ class Model_View_Store(Model_View_Base):
# get products from database
# call datastore method
# return [Product.template()]
self.category_list, errors = DataStore_Store(self.db, self.info_user, self.app).get_many_product_category(product_filters) # category_ids, product_ids, get_all_category, get_all_product, max_products_per_category)
self.category_list, errors = DataStore_Store_Base().get_many_product(product_filters) # category_ids, product_ids, get_all_category, get_all_product, max_products_per_category)
# self.categories = categories
# self.category_index = category_index
@@ -203,7 +207,7 @@ class Model_View_Store(Model_View_Base):
"""
def get_product_category_text(self, category):
return Enum_Product_Category.get_member_by_text(category).text()
return Enum_Product_Product_Category.get_member_by_text(category).text()
def add_2_basket(product_id, quantity, basket_local):
_m = 'Model_View_Store.add_2_basket'
@@ -237,14 +241,14 @@ class Model_View_Store(Model_View_Base):
# item_added = False
print(f'basket: {self.basket}')
ids_permutation, quantities_permutation = self.basket.to_csv()
self.basket = DataStore_Store(self.db, self.info_user, self.app).edit_basket(ids_permutation, quantities_permutation, permutation_id, quantity, quantity_sum_not_replace, self.id_currency, self.id_region_delivery, self.is_included_VAT)
self.basket = DataStore_Store_Basket().edit_basket(ids_permutation, quantities_permutation, permutation_id, quantity, quantity_sum_not_replace, self.id_currency, self.id_region_delivery, self.is_included_VAT)
return True
def get_basket(self, json_data):
self.import_JSON_basket(json_data)
if self.is_user_logged_in:
ids_permutation, quantities_permutation = self.basket.to_csv()
self.basket = DataStore_Store(self.db, self.info_user, self.app).edit_basket(ids_permutation, quantities_permutation, None, None, None, self.id_currency, self.id_region_delivery, self.is_included_VAT)
self.basket = DataStore_Store_Basket().edit_basket(ids_permutation, quantities_permutation, None, None, None, self.id_currency, self.id_region_delivery, self.is_included_VAT)
# return self.basket
def _get_json_basket_id_CSVs_product_permutation(self, basket):
@@ -284,7 +288,7 @@ class Model_View_Store(Model_View_Base):
is_included_VAT = basket[self.KEY_IS_INCLUDED_VAT]
print(f'json basket items: {items}')
product_ids, permutation_ids, item_index_dict = self._get_json_basket_id_CSVs_product_permutation(items)
category_list, errors = DataStore_Store(self.db, self.info_user, self.app).get_many_product_category(Product_Filters(
category_list, errors = DataStore_Store_Base().get_many_product(Product_Filters(
self.id_user, # :a_id_user
True, '', False, # :a_get_all_category, :a_ids_category, :a_get_inactive_category
False, product_ids, False, False, # :a_get_all_product, :a_ids_product, :a_get_inactive_product, :a_get_first_product_only
@@ -299,11 +303,11 @@ class Model_View_Store(Model_View_Base):
if len(category_list.categories) > 0: # not (categories is None):
for category in category_list.categories:
for product in category.products:
# product = Product.make_from_json(items[index_item])
# product = Product.from_json(items[index_item])
product.form_basket_edit = Form_Basket_Edit()
# key_index_product = Basket.get_key_product_index_from_ids_product_permutation(product.id_product, product.get_id_permutation())
permutation = product.get_permutation_selected()
self.basket.add_item(Basket_Item.make_from_product_and_quantity_and_VAT_included(product, items[item_index_dict[str(permutation.id_permutation)]][self.KEY_QUANTITY], self.is_included_VAT))
self.basket.add_item(Basket_Item.from_product_and_quantity_and_VAT_included(product, items[item_index_dict[str(permutation.id_permutation)]][self.KEY_QUANTITY], self.is_included_VAT))
"""
if len(items) > 0:
for index_item in range(len(items)):
@@ -316,7 +320,7 @@ class Model_View_Store(Model_View_Base):
if len(errors) > 0:
for error in errors:
if error[1] == 'PRODUCT_AVAILABILITY':
ids_permutation = DataStore_Store.get_ids_permutation_from_error_availability(error[2])
ids_permutation = DataStore_Store_Base.get_ids_permutation_from_error_availability(error[2])
for id_permutation in ids_permutation:
for item in self.basket.items:
permutation = item.product.get_permutation_selected()
@@ -331,7 +335,7 @@ class Model_View_Store(Model_View_Base):
"""
ids_permutation_unavailable = self.basket.get_ids_permutation_unavailable()
if len(ids_permutation_unavailable) > 0:
category_list_unavailable, errors_unavailable = DataStore_Store(self.db, self.info_user, self.app).get_many_product_category(Product_Filters(
category_list_unavailable, errors_unavailable = DataStore_Store().get_many_product(Product_Filters(
self.id_user, # :a_id_user
True, '', False, # :a_get_all_category, :a_ids_category, :a_get_inactive_category
False, '', False, False, # :a_get_all_product, :a_ids_product, :a_get_inactive_product, :a_get_first_product_only
@@ -391,14 +395,14 @@ class Model_View_Store(Model_View_Base):
# _m = 'Model_View_Store.get_many_user_order'
# av.val_str(id_user)
# validation conducted by server
return DataStore_Store(self.db, self.info_user, self.app).get_many_user_order(self.info_user['sub'], ids_order, n_order_max, id_checkout_session)
return DataStore_User().get_many_user_order(self.info_user['sub'], ids_order, n_order_max, id_checkout_session)
def get_regions_and_currencies(self):
regions, currencies = DataStore_Store(self.db, self.info_user, self.app).get_regions_and_currencies()
regions, currencies = DataStore_Store_Base().get_regions_and_currencies()
return regions, currencies
def get_many_product_variation(self, variation_filters = None):
if variation_filters is None:
variation_filters = Variation_Filters.get_default()
variations, errors = DataStore_Store(self.app, self.db).get_many_product_variation(variation_filters)
variation_filters = Product_Variation_Filters.get_default()
variations, errors = DataStore_Store_Base().get_many_product_variation(variation_filters)
return variations, errors

View File

@@ -18,7 +18,7 @@ Data model for store basket view
# internal
from models.model_view_store import Model_View_Store
# from routes import bp_home
from business_objects.product import Product
from business_objects.store.product import Product
from forms import Form_Billing # Form_Product
# external
@@ -64,15 +64,11 @@ class Model_View_Store_Basket(Model_View_Store):
@property
def title(self):
return 'Store Basket'
def __new__(cls, db, id_user, app, id_currency, id_region_delivery, is_included_VAT):
# Initialiser - validation
return super(Model_View_Store_Basket, cls).__new__(cls, db, id_user, app, id_currency, id_region_delivery, is_included_VAT)
def __init__(self, db, id_user, app, id_currency, id_region_delivery, is_included_VAT):
def __init__(self, id_currency, id_region_delivery, is_included_VAT, hash_page_current=Model_View_Store.HASH_PAGE_STORE_BASKET):
# Constructor
super().__init__(db, id_user, app, id_currency, id_region_delivery, is_included_VAT)
# self.product_categories = Model_View_Store_Basket.get_many_product_category(get_all_category = True, get_all_product = True)
super().__init__(hash_page_current=hash_page_current, id_currency=id_currency, id_region_delivery=id_region_delivery, is_included_VAT=is_included_VAT)
# self.product_categories = Model_View_Store_Basket.get_many_product(get_all_category = True, get_all_product = True)
self.form_billing = Form_Billing()
self.form_billing.form_type_billing_not_delivery = True
self.form_delivery = Form_Billing()

View File

@@ -19,10 +19,10 @@ Data model for store checkout view
from models.model_view_store import Model_View_Store
from models.model_view_store_basket import Model_View_Store_Basket
# from routes import bp_home
from business_objects.product import Product
from business_objects.store.product import Product
from forms import Form_Billing # Form_Product
import lib.argument_validation as av
from datastores.datastore_store import DataStore_Store
# from datastores.datastore_store_base import DataStore_Store
# external
import os
import stripe
@@ -41,13 +41,9 @@ class Model_View_Store_Checkout(Model_View_Store_Basket):
def title(self):
return 'Store Checkout'
def __new__(cls, db, id_user, app, id_currency, id_region_delivery, is_included_VAT):
# Initialiser - validation
return super(Model_View_Store_Checkout, cls).__new__(cls, db, id_user, app, id_currency, id_region_delivery, is_included_VAT)
def __init__(self, db, id_user, app, id_currency, id_region_delivery, is_included_VAT):
def __init__(self, id_currency, id_region_delivery, is_included_VAT, hash_page_current=Model_View_Store.HASH_PAGE_STORE_CHECKOUT):
# Constructor
super().__init__(db, id_user, app, id_currency, id_region_delivery, is_included_VAT)
super().__init__(hash_page_current=hash_page_current, id_currency=id_currency, id_region_delivery=id_region_delivery, is_included_VAT=is_included_VAT)
self.key_secret_stripe = os.environ.get("KEY_SECRET_STRIPE")
self.key_public_stripe = os.environ.get("KEY_PUBLIC_STRIPE")
@@ -60,16 +56,16 @@ class Model_View_Store_Checkout(Model_View_Store_Basket):
stripe.api_key = self.key_secret_stripe
"""
def create_product(self, product): # _name, product_description):
return DataStore_Store(self.db, self.info_user).create_product(product) # _name, product_description)
return DataStore_Store().create_product(product) # _name, product_description)
def create_price(self, product, currency):
return DataStore_Store(self.db, self.info_user).create_price(product, currency)
return DataStore_Store().create_price(product, currency)
def get_many_product_new(self):
return DataStore_Store(self.db, self.info_user).get_many_product_new()
return DataStore_Store().get_many_product_new()
"""
def get_price_id(product_ids):
return DataStore_Store().get_many_id_price(product_ids)
"""

View File

@@ -19,10 +19,10 @@ Data model for store checkout success view
from models.model_view_store import Model_View_Store
from models.model_view_store_checkout import Model_View_Store_Checkout
# from routes import bp_home
from business_objects.product import Product
from business_objects.store.product import Product
from forms import Form_Billing # Form_Product
import lib.argument_validation as av
from datastores.datastore_store import DataStore_Store
# from datastores.datastore_store_base import DataStore_Store
# external
import os
@@ -36,20 +36,14 @@ class Model_View_Store_Checkout_Success(Model_View_Store_Checkout):
key_public_stripe: str
# Global constants
key_id_price = 'price_id'
@property
def title(self):
return 'Store Checkout Success'
def __new__(cls, db, id_user, app, id_checkout_session, checkout_items, id_currency, id_region_delivery, is_included_VAT):
# Initialiser - validation
_m = 'Model_View_Store_Checkout_Success.__new__'
# av.val_list(checkout_items, 'checkout_items', _m)
av.val_str(id_checkout_session, 'id_checkout_session', _m)
return super(Model_View_Store_Checkout_Success, cls).__new__(cls, db, id_user, app, id_currency, id_region_delivery, is_included_VAT)
def __init__(self, db, id_user, app, id_checkout_session, checkout_items, id_currency, id_region_delivery, is_included_VAT):
def __init__(self, id_checkout_session, checkout_items, id_currency, id_region_delivery, is_included_VAT, hash_page_current=Model_View_Store.HASH_PAGE_STORE_CHECKOUT_SUCCESS):
# Constructor
super().__init__(db, id_user, app, id_currency, id_region_delivery, is_included_VAT)
super().__init__(hash_page_current=hash_page_current, id_currency=id_currency, id_region_delivery=id_region_delivery, is_included_VAT=is_included_VAT)
self.checkout_items = checkout_items
self.id_checkout_session = id_checkout_session
self.order = self.get_many_user_order('', 1, id_checkout_session)

View File

@@ -18,7 +18,7 @@ Data model for store home view
# internal
from models.model_view_store import Model_View_Store
# from routes import bp_home
from business_objects.product import Product
from business_objects.store.product import Product
from forms import Form_Basket_Add, Form_Basket_Edit # Form_Product
# external
@@ -40,15 +40,11 @@ class Model_View_Store_Home(Model_View_Store):
return 'Store Home'
max_products_per_category = -1
def __new__(cls, db, app, id_currency, id_region_delivery, is_included_VAT):
# Initialiser - validation
return super(Model_View_Store_Home, cls).__new__(cls, db, app, id_currency, id_region_delivery, is_included_VAT)
def __init__(self, db, app, id_currency, id_region_delivery, is_included_VAT):
def __init__(self, id_currency, id_region_delivery, is_included_VAT, hash_page_current=Model_View_Store.HASH_PAGE_STORE_):
# Constructor
super().__init__(db, app, id_currency, id_region_delivery, is_included_VAT)
# self.categories = Model_View_Store_Home.get_many_product_category(self.db, get_all_category = True, get_all_product = True)
# self.get_many_product_category(get_all_category = True, get_all_product = True)
super().__init__(id_currency, id_region_delivery, is_included_VAT)
# self.categories = Model_View_Store_Home.get_many_product(self.db, get_all_category = True, get_all_product = True)
# self.get_many_product(get_all_category = True, get_all_product = True)
"""
self.forms_product = {}
for cat in self.product_categories:

View File

@@ -17,9 +17,9 @@ Data model for store product view
# IMPORTS
# internal
from models.model_view_store import Model_View_Store
from datastores.datastore_store import DataStore_Store
from datastores.datastore_store_base import DataStore_Store_Base
# from routes import bp_home
from business_objects.product import Product, Product_Filters
from business_objects.store.product import Product, Product_Filters
import lib.argument_validation as av
# external
@@ -37,32 +37,14 @@ class Model_View_Store_Product(Model_View_Store):
def title(self):
return 'Store Product'
def __new__(cls, db, id_user, app, id_permutation, id_currency, id_region_delivery, is_included_VAT): # *args, **kwargs
# Initialiser - validation
_m = 'Model_View_Store_Product.__new__'
print(f'{_m}\nstarting...')
v_arg_type = 'class attribute'
# av.val_instance(product, 'product', _m, Product, v_arg_type=v_arg_type)
# av.val_int(id_product, 'id_product', _m, v_arg_type=v_arg_type)
# av.val_int(id_permutation, 'id_permutation', _m, v_arg_type=v_arg_type)
print(f'user id: {id_user.get("sub")}')
print(f'ending')
# return super().__new__(cls, *args, **kwargs) # Model_View_Store_Product, cls # , db, id_user, id_product) # , db, id_user)
return super(Model_View_Store_Product, cls).__new__(cls, db, id_user, app, id_currency, id_region_delivery, is_included_VAT)
def __init__(self, db, id_user, app, id_permutation, id_currency, id_region_delivery, is_included_VAT):
def __init__(self, id_permutation, id_currency, id_region_delivery, is_included_VAT, hash_page_current=Model_View_Store.HASH_PAGE_STORE_PRODUCT):
# Constructor
_m = 'Model_View_Store_Product.__init__'
print(f'{_m}\nstarting...')
super().__init__(db, id_user, app, id_currency, id_region_delivery, is_included_VAT)
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')
print(f'user info: {self.info_user}')
# print(f'user id: {self.info_user.get("sub")}')
category_list = DataStore_Store(self.db, self.info_user).get_many_product_category(Product_Filters(
category_list = DataStore_Store_Base().get_many_product(Product_Filters(
self.info_user['sub'],
True, '', False,
True, '', False, False,

View File

@@ -12,19 +12,20 @@ Data model for store permutations view
# internal
from models.model_view_store import Model_View_Store
from datastores.datastore_store import DataStore_Store
from business_objects.category import Category_List
# from datastores.datastore_store_base import DataStore_Store_Base
from datastores.datastore_store_product_category import DataStore_Store_Product_Category
from business_objects.store.product_category import Container_Product_Category
from forms import Form_Filters_Permutation
# from routes import bp_home
from business_objects.product import Product, Product_Filters, Product_Permutation
from business_objects.variation import Variation_List
from business_objects.store.product import Product, Product_Filters, Product_Permutation
from business_objects.store.product_variation import Product_Variation_List
import lib.argument_validation as av
# external
from pydantic import BaseModel
from typing import ClassVar
class Model_View_Store_Permutation(Model_View_Store):
class Model_View_Store_Product_Category(Model_View_Store):
ID_FILTER_CATEGORY: ClassVar[str] = 'id_category'
ID_FILTER_PRODUCT: ClassVar[str] = 'id_product'
ID_FILTER_IS_OUT_OF_STOCK: ClassVar[str] = 'is_out_of_stock'
@@ -33,25 +34,25 @@ class Model_View_Store_Permutation(Model_View_Store):
ID_Form_Filters_Permutation: ClassVar[str] = 'Form_Filters_Permutation'
KEY_PERMUTATIONS: ClassVar[str] = 'permutations'
category_list: Category_List = None # (str)
category_list: Container_Product_Category = None # (str)
filters_product: Product_Filters
form_filters: Form_Filters_Permutation = None
permutation_blank: Product_Permutation = None
variations: Variation_List = None
variations: Product_Variation_List = None
@property
def title(self):
return 'Stock Report'
return 'Product Category'
def __init__(self, app, db, filters_product, **kwargs):
_m = 'Model_View_Store_Permutation.__init__'
def __init__(self, filters_product, hash_page_current=Model_View_Store.HASH_PAGE_STORE_PRODUCT_PERMUTATIONS):
_m = 'Model_View_Store_Product_Category.__init__'
print(f'{_m}\nstarting...')
super().__init__(app=app, db=db, filters_product=filters_product, **kwargs)
super().__init__(hash_page_current=hash_page_current, filters_product=filters_product)
# BaseModel.__init__(self, app=app, filters_product=filters_product, **kwargs)
self.form_filters = Form_Filters_Permutation()
datastore_store = DataStore_Store(self.app, self.db)
self.category_list, errors = datastore_store.get_many_product_category(filters_product)
category_list_filters, errors_filters = datastore_store.get_many_product_category(
datastore_store = DataStore_Store_Product_Category()
self.category_list, errors = datastore_store.get_many_product(filters_product)
category_list_filters, errors_filters = datastore_store.get_many_product(
Product_Filters(
# self.info_user['sub'],
True, False, False, '',
@@ -75,6 +76,6 @@ class Model_View_Store_Permutation(Model_View_Store):
variations, errors = self.get_many_product_variation()
self.variations = variations
def save_permutations(self, comment, list_permutations):
_m = 'Model_View_Store_Permutation.save_permutations'
DataStore_Store(self.app, self.db).save_permutations(comment, list_permutations)
def save_categories(self, comment, list_categories):
_m = 'Model_View_Store_Product_Category.save_categories'
DataStore_Store_Product_Category().save_categories(comment, list_categories)

View File

@@ -0,0 +1,80 @@
"""
Project: PARTS Website
Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: View Models
Feature: Store Permutations View Model
Description:
Data model for store permutations view
"""
# internal
from models.model_view_store import Model_View_Store
from datastores.datastore_store_product_permutation import DataStore_Store_Product_Permutation
from business_objects.store.product_category import Container_Product_Category
from forms import Form_Filters_Permutation
# from routes import bp_home
from business_objects.store.product import Product, Product_Filters, Product_Permutation
from business_objects.store.product_variation import Product_Variation_List
import lib.argument_validation as av
# external
from pydantic import BaseModel
from typing import ClassVar
class Model_View_Store_Product_Permutation(Model_View_Store):
ID_FILTER_CATEGORY: ClassVar[str] = 'id_category'
ID_FILTER_PRODUCT: ClassVar[str] = 'id_product'
ID_FILTER_IS_OUT_OF_STOCK: ClassVar[str] = 'is_out_of_stock'
ID_FILTER_QUANTITY_MIN: ClassVar[str] = 'quantity_min'
ID_FILTER_QUANTITY_MAX: ClassVar[str] = 'quantity_max'
ID_Form_Filters_Permutation: ClassVar[str] = 'Form_Filters_Permutation'
KEY_PERMUTATIONS: ClassVar[str] = 'permutations'
category_list: Container_Product_Category = None # (str)
filters_product: Product_Filters
form_filters: Form_Filters_Permutation = None
permutation_blank: Product_Permutation = None
variations: Product_Variation_List = None
@property
def title(self):
return 'Product Permutations'
def __init__(self, filters_product, hash_page_current=Model_View_Store.HASH_PAGE_STORE_PRODUCT_PERMUTATIONS):
_m = 'Model_View_Store_Permutation.__init__'
print(f'{_m}\nstarting...')
super().__init__(hash_page_current=hash_page_current, filters_product=filters_product)
# BaseModel.__init__(self, app=app, filters_product=filters_product, **kwargs)
self.form_filters = Form_Filters_Permutation()
datastore_store = DataStore_Store_Product_Permutation()
self.category_list, errors = datastore_store.get_many_product(filters_product)
category_list_filters, errors_filters = datastore_store.get_many_product(
Product_Filters(
# self.info_user['sub'],
True, False, '',
True, False, '',
True, False, '',
False, False, '',
# False, False, False, '',
# False, False, False, '',
# False, False, '',
filters_product.get_products_quantity_stock_below_min
)
)
print(f'category_list_filters: {category_list_filters.categories}')
self.form_filters.id_category.choices = [('0', 'All')] + [(str(category.id_category), category.name) for category in category_list_filters.categories]
print(f'category options: {self.form_filters.id_category.choices}')
product_list = category_list_filters.to_list_products()
print(f'product_list: {product_list}')
self.form_filters.id_product.choices = [('0', 'All')] + [(str(product['value']), product['text']) for product in product_list]
self.permutation_blank = Product_Permutation()
print(f'category options: {self.form_filters.id_category.choices}')
variations, errors = self.get_many_product_variation()
self.variations = variations
def save_permutations(self, comment, list_permutations):
_m = 'Model_View_Store_Permutation.save_permutations'
DataStore_Store_Product_Permutation().save_permutations(comment, list_permutations)

View File

@@ -12,19 +12,19 @@ Data model for store stock items view
# internal
from models.model_view_store import Model_View_Store
from datastores.datastore_store import DataStore_Store
from business_objects.category import Category_List
from datastores.datastore_store_stock_item import DataStore_Store_Stock_Item
from business_objects.store.product_category import Container_Product_Category
from forms import Form_Filters_Stock_Item
# from routes import bp_home
from business_objects.product import Product, Product_Filters, Product_Permutation
from business_objects.stock_item import Stock_Item, Stock_Item_Filters
from business_objects.store.product import Product, Product_Filters, Product_Permutation
from business_objects.store.stock_item import Stock_Item, Stock_Item_Filters
import lib.argument_validation as av
# external
from pydantic import BaseModel
from typing import ClassVar
class Model_View_Store_Stock_Item(Model_View_Store):
class Model_View_Store_Stock_Items(Model_View_Store):
ID_FILTER_CATEGORY: ClassVar[str] = 'id_category'
ID_FILTER_PRODUCT: ClassVar[str] = 'id_product'
ID_FILTER_IS_OUT_OF_STOCK: ClassVar[str] = 'is_out_of_stock'
@@ -33,7 +33,7 @@ class Model_View_Store_Stock_Item(Model_View_Store):
ID_Form_Filters_Permutation: ClassVar[str] = 'Form_Filters_Permutation'
KEY_PERMUTATIONS: ClassVar[str] = 'permutations'
category_list: Category_List = None # (str)
category_list: Container_Product_Category = None # (str)
filters_stock_item: Stock_Item_Filters
form_filters: Form_Filters_Stock_Item = None
permutation_blank: Product_Permutation = None
@@ -42,13 +42,13 @@ class Model_View_Store_Stock_Item(Model_View_Store):
def title(self):
return 'Store Stock Items'
def __init__(self, app, db, filters_stock_item, **kwargs):
def __init__(self, filters_stock_item, hash_page_current=Model_View_Store.HASH_PAGE_STORE_STOCK_ITEMS):
_m = 'Model_View_Store_Stock_Item.__init__'
print(f'{_m}\nstarting...')
super().__init__(app=app, db=db, filters_stock_item=filters_stock_item, **kwargs)
super().__init__(hash_page_current=hash_page_current, filters_stock_item=filters_stock_item)
# BaseModel.__init__(self, app=app, filters_stock_item=filters_stock_item, **kwargs)
self.form_filters = Form_Filters_Stock_Item()
datastore_store = DataStore_Store(self.app, self.db)
datastore_store = DataStore_Store_Stock_Item()
self.category_list, errors = datastore_store.get_many_stock_item(filters_stock_item)
category_list_filters, errors_filters = datastore_store.get_many_stock_item(
Stock_Item_Filters(
@@ -78,4 +78,4 @@ class Model_View_Store_Stock_Item(Model_View_Store):
def save_stock_item(self, comment, list_stock_items):
_m = 'Model_View_Store_Stock_Item.save_stock_item'
DataStore_Store(self.app, self.db).save_stock_item(comment, list_stock_items)
DataStore_Store_Stock_Item().save_stock_item(comment, list_stock_items)

View File

@@ -12,16 +12,14 @@ Data model for supplier view page
# internal
from models.model_view_base import Model_View_Base
from models.model_view_store import Model_View_Store
# from routes import bp_home
from lib import argument_validation as av
from forms import Form_Supplier
# external
from flask_wtf import FlaskForm
from abc import abstractproperty
from pydantic import BaseModel
class Model_View_Supplier(Model_View_Base):
class Model_View_Store_Supplier(Model_View_Store):
# Attributes
form: Form_Supplier
@@ -36,8 +34,5 @@ class Model_View_Supplier(Model_View_Base):
av.val_instance(form, 'form', _m, FlaskForm)
return super(Model_View_Supplier, cls).__new__(cls, db, info_user, app)
"""
def __init__(self, db, info_user, app, form):
# Constructor
super().__init__(db, info_user, app)
BaseModel.__init__(self, form=form)
# self.form = form
def __init__(self,form, hash_page_current=Model_View_Base.HASH_PAGE_STORE_SUPPLIER):
super().__init__(hash_page_current=hash_page_current, form=form)

View File

@@ -21,7 +21,7 @@ class Model_View_User(Model_View_Base):
def title(self):
return 'User'
def __init__(self, app, db):
def __init__(self, hash_page_current=Model_View_Base.HASH_PAGE_USER_ACCOUNT):
# Constructor
super().__init__(app=app, db=db)
super().__init__(hash_page_current=hash_page_current)