New website focusing on ERP services.

This commit is contained in:
2025-01-15 23:52:09 +00:00
parent 120cccd0d5
commit d1b90db6d7
207 changed files with 3827 additions and 24667 deletions

View File

@@ -1,26 +0,0 @@
"""
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 helpers.helper_app import Helper_App
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__'
Helper_App.console_log(f'{_m}\nstarting')
super().__init__(hash_page_current=hash_page_current, **kwargs)

View File

@@ -1,27 +0,0 @@
"""
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

@@ -18,7 +18,6 @@ Base data model for views
# internal
# from routes import bp_home
from business_objects.base import Base
from business_objects.store.product_category import Product_Category
from business_objects.user import User, Parameters_User
from datastores.datastore_base import DataStore_Base
from datastores.datastore_user import DataStore_User
@@ -46,8 +45,10 @@ class Model_View_Base(BaseModel, ABC):
ATTR_TEXT_EXPANDED: ClassVar[str] = 'textExpanded'
ATTR_VALUE_CURRENT: ClassVar[str] = 'current-value'
ATTR_VALUE_PREVIOUS: ClassVar[str] = 'previous-value'
COMPANY_ADDRESS_SHORT: ClassVar[str] = '53 Alfred Green Close, Rugby, United Kingdom, CV22 6DN'
COMPANY_NUMBER: ClassVar[str] = '13587499'
FLAG_ACCESS_LEVEL: ClassVar[str] = 'access_level'
FLAG_ACCESS_LEVEL_REQUIRED: ClassVar[str] = Product_Category.FLAG_ACCESS_LEVEL_REQUIRED
FLAG_ACCESS_LEVEL_REQUIRED: ClassVar[str] = Base.FLAG_ACCESS_LEVEL_REQUIRED
FLAG_ACTIVE: ClassVar[str] = Base.FLAG_ACTIVE
FLAG_ADD: ClassVar[str] = 'add'
# FLAG_ADD_DELETE: ClassVar[str] = 'add-delete'
@@ -56,6 +57,9 @@ class Model_View_Base(BaseModel, ABC):
FLAG_ADDRESS_LINE_2: ClassVar[str] = Base.FLAG_ADDRESS_LINE_2
FLAG_BOOL_FALSE: ClassVar[str] = 'false'
FLAG_BOOL_TRUE: ClassVar[str] = 'true'
FLAG_BUTTON: ClassVar[str] = 'button'
FLAG_BUTTON_LIGHT: ClassVar[str] = 'button-light'
FLAG_BUTTON_PRIMARY: ClassVar[str] = 'button-primary'
FLAG_CANCEL: ClassVar[str] = 'button-cancel'
FLAG_CALLBACK: ClassVar[str] = 'callback'
FLAG_CARD: ClassVar[str] = 'card'
@@ -68,8 +72,9 @@ class Model_View_Base(BaseModel, ABC):
FLAG_COMMENT: ClassVar[str] = 'comment'
# FLAG_CONTACT_US: ClassVar[str] = 'button-contact'
FLAG_CONTAINER: ClassVar[str] = 'container'
FLAG_CONTAINER_CHECKBOX: ClassVar[str] = 'container-checkbox'
FLAG_CONTAINER_ICON_AND_LABEL: ClassVar[str] = 'container-icon-label'
FLAG_CONTAINER_INPUT: ClassVar[str] = FLAG_CONTAINER + '-input'
FLAG_CONTAINER_INPUT: ClassVar[str] = 'container-input'
FLAG_COUNTY: ClassVar[str] = Base.FLAG_COUNTY
FLAG_CSRF_TOKEN: ClassVar[str] = 'X-CSRFToken'
FLAG_CURRENCY: ClassVar[str] = 'currency'
@@ -95,8 +100,9 @@ class Model_View_Base(BaseModel, ABC):
FLAG_IMAGE_LOGO: ClassVar[str] = 'image-logo'
FLAG_INITIALISED: ClassVar[str] = 'initialised'
FLAG_IS_INCLUDED_VAT: ClassVar[str] = 'is_included_VAT'
# FLAG_KEY_PRIMARY: ClassVar[str] = Store_Base.FLAG_KEY_PRIMARY
FLAG_MESSAGE: ClassVar[str] = 'Message'
FLAG_LEFT_HAND_STUB: ClassVar[str] = 'lhs'
FLAG_LOGO: ClassVar[str] = 'logo'
FLAG_MESSAGE: ClassVar[str] = 'message'
FLAG_MODAL: ClassVar[str] = 'modal'
FLAG_NAME: ClassVar[str] = Base.FLAG_NAME
FLAG_NAME_ATTR_OPTION_TEXT: ClassVar[str] = Base.FLAG_NAME_ATTR_OPTION_TEXT
@@ -127,6 +133,7 @@ class Model_View_Base(BaseModel, ABC):
FLAG_PAGE_BODY: ClassVar[str] = 'page-body'
FLAG_PHONE_NUMBER: ClassVar[str] = Base.FLAG_PHONE_NUMBER
FLAG_POSTCODE: ClassVar[str] = Base.FLAG_POSTCODE
FLAG_RIGHT_HAND_SIDE: ClassVar[str] = 'rhs'
FLAG_ROW: ClassVar[str] = 'row'
FLAG_ROW_NEW: ClassVar[str] = 'row-new'
FLAG_ROWS: ClassVar[str] = Base.FLAG_ROWS
@@ -153,24 +160,10 @@ class Model_View_Base(BaseModel, ABC):
HASH_PAGE_LICENSE: ClassVar[str] = '/license'
HASH_PAGE_PRIVACY_POLICY: ClassVar[str] = '/privacy-policy'
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_CUSTOMER_SALES_ORDERS: ClassVar[str] = '/store/customer_sales_orders'
HASH_PAGE_STORE_HOME: ClassVar[str] = '/store'
HASH_PAGE_STORE_MANUFACTURING_PURCHASE_ORDERS: ClassVar[str] = '/store/manufacturing_purchase_orders'
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_SUPPLIERS: ClassVar[str] = '/store/suppliers'
HASH_PAGE_STORE_SUPPLIER_PURCHASE_ORDERS: ClassVar[str] = '/store/supplier_purchase_orders'
HASH_PAGE_USER_ACCOUNT: ClassVar[str] = '/user'
HASH_PAGE_USER_ADMIN: ClassVar[str] = '/user/admin'
HASH_PAGE_USER_LOGIN: ClassVar[str] = '/login'
HASH_PAGE_USER_LOGOUT: ClassVar[str] = '/logout'
HASH_SCRIPTS_SECTION_STORE: ClassVar[str] = '/scripts_store'
ID_BUTTON_ADD: ClassVar[str] = 'buttonAdd'
ID_BUTTON_APPLY_FILTERS: ClassVar[str] = 'buttonApplyFilters'
ID_BUTTON_CANCEL: ClassVar[str] = 'buttonCancel'
@@ -192,14 +185,6 @@ class Model_View_Base(BaseModel, ABC):
# 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'
@@ -211,6 +196,7 @@ class Model_View_Base(BaseModel, ABC):
ID_TABLE_MAIN: ClassVar[str] = 'tableMain'
ID_TEXTAREA_CONFIRM: ClassVar[str] = 'textareaConfirm'
NAME_COMPANY: ClassVar[str] = 'Precision And Research Technology Systems Limited'
NAME_COMPANY_SHORT: ClassVar[str] = 'PARTS Ltd'
NAME_CSRF_TOKEN: ClassVar[str] = 'csrf-token'
# URL_HOST: ClassVar[str] = os.env() 'http://127.0.0.1:5000' # 'https://www.partsltd.co.uk'
URL_GITHUB: ClassVar[str] = 'https://github.com/Teddy-1024'
@@ -392,4 +378,6 @@ class Model_View_Base(BaseModel, ABC):
return date_time.strftime('%Y-%m-%dT%H:%M')
@staticmethod
def jsonify(data):
return jsonify(data)
return jsonify(data)
def get_mail_contact_public(self):
return self.app.config['MAIL_CONTACT_PUBLIC']

View File

@@ -14,18 +14,27 @@ Data model for contact view
from models.model_view_base import Model_View_Base
# from routes import bp_home
from lib import argument_validation as av
from forms.forms import Form_Contact
from forms.contact import Form_Contact
# external
from flask_wtf import FlaskForm
from abc import abstractproperty
from pydantic import BaseModel
from typing import ClassVar
class Model_View_Contact(Model_View_Base):
# Attributes
ID_EMAIL: str = 'email'
ID_MESSAGE: str = 'msg'
ID_NAME: str = 'name'
FLAG_COMPANY_NAME: ClassVar[str] = 'company_name'
FLAG_CONTACT_NAME: ClassVar[str] = 'contact_name'
FLAG_RECEIVE_MARKETING: ClassVar[str] = 'receive_marketing'
"""
ID_EMAIL: ClassVar[str] = 'email'
ID_COMPANY_NAME: ClassVar[str] = 'company_name'
ID_CONTACT_NAME: ClassVar[str] = 'contact_name'
ID_MESSAGE: ClassVar[str] = 'msg'
ID_RECEIVE_MARKETING: ClassVar[str] = 'receive_marketing'
ID_NAME: ClassVar[str] = 'name'
"""
form_contact: Form_Contact
@property

View File

@@ -1,27 +0,0 @@
"""
Project: PARTS Website
Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: View Models
Feature: Services View Model
Description:
Data model for services view
"""
# internal
from models.model_view_base import Model_View_Base
# from routes import bp_home
# external
class Model_View_Services(Model_View_Base):
# Attributes
@property
def title(self):
return 'Services'
def __init__(self, hash_page_current=Model_View_Base.HASH_PAGE_SERVICES):
# Constructor
super().__init__(hash_page_current=hash_page_current)

View File

@@ -1,515 +0,0 @@
"""
Project: PARTS Website
Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: View Models
Feature: Store Parent View Model
Description:
Parent data model for store views
"""
# IMPORTS
# VARIABLE INSTANTIATION
# METHODS
# IMPORTS
# internal
# from context import models
from business_objects.store.store_base import Store_Base
from business_objects.store.product import Product, Parameters_Product, Product_Permutation # Product_Image_Filters,
# from business_objects.store.product_category import Filters_Product_Category
from business_objects.store.image import Resolution_Level_Enum
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, Parameters_Product_Variation
from business_objects.store.stock_item import Stock_Item
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.forms import Form_Basket_Edit, Form_Is_Included_VAT, Form_Delivery_Region, Form_Currency
from helpers.helper_app import Helper_App
import lib.argument_validation as av
from models.model_view_base import Model_View_Base
# external
from flask import send_file, jsonify
from flask_sqlalchemy import SQLAlchemy
import locale
from typing import ClassVar
from abc import abstractmethod
class Model_View_Store(Model_View_Base):
# Global constants
ATTR_FORM_TYPE: ClassVar[str] = 'form-type'
ATTR_ID_CUSTOMER: ClassVar[str] = 'id-customer'
ATTR_ID_CUSTOMER_ADDRESS: ClassVar[str] = Store_Base.ATTR_ID_CUSTOMER_ADDRESS
ATTR_ID_CUSTOMER_SALES_ORDER: ClassVar[str] = 'id-customer-sales-order'
ATTR_ID_DELIVERY_OPTION: ClassVar[str] = Store_Base.ATTR_ID_DELIVERY_OPTION
ATTR_ID_DISCOUNT: ClassVar[str] = Store_Base.ATTR_ID_DISCOUNT
ATTR_ID_MANUFACTURING_PURCHASE_ORDER: ClassVar[str] = Store_Base.ATTR_ID_MANUFACTURING_PURCHASE_ORDER
ATTR_ID_MANUFACTURING_PURCHASE_ORDER_PRODUCT_LINK: ClassVar[str] = Store_Base.ATTR_ID_MANUFACTURING_PURCHASE_ORDER_PRODUCT_LINK
ATTR_ID_PLANT: ClassVar[str] = 'id-plant'
ATTR_ID_PRODUCT : ClassVar[str] = Product.ATTR_ID_PRODUCT # 'id-product'
ATTR_ID_PRODUCT_CATEGORY: ClassVar[str] = Product.ATTR_ID_PRODUCT_CATEGORY
ATTR_ID_PRODUCT_PERMUTATION : ClassVar[str] = Product.ATTR_ID_PRODUCT_PERMUTATION # 'id-permutation'
ATTR_ID_PRODUCT_PRICE: ClassVar[str] = Product.ATTR_ID_PRODUCT_PRICE
ATTR_ID_PRODUCT_VARIATION : ClassVar[str] = Product_Variation.ATTR_ID_PRODUCT_VARIATION # 'id-variation'
ATTR_ID_PRODUCT_VARIATION_TYPE : ClassVar[str] = Product_Variation.ATTR_ID_PRODUCT_VARIATION_TYPE # 'id-variation-type'
ATTR_ID_STOCK_ITEM: ClassVar[str] = Store_Base.ATTR_ID_STOCK_ITEM
ATTR_ID_STORAGE_LOCATION: ClassVar[str] = Store_Base.ATTR_ID_STORAGE_LOCATION
ATTR_ID_SUPPLIER: ClassVar[str] = Store_Base.ATTR_ID_SUPPLIER
ATTR_ID_SUPPLIER_ADDRESS: ClassVar[str] = Store_Base.ATTR_ID_SUPPLIER_ADDRESS
ATTR_ID_SUPPLIER_PURCHASE_ORDER: ClassVar[str] = Store_Base.ATTR_ID_SUPPLIER_PURCHASE_ORDER
ATTR_ID_SUPPLIER_PURCHASE_ORDER_PRODUCT_LINK: ClassVar[str] = Store_Base.ATTR_ID_SUPPLIER_PURCHASE_ORDER_PRODUCT_LINK
ATTR_ID_UNIT_MEASUREMENT_LATENCY_MANUFACTURE: ClassVar[str] = Product_Permutation.ATTR_ID_UNIT_MEASUREMENT_LATENCY_MANUFACTURE
ATTR_ID_UNIT_MEASUREMENT_QUANTITY: ClassVar[str] = Product_Permutation.ATTR_ID_UNIT_MEASUREMENT_QUANTITY
FLAG_BUTTON_BASKET_ADD : ClassVar[str] = Model_View_Base.FLAG_SUBMIT + '.buttonAddToBasket'
FLAG_BUTTON_BUY_NOW : ClassVar[str] = 'buttonBuyNow'
"""
FLAG_COST_LOCAL: ClassVar[str] = Store_Base.FLAG_COST_LOCAL
FLAG_COST_LOCAL_VAT_EXCL: ClassVar[str] = Store_Base.FLAG_COST_LOCAL_VAT_EXCL
FLAG_COST_LOCAL_VAT_INCL: ClassVar[str] = Store_Base.FLAG_COST_LOCAL_VAT_INCL
"""
FLAG_COST_TOTAL_LOCAL_VAT_EXCL: ClassVar[str] = Store_Base.FLAG_COST_TOTAL_LOCAL_VAT_EXCL
FLAG_COST_TOTAL_LOCAL_VAT_INCL: ClassVar[str] = Store_Base.FLAG_COST_TOTAL_LOCAL_VAT_INCL
FLAG_COST_UNIT_LOCAL_VAT_EXCL: ClassVar[str] = Store_Base.FLAG_COST_UNIT_LOCAL_VAT_EXCL
FLAG_COST_UNIT_LOCAL_VAT_INCL: ClassVar[str] = Store_Base.FLAG_COST_UNIT_LOCAL_VAT_INCL
FLAG_COUNT_UNIT_MEASUREMENT_INTERVAL_EXPIRATION_UNSEALED: ClassVar[str] = Product_Permutation.FLAG_COUNT_UNIT_MEASUREMENT_INTERVAL_EXPIRATION_UNSEALED
FLAG_COUNT_UNIT_MEASUREMENT_INTERVAL_RECURRENCE: ClassVar[str] = Product_Permutation.FLAG_COUNT_UNIT_MEASUREMENT_INTERVAL_RECURRENCE
FLAG_COUNT_UNIT_MEASUREMENT_PER_QUANTITY_STEP: ClassVar[str] = Product_Permutation.FLAG_COUNT_UNIT_MEASUREMENT_PER_QUANTITY_STEP
FLAG_CURRENCY_COST: ClassVar[str] = Product_Permutation.FLAG_CURRENCY_COST
FLAG_CUSTOMER: ClassVar[str] = Store_Base.FLAG_CUSTOMER
FLAG_CUSTOMER_ADDRESS: ClassVar[str] = Store_Base.FLAG_CUSTOMER_ADDRESS
FLAG_CUSTOMER_SALES_ORDER: ClassVar[str] = Store_Base.FLAG_CUSTOMER_SALES_ORDER
FLAG_DATE_CONSUMED: ClassVar[str] = Stock_Item.FLAG_DATE_CONSUMED
FLAG_DATE_EXPIRATION: ClassVar[str] = Stock_Item.FLAG_DATE_EXPIRATION
FLAG_DATE_PURCHASED: ClassVar[str] = Stock_Item.FLAG_DATE_PURCHASED
FLAG_DATE_RECEIVED: ClassVar[str] = Stock_Item.FLAG_DATE_RECEIVED
FLAG_DATE_UNSEALED: ClassVar[str] = Stock_Item.FLAG_DATE_UNSEALED
FLAG_DISCOUNT: ClassVar[str] = Store_Base.FLAG_DISCOUNT
FLAG_DOES_EXPIRE_FASTER_ONCE_UNSEALED: ClassVar[str] = Product_Permutation.FLAG_DOES_EXPIRE_FASTER_ONCE_UNSEALED
FLAG_HAS_VARIATIONS: ClassVar[str] = Product_Permutation.FLAG_HAS_VARIATIONS
FLAG_ID_STRIPE_PRODUCT: ClassVar[str] = Product_Permutation.FLAG_ID_STRIPE_PRODUCT
FLAG_IS_CONSUMED: ClassVar[str] = Stock_Item.FLAG_IS_CONSUMED
FLAG_IS_NOT_EMPTY: ClassVar[str] = Store_Base.FLAG_IS_NOT_EMPTY
FLAG_IS_OUT_OF_STOCK: ClassVar[str] = Store_Base.FLAG_IS_OUT_OF_STOCK
FLAG_IS_SEALED: ClassVar[str] = Stock_Item.FLAG_IS_SEALED
FLAG_IS_SUBSCRIPTION: ClassVar[str] = Product_Permutation.FLAG_IS_SUBSCRIPTION
FLAG_LATENCY_DELIVERY_DAYS: ClassVar[str] = Store_Base.FLAG_LATENCY_DELIVERY_DAYS
FLAG_LATENCY_MANUFACTURE: ClassVar[str] = Product_Permutation.FLAG_LATENCY_MANUFACTURE
FLAG_MANUFACTURING_PURCHASE_ORDER: ClassVar[str] = Store_Base.FLAG_MANUFACTURING_PURCHASE_ORDER
FLAG_NAME_PLURAL_UNIT_MEASUREMENT_INTERVAL_EXPIRATION_UNSEALED: ClassVar[str] = Product_Permutation.FLAG_NAME_PLURAL_UNIT_MEASUREMENT_INTERVAL_EXPIRATION_UNSEALED
FLAG_NAME_PLURAL_UNIT_MEASUREMENT_INTERVAL_RECURRENCE: ClassVar[str] = Product_Permutation.FLAG_NAME_PLURAL_UNIT_MEASUREMENT_INTERVAL_RECURRENCE
FLAG_NAME_PLURAL_UNIT_MEASUREMENT_QUANTITY: ClassVar[str] = Product_Permutation.FLAG_NAME_PLURAL_UNIT_MEASUREMENT_QUANTITY
FLAG_NAME_SINGULAR_UNIT_MEASUREMENT_INTERVAL_EXPIRATION_UNSEALED: ClassVar[str] = Product_Permutation.FLAG_NAME_SINGULAR_UNIT_MEASUREMENT_INTERVAL_EXPIRATION_UNSEALED
FLAG_NAME_SINGULAR_UNIT_MEASUREMENT_INTERVAL_RECURRENCE: ClassVar[str] = Product_Permutation.FLAG_NAME_SINGULAR_UNIT_MEASUREMENT_INTERVAL_RECURRENCE
FLAG_NAME_SINGULAR_UNIT_MEASUREMENT_QUANTITY: ClassVar[str] = Product_Permutation.FLAG_NAME_SINGULAR_UNIT_MEASUREMENT_QUANTITY
FLAG_ORDER_ITEMS: ClassVar[str] = Store_Base.FLAG_ORDER_ITEMS
FLAG_PLANT: ClassVar[str] = Store_Base.FLAG_PLANT
FLAG_PRICE_TOTAL_LOCAL_VAT_EXCL: ClassVar[str] = Store_Base.FLAG_PRICE_TOTAL_LOCAL_VAT_EXCL
FLAG_PRICE_TOTAL_LOCAL_VAT_INCL: ClassVar[str] = Store_Base.FLAG_PRICE_TOTAL_LOCAL_VAT_INCL
FLAG_PRICE_UNIT_LOCAL_VAT_EXCL: ClassVar[str] = Store_Base.FLAG_PRICE_UNIT_LOCAL_VAT_EXCL
FLAG_PRICE_UNIT_LOCAL_VAT_INCL: ClassVar[str] = Store_Base.FLAG_PRICE_UNIT_LOCAL_VAT_INCL
FLAG_PRODUCT: ClassVar[str] = Store_Base.FLAG_PRODUCT
FLAG_PRODUCT_CATEGORY: ClassVar[str] = Store_Base.FLAG_PRODUCT_CATEGORY
FLAG_PRODUCT_PERMUTATION: ClassVar[str] = Store_Base.FLAG_PRODUCT_PERMUTATION
FLAG_PRODUCT_PRICE: ClassVar[str] = Store_Base.FLAG_PRODUCT_PRICE
FLAG_PRODUCT_VARIATION: ClassVar[str] = Store_Base.FLAG_PRODUCT_VARIATION
FLAG_PRODUCT_VARIATIONS: ClassVar[str] = Store_Base.FLAG_PRODUCT_VARIATIONS
FLAG_PRODUCT_VARIATION_TYPE: ClassVar[str] = Store_Base.FLAG_PRODUCT_VARIATION_TYPE
FLAG_PROFIT_LOCAL_MIN: ClassVar[str] = Product_Permutation.FLAG_PROFIT_LOCAL_MIN
FLAG_QUANTITY: ClassVar[str] = 'quantity'
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_ORDERED: ClassVar[str] = Store_Base.FLAG_QUANTITY_ORDERED
FLAG_QUANTITY_RECEIVED: ClassVar[str] = Store_Base.FLAG_QUANTITY_RECEIVED
FLAG_QUANTITY_STOCK: ClassVar[str] = Product_Permutation.FLAG_QUANTITY_STOCK # 'quantity-stock'
FLAG_REGION: ClassVar[str] = Store_Base.FLAG_REGION
FLAG_STOCK_ITEM: ClassVar[str] = Store_Base.FLAG_STOCK_ITEM
FLAG_STORAGE_LOCATION: ClassVar[str] = Store_Base.FLAG_STORAGE_LOCATION
FLAG_SUPPLIER: ClassVar[str] = Store_Base.FLAG_SUPPLIER
FLAG_SUPPLIER_ADDRESS: ClassVar[str] = Store_Base.FLAG_SUPPLIER_ADDRESS
FLAG_SUPPLIER_PURCHASE_ORDER: ClassVar[str] = Store_Base.FLAG_SUPPLIER_PURCHASE_ORDER
FLAG_SYMBOL_CURRENCY_COST: ClassVar[str] = Product_Permutation.FLAG_SYMBOL_CURRENCY_COST
FLAG_SYMBOL_IS_SUFFIX_NOT_PREFIX_UNIT_INTERVAL_EXPIRATION_UNSEALED: ClassVar[str] = Product_Permutation.FLAG_SYMBOL_IS_SUFFIX_NOT_PREFIX_UNIT_INTERVAL_EXPIRATION_UNSEALED
FLAG_SYMBOL_IS_SUFFIX_NOT_PREFIX_UNIT_MEASUREMENT_INTERVAL_RECURRENCE: ClassVar[str] = Product_Permutation.FLAG_SYMBOL_IS_SUFFIX_NOT_PREFIX_UNIT_MEASUREMENT_INTERVAL_RECURRENCE
FLAG_SYMBOL_IS_SUFFIX_NOT_PREFIX_UNIT_MEASUREMENT_QUANTITY: ClassVar[str] = Product_Permutation.FLAG_SYMBOL_IS_SUFFIX_NOT_PREFIX_UNIT_MEASUREMENT_QUANTITY
FLAG_SYMBOL_UNIT_MEASUREMENT_INTERVAL_EXPIRATION_UNSEALED: ClassVar[str] = Product_Permutation.FLAG_SYMBOL_UNIT_MEASUREMENT_INTERVAL_EXPIRATION_UNSEALED
FLAG_SYMBOL_UNIT_MEASUREMENT_INTERVAL_RECURRENCE: ClassVar[str] = Product_Permutation.FLAG_SYMBOL_UNIT_MEASUREMENT_INTERVAL_RECURRENCE
FLAG_SYMBOL_UNIT_MEASUREMENT_QUANTITY: ClassVar[str] = Product_Permutation.FLAG_SYMBOL_UNIT_MEASUREMENT_QUANTITY
FLAG_UNIT_MEASUREMENT_INTERVAL_EXPIRATION_UNSEALED: ClassVar[str] = Product_Permutation.FLAG_UNIT_MEASUREMENT_INTERVAL_EXPIRATION_UNSEALED
FLAG_UNIT_MEASUREMENT_INTERVAL_RECURRENCE: ClassVar[str] = Product_Permutation.FLAG_UNIT_MEASUREMENT_INTERVAL_RECURRENCE
FLAG_UNIT_MEASUREMENT_LATENCY_MANUFACTURE: ClassVar[str] = Store_Base.FLAG_UNIT_MEASUREMENT_LATENCY_MANUFACTURE
FLAG_UNIT_MEASUREMENT_QUANTITY: ClassVar[str] = Product_Permutation.FLAG_UNIT_MEASUREMENT_QUANTITY
HASH_GET_STORE_CUSTOMER_SALES_ORDER: ClassVar[str] = '/store/customer_sales_order_get'
HASH_GET_STORE_MANUFACTURING_PURCHASE_ORDER: ClassVar[str] = '/store/manufacturing_purchase_order_get'
HASH_GET_STORE_PRODUCT: ClassVar[str] = '/store/product_get'
HASH_GET_STORE_PRODUCT_CATEGORY: ClassVar[str] = '/store/category_get'
HASH_GET_STORE_PRODUCT_PERMUTATION: ClassVar[str] = '/store/permutation_get'
HASH_GET_STORE_PRODUCT_VARIATION: ClassVar[str] = '/store/product_variation_get'
HASH_GET_STORE_STOCK_ITEM: ClassVar[str] = '/store/stock_item_get'
HASH_GET_STORE_SUPPLIER: ClassVar[str] = '/store/supplier_get'
HASH_GET_STORE_SUPPLIER_PURCHASE_ORDER: ClassVar[str] = '/store/supplier_purchase_order_get'
HASH_PAGE_STORE_BASKET : ClassVar[str] = '/store/basket'
HASH_SAVE_STORE_CUSTOMER_SALES_ORDER: ClassVar[str] = '/store/save_customer_sales_order'
HASH_SAVE_STORE_MANUFACTURING_PURCHASE_ORDER: ClassVar[str] = '/store/save_manufacturing_purchase_order'
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_PRODUCT_VARIATION: ClassVar[str] = '/store/save_product_variation'
HASH_SAVE_STORE_STOCK_ITEM: ClassVar[str] = '/store/save_stock_item'
HASH_SAVE_STORE_SUPPLIER: ClassVar[str] = '/store/save_supplier'
HASH_SAVE_STORE_SUPPLIER_PURCHASE_ORDER: ClassVar[str] = '/store/save_supplier_purchase_order'
HASH_STORE_BASKET_ADD : ClassVar[str] = '/store/basket_add'
HASH_STORE_BASKET_DELETE : ClassVar[str] = '/store/basket_delete'
HASH_STORE_BASKET_EDIT : ClassVar[str] = '/store/basket_edit'
HASH_STORE_BASKET_LOAD : ClassVar[str] = '/store/basket_load'
HASH_STORE_SET_CURRENCY : ClassVar[str] = '/store/set_currency'
HASH_STORE_SET_DELIVERY_REGION : ClassVar[str] = '/store/set_delivery_region'
HASH_STORE_SET_IS_INCLUDED_VAT : ClassVar[str] = '/store/set_is_included_VAT'
ID_BASKET : ClassVar[str] = 'basket'
ID_BASKET_CONTAINER : ClassVar[str] = 'basketContainer'
ID_BASKET_TOTAL : ClassVar[str] = 'basketTotal'
ID_BUTTON_BASKET_ADD : ClassVar[str] = 'buttonBasketAdd'
ID_BUTTON_BUY_NOW : ClassVar[str] = 'buttonBuyNow'
ID_BUTTON_CHECKOUT : ClassVar[str] = 'buttonCheckout'
ID_CURRENCY : ClassVar[str] = Form_Currency.id_id_currency # 'id_currency'
ID_CURRENCY_DEFAULT : ClassVar[str] = 1
ID_LABEL_BASKET_EMPTY : ClassVar[str] = 'basketEmpty'
ID_PRODUCT_CATEGORY_DEFAULT: ClassVar[str] = 1
ID_REGION_DELIVERY_DEFAULT : ClassVar[str] = 1
IS_INCLUDED_VAT_DEFAULT : ClassVar[str] = True
"""
KEY_BASKET : ClassVar[str] = Basket.KEY_BASKET # 'basket'
# KEY_CODE_CURRENCY : ClassVar[str] = 'code_currency'
KEY_ID_CURRENCY : ClassVar[str] = Basket.KEY_ID_CURRENCY # 'id_currency'
KEY_ID_PRODUCT : ClassVar[str] = 'product_id'
KEY_ID_PERMUTATION : ClassVar[str] = 'permutation_id'
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_PRICE : ClassVar[str] = 'price'
KEY_QUANTITY : ClassVar[str] = 'quantity'
KEY_VALUE_DEFAULT : ClassVar[str] = 'default'
"""
TYPE_FORM_BASKET_ADD : ClassVar[str] = 'Form_Basket_Add'
TYPE_FORM_BASKET_EDIT : ClassVar[str] = 'Form_Basket_Edit'
# development variables
# valid_product_id_list = ['prod_PB0NUOSEs06ymG']
# Attributes
# id_user: str
# db: SQLAlchemy
# basket: Basket # list # dict
# basket_total: float
"""
id_currency: bool
id_region_delivery: bool
is_included_VAT: bool
show_delivery_option: bool # for checkout page
"""
"""
def __new__(cls, db, info_user, app, id_currency, id_region_delivery, is_included_VAT): # , *args, **kwargs``
# Initialiser - validation
_m = 'Model_View_Store.__new__'
v_arg_type = 'class attribute'
Helper_App.console_log(f'{_m}\nstarting')
# av.val_str(id_user, 'id_user', _m)
# return super().__new__(cls, *args, **kwargs)
# cls.FLAG_BUTTON_BASKET_ADD = cls.FLAG_BUTTON_SUBMIT + '.buttonAddToBasket'
return super().__new__(cls, db, info_user, app) # Model_View_Store, cls
"""
@property
def title(self):
raise NotImplementedError('title must be implemented in child class')
def __init__(self, hash_page_current, **kwargs): # , id_currency, id_region_delivery, is_included_VAT):
# Constructor
_m = 'Model_View_Store.__init__'
Helper_App.console_log(f'{_m}\nstarting')
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)
# self.basket_total = 0
# self.db = db
# if logged in:
# else:
self.id_currency = id_currency
self.id_region_delivery = id_region_delivery
self.is_included_VAT = is_included_VAT
self.show_delivery_option = True
self.form_is_included_VAT = Form_Is_Included_VAT()
regions, currencies = self.get_many_region_and_currency()
self.form_currency = Form_Currency(id_currency=self.id_currency)
self.form_currency.id_currency.choices = [(currency.id_currency, f'{currency.code} - {currency.name}') for currency in currencies]
self.form_currency.id_currency.data = str(self.id_currency) if len(currencies) > 0 else None
self.form_delivery_region = Form_Delivery_Region(id_region_delivery=self.id_region_delivery)
self.form_delivery_region.id_region_delivery.choices = [(region.id_region, f'{region.code} - {region.name}') for region in regions]
self.form_delivery_region.id_region_delivery.data = str(self.id_region_delivery) if len(regions) > 0 else None
"""
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, Parameters_Product)
"""
av.val_str(category_ids, 'category_ids', _m)
av.val_str(product_ids, 'product_ids', _m)
av.val_bool(get_all_category, 'get_all_category', _m)
av.val_bool(get_all_product, 'get_all_product', _m)
av.val_int(max_products_per_category, 'max_products_per_category', _m)
"""
# get products from database
# call datastore method
# return [Product.template()]
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
return
if get_all_category or get_all_product:
prod = Product.template()
prod_list = [ prod, prod ]
return { 'MISCELLANEOUS': prod_list if max_products_per_category < 0 else prod_list[:max_products_per_category] }
if product_ids == 'panties123':
prod = Product.template()
return { 'MISCELLANEOUS': [ prod] }
# def product_category_getMany(self, category_ids = '', product_ids = '', get_all_category = True, get_all_product = True):
# return Model_View_Store.product_category_getMany(category_ids, product_ids, get_all_category, get_all_product)
def get_many_product_image_src(self, product_id, image_ids = '', get_primary_only = True, resolution_level = ''):
_m = 'Model_View_Store.get_many_product_image'
# Helper_App.console_log(f'{_m}\n')
# av.val_instance(filters, 'filters', _m, Product_Image_Filters)
av.val_int(product_id, 'product_id', _m)
# av.full_val_int(product_id, 'product_id', _m)
# product_id = int(product_id)
av.val_str(image_ids, 'image_ids', _m)
av.full_val_bool(get_primary_only, 'get_primary_only', _m)
get_primary_only = bool(get_primary_only)
resolution_level = Resolution_Level_Enum.get_member_by_text(resolution_level)
av.val_instance(resolution_level, 'resolution_level', _m, Resolution_Level_Enum)
# if (filters.product_id < 0 or filters.product_id not in self.valid_product_id_list):
if (product_id not in Model_View_Store.valid_product_id_list): # product_id < 0 or
return ''
path_suffix = 'jpg' # get_suffix_from_product_id(product_id)
path_file = f'/static/images/{product_id}.{path_suffix}'
return path_file
# return send_file(path_file, mimetype=f'image/{path_suffix}')
"""
def get_product_category_text(self, category):
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'
av.full_val_int(product_id, 'product_id', _m)
product_id = str(product_id)
av.full_val_int(quantity, 'quantity', _m)
quantity = int(quantity)
av.val_instance(basket_local, 'basket_local', _m, dict)
# send to database
# update basket on webpage with new database status
if product_id in basket_local:
basket_local[product_id] += quantity
else:
basket_local[product_id] = quantity
return basket_local // jsonify(basket_local)
"""
def basket_item_edit(self, permutation_id, quantity, quantity_sum_not_replace):
_m = 'Model_View_Store.basket_item_edit'
# av.full_val_int(product_id, 'product_id', _m)
# product_id = int(product_id)
# av.val_instance(db, 'db', _m, SQLAlchemy)
Helper_App.console_log(f'{_m} starting')
# Helper_App.console_log(f'product_id: {product_id}\npermutation_id: {permutation_id}\nquantity = {quantity}')
# av.full_val_int(product_id, 'product_id', _m)
# Helper_App.console_log('valid product id')
av.full_val_int(quantity, 'quantity', _m)
quantity = int(quantity)
# item_added = False
Helper_App.console_log(f'basket: {self.basket}')
ids_permutation, quantities_permutation = self.basket.to_csv()
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_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):
product_ids = ''
permutation_ids = ''
item_index_dict = {}
if len(basket) > 0:
for index_item in range(len(basket)):
if index_item > 0:
product_ids += ','
permutation_ids += ','
basket_item = basket[index_item]
id_product = basket_item[self.KEY_ID_PRODUCT]
id_permutation = basket_item[self.KEY_ID_PERMUTATION]
id_permutation = '' if (id_permutation is None or id_permutation == 'None') else str(id_permutation)
product_ids += str(id_product) # str(basket[b].product.id)
permutation_ids += id_permutation # str(basket[b].product.id)
# item_index_dict[Basket.get_key_product_index_from_ids_product_permutation(id_product, id_permutation)] = index_item
item_index_dict[id_permutation] = index_item
Helper_App.console_log(f'product_ids = {product_ids}')
Helper_App.console_log(f'permutation_ids = {permutation_ids}')
return product_ids, permutation_ids, item_index_dict
def _get_basket_from_json(self, json_data):
basket = json_data[self.KEY_BASKET]['items']
av.val_instance(basket, 'basket', 'Model_View_Store._get_basket_from_json', list)
Helper_App.console_log(f'basket = {basket}')
return basket
def import_JSON_basket(self, json_data):
_m = 'Model_View_Store.import_JSON_basket'
# av.val_instance(db, 'db', _m, SQLAlchemy)
items = self._get_basket_from_json(json_data)
basket = json_data[self.KEY_BASKET]
id_currency = basket[self.KEY_ID_CURRENCY]
id_region_delivery = basket[self.KEY_ID_REGION_DELIVERY]
is_included_VAT = basket[self.KEY_IS_INCLUDED_VAT]
Helper_App.console_log(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_Base().get_many_product(Parameters_Product(
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
False, permutation_ids, False, # :a_get_all_permutation, :a_ids_permutation, :a_get_inactive_permutation
False, '', False, True, # :a_get_all_image, :a_ids_image, :a_get_inactive_image, :a_get_first_image_only
False, str(id_region_delivery), False, # :a_get_all_delivery_region, :a_ids_delivery_region, :a_get_inactive_delivery_region
False, str(id_currency), False, # :a_get_all_currency, :a_ids_currency, :a_get_inactive_currency
True, '', False # :a_get_all_discount, :a_ids_discount, :a_get_inactive_discount
)) # product_ids=product_ids, get_all_category=False, get_all_product=False)
# Helper_App.console_log(f'categories = {categories}')
self.basket = Basket(id_currency, id_region_delivery, is_included_VAT)
if len(category_list.categories) > 0: # not (categories is None):
for category in category_list.categories:
for product in category.products:
# 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.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)):
"""
Helper_App.console_log(f'basket data: {json_data}')
Helper_App.console_log(f'basket: {self.basket}')
# ids_permutation_unavailable_region_or_currency = []
# id_permutation_unavailable_otherwise = []
if len(errors) > 0:
for error in errors:
if error[1] == 'PRODUCT_AVAILABILITY':
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()
if id_permutation == permutation.id_permutation:
item.is_available = False
if 'region' in error[2] or 'currency' in error[2]:
item.is_unavailable_in_currency_or_region = True
# ids_permutation_unavailable_region_or_currency.append(id_permutation)
# else:
# for id_permutation in ids_permutation:
# id_permutation_unavailable_otherwise.append(id_permutation)
"""
ids_permutation_unavailable = self.basket.get_ids_permutation_unavailable()
if len(ids_permutation_unavailable) > 0:
category_list_unavailable, errors_unavailable = DataStore_Store().get_many_product(Parameters_Product(
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
False, ','.join(ids_permutation_unavailable), False, # :a_get_all_permutation, :a_ids_permutation, :a_get_inactive_permutation
False, '', False, True, # :a_get_all_image, :a_ids_image, :a_get_inactive_image, :a_get_first_image_only
True, '', False, # :a_get_all_delivery_region, :a_ids_delivery_region, :a_get_inactive_delivery_region
True, '', False, # :a_get_all_currency, :a_ids_currency, :a_get_inactive_currency
True, '', False # :a_get_all_discount, :a_ids_discount, :a_get_inactive_discount
)) # product_ids=product_ids, get_all_category=False, get_all_product=False)
else:
category_list_unavailable = None
errors_unavailable = []
"""
def import_JSON_basket_item(self, json_data, form_basket = None):
_m = 'Model_View_Store.import_JSON_basket_item'
Helper_App.console_log(f'starting {_m}')
# Helper_App.console_log('getting product id')
# product_id = av.input_int(json_data[self.key_id_product], self.key_id_product, _m)
# Helper_App.console_log(f'product id: {product_id}, type: {str(type(product_id))}')
try:
permutation_id = json_data[self.KEY_ID_PERMUTATION]
av.full_val_int(permutation_id, self.KEY_ID_PERMUTATION, _m)
permutation_id = int(permutation_id)
except:
permutation_id = None
if not permutation_id == 'None':
Helper_App.console_log(f'permutation_id invalid: {permutation_id}')
raise ValueError("Invalid permutation id")
Helper_App.console_log(f'permutation_id: {permutation_id}')
try:
Helper_App.console_log(f'form_basket: {form_basket}')
Helper_App.console_log('getting quantity')
Helper_App.console_log(f'form_basket.quantity: {form_basket.quantity}')
Helper_App.console_log(f'form_basket.quantity.data: {form_basket.quantity.data}')
quantity = int(form_basket.quantity.data)
except:
quantity = 0
Helper_App.console_log(f'quantity: {quantity}')
Helper_App.console_log(f'permutation_id: {permutation_id}\nquantity: {quantity}')
return permutation_id, quantity
def output_basket_total(self):
return self.basket.output_total()
def init_forms_basket_add(self):
for cat in self.categories:
c = self.category_index
def get_many_user_order(self, ids_order, n_order_max, id_checkout_session):
# _m = 'Model_View_Store.get_many_user_order'
# av.val_str(id_user)
# validation conducted by server
return DataStore_User().get_many_user_order(self.info_user['sub'], ids_order, n_order_max, id_checkout_session)
def get_many_plant(self, get_inactive = False):
plants = DataStore_Store_Base().get_many_plant(get_inactive)
return plants
def get_many_storage_location(self, get_inactive = False):
storage_locations = DataStore_Store_Base().get_many_storage_location(get_inactive)
return storage_locations
def get_many_currency(self):
currencies = DataStore_Store_Base().get_many_currency()
return currencies
def get_many_region(self):
regions = DataStore_Store_Base().get_many_region()
return regions
def get_many_region_and_currency(self):
regions, currencies = DataStore_Store_Base().get_many_region_and_currency()
return regions, currencies
def get_many_product_variation(self, variation_filters = None):
if variation_filters is None:
variation_filters = Parameters_Product_Variation.get_default()
variation_types, variations, errors = DataStore_Store_Base().get_many_product_variation(variation_filters)
return variation_types, variations, errors

View File

@@ -1,89 +0,0 @@
"""
Project: PARTS Website
Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: View Models
Feature: Store Basket View Model
Description:
Data model for store basket view
"""
# IMPORTS
# VARIABLE INSTANTIATION
# METHODS
# IMPORTS
# internal
from models.model_view_store import Model_View_Store
# from routes import bp_home
from business_objects.store.product import Product
from forms.forms import Form_Billing # Form_Product
# external
# VARIABLE INSTANTIATION
# CLASSES
class Model_View_Store_Basket(Model_View_Store):
# Attributes
# product_categories: list # (str)
form_delivery: Form_Billing
form_billing: Form_Billing
forms_delivery_method: list # []
is_collapsed_info_billing: bool
is_collapsed_info_delivery: bool
# Global constants
# category_products: dict { category_enum_id: List[Product] }
hash_page_store_checkout = '/store/checkout'
hash_page_store_checkout_session = '/store/checkout_session'
hash_store_basket_info = '/store/basket_info'
id_container_info_billing = 'containerInfoBilling'
id_container_info_delivery = 'containerInfoDelivery'
id_overlay_info_delivery = 'overlayInfoDelivery'
id_overlay_info_billing = 'overlayInfoBilling'
key_address1 = 'address_1'
key_address2 = 'address_2'
key_city = 'city'
key_county = 'county'
key_id_checkout = 'checkout-session-id'
key_info_billing = 'billing-info'
key_info_delivery = 'delivery-info'
key_info_identical = 'identical'
key_info_type = 'type-info'
key_is_subscription = 'is-subscription'
key_name_full = 'name_full'
key_phone_number = 'phone_number'
key_postcode = 'postcode'
key_region = 'region'
key_url_checkout = 'checkout-url'
# Attributes
@property
def title(self):
return 'Store Basket'
def __init__(self, id_currency, id_region_delivery, is_included_VAT, hash_page_current=Model_View_Store.HASH_PAGE_STORE_BASKET):
# Constructor
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()
# if logged in:
# else:
self.is_collapsed_info_billing = False
self.is_collapsed_info_delivery = False
"""
self.forms_product = {}
for cat in self.product_categories:
for product in cat:
if len(list(product.variations.keys())) == 0:
new_form = Form_Product()
if new_form.validate_on_submit():
# Handle form submission
self.add_2_basket(product.id, )
self.forms[str(product.id)] = new_form
"""

View File

@@ -1,71 +0,0 @@
"""
Project: PARTS Website
Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: View Models
Feature: Store Checkout View Model
Description:
Data model for store checkout view
"""
# IMPORTS
# VARIABLE INSTANTIATION
# METHODS
# IMPORTS
# internal
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.store.product import Product
from forms.forms import Form_Billing # Form_Product
import lib.argument_validation as av
# from datastores.datastore_store_base import DataStore_Store
# external
import os
import stripe
# VARIABLE INSTANTIATION
# CLASSES
class Model_View_Store_Checkout(Model_View_Store_Basket):
# Attributes
key_secret_stripe: str
key_public_stripe: str
# Global constants
key_id_price = 'price_id'
@property
def title(self):
return 'Store Checkout'
def __init__(self, id_currency, id_region_delivery, is_included_VAT, hash_page_current=Model_View_Store.HASH_PAGE_STORE_CHECKOUT):
# Constructor
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")
# For sample support and debugging, not required for production:
stripe.set_app_info(
'stripe-samples/checkout-one-time-payments',
version='0.0.1',
url='https://github.com/stripe-samples/checkout-one-time-payments')
stripe.api_key = self.key_secret_stripe
"""
def create_product(self, product): # _name, product_description):
return DataStore_Store().create_product(product) # _name, product_description)
def create_price(self, product, currency):
return DataStore_Store().create_price(product, currency)
def get_many_product_new(self):
return DataStore_Store().get_many_product_new()
def get_price_id(product_ids):
return DataStore_Store().get_many_id_price(product_ids)
"""

View File

@@ -1,49 +0,0 @@
"""
Project: PARTS Website
Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: View Models
Feature: Store Checkout Success View Model
Description:
Data model for store checkout success view
"""
# IMPORTS
# VARIABLE INSTANTIATION
# METHODS
# IMPORTS
# internal
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.store.product import Product
from forms.forms import Form_Billing # Form_Product
import lib.argument_validation as av
# from datastores.datastore_store_base import DataStore_Store
# external
import os
# VARIABLE INSTANTIATION
# CLASSES
class Model_View_Store_Checkout_Success(Model_View_Store_Checkout):
# Attributes
key_secret_stripe: str
key_public_stripe: str
# Global constants
key_id_price = 'price_id'
@property
def title(self):
return 'Store Checkout Success'
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__(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

@@ -1,59 +0,0 @@
"""
Project: PARTS Website
Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: View Models
Feature: Store Home View Model
Description:
Data model for store home view
"""
# IMPORTS
# VARIABLE INSTANTIATION
# METHODS
# IMPORTS
# internal
from models.model_view_store import Model_View_Store
# from routes import bp_home
from business_objects.store.product import Product
from forms.forms import Form_Basket_Add, Form_Basket_Edit # Form_Product
# external
from typing import ClassVar
# VARIABLE INSTANTIATION
# CLASSES
class Model_View_Store_Home(Model_View_Store):
# Global constants
MAX_PRODUCTS_PER_CATEGORY: ClassVar[int] = -1
# Attributes
product_categories: list # (str)
forms_product: dict
forms_basket: dict
# category_products: dict { category_enum_id: List[Product] }
# Attributes
@property
def title(self):
return 'Store Home'
def __init__(self, id_currency, id_region_delivery, is_included_VAT, hash_page_current=Model_View_Store.HASH_PAGE_STORE_HOME):
# Constructor
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:
for product in cat:
if len(list(product.variations.keys())) == 0:
new_form = Form_Product()
if new_form.validate_on_submit():
# Handle form submission
self.add_2_basket(product.id, )
self.forms[str(product.id)] = new_form
"""

View File

@@ -1,61 +0,0 @@
"""
Project: PARTS Website
Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: View Models
Feature: Manufacturing Purchase Order View Model
Description:
Data model for manufacturing purchase order view page
"""
# internal
from models.model_view_store import Model_View_Store
from datastores.datastore_store_manufacturing_purchase_order import DataStore_Store_Manufacturing_Purchase_Order
from business_objects.store.product import Product, Parameters_Product
from business_objects.store.product_category import Product_Category_Container
from business_objects.store.manufacturing_purchase_order import Manufacturing_Purchase_Order, Parameters_Manufacturing_Purchase_Order, Manufacturing_Purchase_Order_Product_Link
from forms.store.manufacturing_purchase_order import Filters_Manufacturing_Purchase_Order
from helpers.helper_app import Helper_App
import lib.argument_validation as av
# external
from typing import ClassVar
class Model_View_Store_Manufacturing_Purchase_Order(Model_View_Store):
FLAG_QUANTITY_PRODUCED: ClassVar[str] = Manufacturing_Purchase_Order_Product_Link.FLAG_QUANTITY_PRODUCED
FLAG_QUANTITY_USED: ClassVar[str] = Manufacturing_Purchase_Order_Product_Link.FLAG_QUANTITY_USED
category_list_filters: Product_Category_Container = None
currencies: list = None
currency_options: list = None
form_filters: Filters_Manufacturing_Purchase_Order = None
form_filters_old: Filters_Manufacturing_Purchase_Order
manufacturing_purchase_orders: list = None
units_measurement: list = None
units_measurement_time: list = None
variation_types: list = None
variations: list = None
@property
def title(self):
return 'Store Manufacturing Purchase Order'
def __init__(self, form_filters_old, hash_page_current=Model_View_Store.HASH_PAGE_STORE_MANUFACTURING_PURCHASE_ORDERS):
_m = 'Model_View_Store_Manufacturing.__init__'
Helper_App.console_log(f'{_m}\nstarting...')
super().__init__(hash_page_current = hash_page_current, form_filters_old = form_filters_old)
self.form_filters = form_filters_old # Filters_Manufacturing_Purchase_Order.from_json(form_filters_old.to_json())
parameters_manufacturing_purchase_order = Parameters_Manufacturing_Purchase_Order.from_filters_manufacturing_purchase_order(form_filters_old)
datastore_manufacturing_purchase_order = DataStore_Store_Manufacturing_Purchase_Order()
self.manufacturing_purchase_orders, errors = datastore_manufacturing_purchase_order.get_many_manufacturing_purchase_order(parameters_manufacturing_purchase_order)
self.category_list_filters, errors = DataStore_Store_Manufacturing_Purchase_Order.get_many_product(Parameters_Product.get_default())
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]
@classmethod
def save_manufacturing_purchase_orders(cls, comment, list_orders):
_m = f'{cls.__name__}.save_manufacturing_purchase_orders'
return DataStore_Store_Manufacturing_Purchase_Order().save_manufacturing_purchase_orders(comment, list_orders)

View File

@@ -1,88 +0,0 @@
"""
Project: PARTS Website
Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: View Models
Feature: Store Product View Model
Description:
Data model for store product view
"""
# 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.access_level import Filters_Access_Level
from forms.store.product import Filters_Product
from helpers.helper_app import Helper_App
from models.model_view_store import Model_View_Store
# from routes import bp_home
import lib.argument_validation as av
# external
from typing import ClassVar
class Model_View_Store_Product(Model_View_Store):
access_levels: list = None
category_list: Product_Category_Container = None
category_list_filters: Product_Category_Container = None
currencies: list = None
currency_options: list = None
form_filters: Filters_Product = None
form_filters_old: Filters_Product
list_options_product: list = None
# product_blank: Product = None
units_measurement: list = None
units_measurement_time: list = None
variations: list = None
variation_types: list = None
@property
def title(self):
return 'Products'
def __init__(self, form_filters_old, hash_page_current=Model_View_Store.HASH_PAGE_STORE_PRODUCTS):
_m = 'Model_View_Store_Product.__init__'
Helper_App.console_log(f'{_m}\nstarting...')
super().__init__(hash_page_current=hash_page_current, form_filters_old=form_filters_old)
self.form_filters = form_filters_old
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)
countProducts = 0
for category in self.category_list.categories:
countProducts += len(category.products)
Helper_App.console_log(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,
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
)
)
Helper_App.console_log(f'category filters: {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]
Helper_App.console_log(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]
Helper_App.console_log(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'
return DataStore_Store_Product.save_products(comment, list_products)

View File

@@ -1,58 +0,0 @@
"""
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_base import DataStore_Store_Base
from datastores.datastore_store_product_category import DataStore_Store_Product_Category
from business_objects.store.product import Parameters_Product
from business_objects.store.product_category import Product_Category_Container # , Filters_Product_Category
from forms.access_level import Filters_Access_Level
# from forms.store.product_permutation import Filters_Product_Permutation
from forms.store.product_category import Filters_Product_Category
# from routes import bp_home
from helpers.helper_app import Helper_App
import lib.argument_validation as av
# external
from pydantic import BaseModel
from typing import ClassVar
class Model_View_Store_Product_Category(Model_View_Store):
# KEY_CATEGORIES: ClassVar[str] = 'categories'
access_levels: list = None
category_list: Product_Category_Container = None # (str)
# filters_category: Filters_Product_Category
form_filters: Filters_Product_Category = None
form_filters_old: Filters_Product_Category
@property
def title(self):
return 'Product Category'
def __init__(self, form_filters_old, hash_page_current=Model_View_Store.HASH_PAGE_STORE_PRODUCT_CATEGORIES):
_m = 'Model_View_Store_Product_Category.__init__'
Helper_App.console_log(f'{_m}\nstarting...')
super().__init__(hash_page_current=hash_page_current, form_filters_old=form_filters_old) # filters_category=filters_category)
self.form_filters = form_filters_old
# BaseModel.__init__(self, app=app, filters_product=filters_product, **kwargs)
self.access_levels = self.get_many_access_level(Filters_Access_Level())
datastore_store = DataStore_Store_Product_Category()
# self.form_filters = Filters_Product_Category.from_filters(filters_category)
filters_product = Parameters_Product.from_filters_product_category(self.form_filters)
self.category_list, errors = datastore_store.get_many_product(filters_product)
@classmethod
def save_categories(cls, comment, list_categories):
_m = f'{cls.__name__}.save_categories'
return DataStore_Store_Product_Category().save_categories(comment, list_categories)

View File

@@ -1,86 +0,0 @@
"""
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 Product_Category_Container
from forms.store.product_permutation import Filters_Product_Permutation
# from routes import bp_home
from business_objects.store.product import Product, Parameters_Product, Product_Permutation
from helpers.helper_app import Helper_App
import lib.argument_validation as av
# external
from pydantic import BaseModel
from typing import ClassVar
class Model_View_Store_Product_Permutation(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_Permutation = None
form_filters_old: Filters_Product_Permutation
list_options_product: list = None
units_measurement: list = None
units_measurement_time: list = None
variations: list = None
variation_types: list = None
@property
def title(self):
return 'Product Permutations'
def __init__(self, form_filters_old, hash_page_current=Model_View_Store.HASH_PAGE_STORE_PRODUCT_PERMUTATIONS):
_m = 'Model_View_Store_Permutation.__init__'
Helper_App.console_log(f'{_m}\nstarting...')
super().__init__(hash_page_current=hash_page_current, form_filters_old=form_filters_old)
self.form_filters = form_filters_old
# self.form_filters = Filters_Product_Permutation()
filters_product = Parameters_Product.from_form_filters_product_permutation(self.form_filters)
datastore_store = DataStore_Store_Product_Permutation()
self.category_list, errors = datastore_store.get_many_product(filters_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 = filters_product.get_products_quantity_stock_below_min
)
)
Helper_App.console_log(f'category filters: {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]
Helper_App.console_log(f'category options: {self.form_filters.id_category.choices}')
self.list_options_product = self.category_list_filters.to_product_option_list()
Helper_App.console_log(f'product options: {self.list_options_product}')
self.form_filters.id_product.choices += [(str(product['value']), product['text']) for product in self.list_options_product]
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_permutations(comment, list_permutations):
_m = 'Model_View_Store_Permutation.save_permutations'
DataStore_Store_Product_Permutation.save_permutations(comment, list_permutations)

View File

@@ -1,54 +0,0 @@
"""
Project: PARTS Website
Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: View Models
Feature: Store Product View Model
Description:
Data model for store product view
"""
# IMPORTS
# VARIABLE INSTANTIATION
# METHODS
# IMPORTS
# internal
from business_objects.store.product_variation import Product_Variation, Parameters_Product_Variation
from business_objects.store.product_category import Product_Category_Container
from datastores.datastore_store_product_variation import DataStore_Store_Product_Variation
from forms.access_level import Filters_Access_Level
from forms.store.product_variation import Filters_Product_Variation
from helpers.helper_app import Helper_App
from models.model_view_store import Model_View_Store
# from routes import bp_home
import lib.argument_validation as av
# external
from typing import ClassVar
class Model_View_Store_Product_Variation(Model_View_Store):
form_filters: Filters_Product_Variation = None
form_filters_old: Filters_Product_Variation
variation_types: list = None
variations: list = None
@property
def title(self):
return 'Store Product Variation'
def __init__(self, form_filters_old, hash_page_current=Model_View_Store.HASH_PAGE_STORE_PRODUCT_VARIATIONS):
_m = 'Model_View_Store_Product_Variation.__init__'
Helper_App.console_log(f'{_m}\nstarting...')
super().__init__(hash_page_current = hash_page_current, form_filters_old = form_filters_old)
self.form_filters = form_filters_old
parameters_variation = Parameters_Product_Variation.from_filters_product_variation(self.form_filters)
datastore_variation = DataStore_Store_Product_Variation()
self.variation_types, self.variations, errors = datastore_variation.get_many_product_variation(parameters_variation)
@classmethod
def save_product_variations(cls, comment, list_orders):
_m = f'{cls.__name__}.save_product_variations'
return DataStore_Store_Product_Variation().save_product_variations(comment, list_orders)

View File

@@ -1,98 +0,0 @@
"""
Project: PARTS Website
Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: View Models
Feature: Store Stock Items View Model
Description:
Data model for store stock items view
"""
# internal
from models.model_view_store import Model_View_Store
from datastores.datastore_store_stock_item import DataStore_Store_Stock_Item
from business_objects.store.product_category import Product_Category_Container
# from routes import bp_home
from business_objects.store.product import Product, Parameters_Product, Product_Permutation
from business_objects.store.stock_item import Stock_Item, Parameters_Stock_Item
from forms.store.stock_item import Filters_Stock_Item
from helpers.helper_app import Helper_App
import lib.argument_validation as av
# external
from pydantic import BaseModel
from typing import ClassVar
class Model_View_Store_Stock_Item(Model_View_Store):
category_list: Product_Category_Container = None
category_list_filters: Product_Category_Container = None
currencies: list = None
currency_options: list = None
form_filters: Filters_Stock_Item = None
form_filters_old: Filters_Stock_Item
list_options_product: list = None
plants: list = None
storage_locations: list = None
units_measurement: list = None
units_measurement_time: list = None
variations: list = None
variation_types: list = None
@property
def title(self):
return 'Store Stock Items'
def __init__(self, form_filters_old, hash_page_current=Model_View_Store.HASH_PAGE_STORE_STOCK_ITEMS):
_m = 'Model_View_Store_Stock_Item.__init__'
Helper_App.console_log(f'{_m}\nstarting...')
super().__init__(hash_page_current=hash_page_current, form_filters_old=form_filters_old)
# BaseModel.__init__(self, app=app, form_filters_old=form_filters_old, **kwargs)
self.form_filters = form_filters_old # Filters_Stock_Item.from_json(form_filters_old.to_json()) # .from_form_stock_item(form_filters_old)
datastore_store = DataStore_Store_Stock_Item()
tmp_category_list_stock_item, errors = datastore_store.get_many_product(Parameters_Product.from_filters_stock_item(self.form_filters))
self.category_list, errors = datastore_store.get_many_stock_item(Parameters_Stock_Item.from_form_stock_item(self.form_filters), tmp_category_list_stock_item)
self.category_list_filters, errors_filters = datastore_store.get_many_product(Parameters_Product.get_default())
"""
Parameters_Stock_Item(
# self.info_user['sub'],
True, False, False, '', # get_all_category, get_inactive_category, get_first_category_only, ids_category
True, False, False, '', # get_all_product, get_inactive_product, get_first_product_only, ids_product
True, False, False, '', # get_all_permutation, get_inactive_permutation, get_first_permutation_only, ids_permutation
False, False, False, '', # get_all_stock_item, get_inactive_stock_item, get_first_stock_item_only, ids_stock_item
False, False, False, '', # get_all_region_storage, get_inactive_region_storage, get_first_region_storage_only, ids_region_storage
False, False, False, '', # get_all_plant_storage, get_inactive_plant_storage, get_first_plant_storage_only, ids_plant_storage
False, False, False, '', # get_all_location_storage, get_inactive_location_storage, get_first_location_storage_only, ids_location_storage
None, # date_received_to
False, False, # get_sealed_stock_item_only, get_unsealed_stock_item_only
False, False, # get_expired_stock_item_only, get_nonexpired_stock_item_only
False, False # get_consumed_stock_item_only, get_nonconsumed_stock_item_only
)
"""
Helper_App.console_log(f'category_list_filters: {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] # [Filters_Stock_Item.get_choice_all()] +
Helper_App.console_log(f'category options: {self.form_filters.id_category.choices}')
product_list = self.category_list_filters.to_product_option_list()
filtered_product_list = []
if product_list is not None:
for product in product_list:
# Helper_App.console_log(f'product: {product}\n{product[Stock_Item.ATTR_ID_PRODUCT_CATEGORY]}\n{self.form_filters.id_category.data}\n{str(type(product[Stock_Item.ATTR_ID_PRODUCT_CATEGORY]))}\n{str(type(self.form_filters.id_category.data))}')
if (self.form_filters.id_category.data == '' or str(product[Stock_Item.ATTR_ID_PRODUCT_CATEGORY]) == self.form_filters.id_category.data):
filtered_product_list.append(product)
Helper_App.console_log(f'product_list: {product_list}\nfiltered_product_list: {filtered_product_list}')
self.form_filters.id_product.choices += [(str(product['value']), product['text']) for product in filtered_product_list] # [Filters_Stock_Item.get_choice_all()] +
# self.form_filters.import_values(form_filters_old)
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]
self.plants = self.get_many_plant(False)
self.storage_locations = self.get_many_storage_location(False)
@classmethod
def save_stock_items(cls, comment, list_stock_items):
_m = f'{cls.__name__}.save_stock_items'
return DataStore_Store_Stock_Item().save_stock_items(comment, list_stock_items)

View File

@@ -1,63 +0,0 @@
"""
Project: PARTS Website
Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: View Models
Feature: Supplier View Model
Description:
Data model for supplier view page
"""
# internal
from models.model_view_store import Model_View_Store
from datastores.datastore_store_supplier import DataStore_Store_Supplier
from business_objects.store.supplier import Supplier, Parameters_Supplier
from forms.store.supplier import Filters_Supplier
from helpers.helper_app import Helper_App
import lib.argument_validation as av
# external
from typing import ClassVar
class Model_View_Store_Supplier(Model_View_Store):
FLAG_DEPARTMENT_CONTACT: ClassVar[str] = Supplier.FLAG_DEPARTMENT_CONTACT
FLAG_NAME_COMPANY: ClassVar[str] = Supplier.FLAG_NAME_COMPANY
FLAG_NAME_CONTACT: ClassVar[str] = Supplier.FLAG_NAME_CONTACT
supplier_addresses: list = None
currencies: list = None
currency_options: list = None
form_filters: Filters_Supplier = None
form_filters_old: Filters_Supplier
regions: list = None
suppliers: list = None
units_measurement: list = None
units_measurement_time: list = None
@property
def title(self):
return 'Store Supplier'
def __init__(self, form_filters_old, hash_page_current=Model_View_Store.HASH_PAGE_STORE_SUPPLIERS):
_m = 'Model_View_Store_Supplier.__init__'
Helper_App.console_log(f'{_m}\nstarting...')
super().__init__(hash_page_current = hash_page_current, form_filters_old = form_filters_old)
self.form_filters = form_filters_old # Filters_Supplier.from_json(form_filters_old.to_json())
parameters_supplier = Parameters_Supplier.from_filters_supplier(self.form_filters)
datastore_supplier = DataStore_Store_Supplier()
self.suppliers, errors = datastore_supplier.get_many_supplier(parameters_supplier)
"""
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]
self.supplier_addresses = {}
for supplier in self.suppliers:
self.supplier_addresses[supplier.id_supplier] = [address.to_json() for address in supplier.addresses] if supplier.addresses else []
self.regions = self.get_many_region()
@classmethod
def save_suppliers(cls, comment, list_suppliers):
_m = f'{cls.__name__}.save_suppliers'
return DataStore_Store_Supplier().save_suppliers(comment, list_suppliers)

View File

@@ -1,62 +0,0 @@
"""
Project: PARTS Website
Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: View Models
Feature: Supplier Purchase Order View Model
Description:
Data model for supplier purchase order view page
"""
# internal
from models.model_view_store import Model_View_Store
from datastores.datastore_store_supplier import DataStore_Store_Supplier
from datastores.datastore_store_supplier_purchase_order import DataStore_Store_Supplier_Purchase_Order
from business_objects.store.product import Product, Parameters_Product
from business_objects.store.product_category import Product_Category_Container
from business_objects.store.supplier import Supplier, Parameters_Supplier
from business_objects.store.supplier_purchase_order import Supplier_Purchase_Order, Parameters_Supplier_Purchase_Order
from forms.store.supplier_purchase_order import Filters_Supplier_Purchase_Order
from helpers.helper_app import Helper_App
import lib.argument_validation as av
class Model_View_Store_Supplier_Purchase_Order(Model_View_Store):
category_list_filters: Product_Category_Container = None
currencies: list = None
currency_options: list = None
form_filters: Filters_Supplier_Purchase_Order = None
form_filters_old: Filters_Supplier_Purchase_Order
supplier_purchase_orders: list = None
suppliers: list = None
units_measurement: list = None
units_measurement_time: list = None
variation_types: list = None
variations: list = None
@property
def title(self):
return 'Store Supplier Purchase Order'
def __init__(self, form_filters_old, hash_page_current=Model_View_Store.HASH_PAGE_STORE_SUPPLIER_PURCHASE_ORDERS):
_m = 'Model_View_Store_Supplier.__init__'
Helper_App.console_log(f'{_m}\nstarting...')
super().__init__(hash_page_current = hash_page_current, form_filters_old = form_filters_old)
self.form_filters = form_filters_old # Filters_Supplier_Purchase_Order.from_json(form_filters_old.to_json())
parameters_supplier_purchase_order = Parameters_Supplier_Purchase_Order.from_filters_supplier_purchase_order(self.form_filters)
datastore_supplier_purchase_order = DataStore_Store_Supplier_Purchase_Order()
self.supplier_purchase_orders, errors = datastore_supplier_purchase_order.get_many_supplier_purchase_order(parameters_supplier_purchase_order)
self.suppliers, errors = DataStore_Store_Supplier.get_many_supplier(Parameters_Supplier.get_default())
self.category_list_filters, errors = DataStore_Store_Supplier_Purchase_Order.get_many_product(Parameters_Product.get_default())
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]
@classmethod
def save_supplier_purchase_orders(cls, comment, list_orders):
_m = f'{cls.__name__}.save_supplier_purchase_orders'
return DataStore_Store_Supplier_Purchase_Order().save_supplier_purchase_orders(comment, list_orders)

View File

@@ -12,13 +12,12 @@ Data model for user view
# internal
from datastores.datastore_user import DataStore_User
# from models.model_view_base import Model_View_Base
from models.model_view_store import Model_View_Store
from models.model_view_base import Model_View_Base
# from routes import bp_home
# external
from typing import ClassVar
class Model_View_User(Model_View_Store):
class Model_View_User(Model_View_Base):
FLAG_ERROR_OAUTH: ClassVar[str] = 'error'
FLAG_ERROR_DESCRIPTION_OAUTH: ClassVar[str] = 'error_description'
FLAG_FIRSTNAME: ClassVar[str] = 'firstname'
@@ -32,7 +31,7 @@ class Model_View_User(Model_View_Store):
def title(self):
return 'User'
def __init__(self, hash_page_current=Model_View_Store.HASH_PAGE_USER_ACCOUNT):
def __init__(self, hash_page_current=Model_View_Base.HASH_PAGE_USER_ACCOUNT):
# Constructor
super().__init__(hash_page_current=hash_page_current, form_filters_old = None)
datastore_user = DataStore_User()