UX Improvements for Home page and Accessibility Statement page

This commit is contained in:
2024-07-31 16:52:05 +01:00
parent 6f4e329258
commit 0201b85836
2341 changed files with 11763 additions and 296638 deletions

View File

@@ -29,20 +29,24 @@ from typing import ClassVar
# VARIABLE INSTANTIATION
# CLASSES
class Model_View_Base(BaseModel, ABC):
# Global constants
ATTR_TEXT_COLLAPSED: ClassVar[str] = 'textCollapsed'
ATTR_TEXT_EXPANDED: ClassVar[str] = 'textExpanded'
FLAG_BUTTON_MODAL_CLOSE: ClassVar[str] = 'btn-overlay-close'
FLAG_BUTTON_SUBMIT: ClassVar[str] = 'btn-submit'
ATTR_VALUE_CURRENT: ClassVar[str] = 'current-value'
ATTR_VALUE_PREVIOUS: ClassVar[str] = 'previous-value'
FLAG_ACTIVE: ClassVar[str] = 'active'
FLAG_BUTTON_CANCEL: ClassVar[str] = 'button-cancel'
FLAG_BUTTON_MODAL_CLOSE: ClassVar[str] = 'button-overlay-close'
FLAG_BUTTON_SUBMIT: ClassVar[str] = 'button-submit'
FLAG_CARD: ClassVar[str] = 'card'
FLAG_COLLAPSED: ClassVar[str] = 'collapsed'
FLAG_COLLAPSIBLE: ClassVar[str] = 'collapsible'
FLAG_COLUMN: ClassVar[str] = 'column'
FLAG_CONTAINER: ClassVar[str] = 'container'
FLAG_CONTAINER_INPUT: ClassVar[str] = FLAG_CONTAINER + '-input'
FLAG_DIRTY: ClassVar[str] = 'dirty'
FLAG_ERROR: ClassVar[str] = 'error'
FLAG_EXPANDED: ClassVar[str] = 'expanded'
FLAG_HAMBURGER: ClassVar[str] = 'hamburger'
@@ -61,13 +65,19 @@ class Model_View_Base(BaseModel, ABC):
HASH_PAGE_LICENSE: ClassVar[str] = '/license'
HASH_PAGE_SERVICES: ClassVar[str] = '/services'
HASH_PAGE_STORE_HOME: ClassVar[str] = '/store'
HASH_PAGE_STORE_PERMUTATIONS: ClassVar[str] = '/store/permutations'
HASH_PAGE_STORE_PRODUCT: ClassVar[str] = '/store/product'
ID_BUTTON_HAMBURGER: ClassVar[str] = 'btnHamburger'
HASH_PAGE_STORE_PRODUCT_PERMUTATION: ClassVar[str] = '/store/permutation'
HASH_PAGE_STORE_PRODUCT_PERMUTATION_FILTER: ClassVar[str] = '/store/permutation_filter'
HASH_PAGE_STORE_PRODUCT_PERMUTATION_SAVE: ClassVar[str] = '/store/permutation_save'
ID_BUTTON_ADD: ClassVar[str] = 'buttonAdd'
ID_BUTTON_CANCEL: ClassVar[str] = 'buttonCancel'
ID_BUTTON_HAMBURGER: ClassVar[str] = 'buttonHamburger'
ID_BUTTON_SAVE: ClassVar[str] = 'buttonSave'
ID_FORM_CONTACT: ClassVar[str] = 'formContact'
ID_FORM_CURRENCY: ClassVar[str] = 'formCurrency'
ID_FORM_DELIVERY_REGION: ClassVar[str] = 'formDeliveryRegion'
ID_FORM_IS_INCLUDED_VAT: ClassVar[str] = 'formIsIncludedVAT'
ID_LABEL_ERROR: ClassVar[str] = 'labelError'
ID_MODAL_SERVICES: ClassVar[str] = 'modalServices'
ID_MODAL_TECHNOLOGIES: ClassVar[str] = 'modalTechnologies'
ID_NAV_CONTACT: ClassVar[str] = 'navContact'
@@ -76,9 +86,11 @@ class Model_View_Base(BaseModel, ABC):
ID_NAV_STORE_HOME: ClassVar[str] = 'navStoreHome'
ID_NAV_STORE_PERMUTATIONS: ClassVar[str] = 'navStorePermutations'
ID_NAV_STORE_PRODUCT: ClassVar[str] = 'navStoreProduct'
ID_OVERLAY_CONFIRM: ClassVar[str] = 'overlayConfirm'
ID_OVERLAY_HAMBURGER: ClassVar[str] = 'overlayHamburger'
ID_PAGE_BODY: ClassVar[str] = 'pageBody'
ID_TABLE_MAIN: ClassVar[str] = 'tableMain'
ID_TEXTAREA_CONFIRM: ClassVar[str] = 'textareaConfirm'
KEY_FORM: ClassVar[str] = 'form'
KEY_FORM_FILTERS: ClassVar[str] = KEY_FORM + 'Filters'
NAME_COMPANY: ClassVar[str] = 'Precision And Research Technology Systems Limited'

View File

@@ -37,7 +37,7 @@ class Model_View_Home(Model_View_Base):
print(f'info_user: {info_user}')
return super(Model_View_Home, cls).__new__(cls, db, info_user, app)
"""
def __init__(self, app):
def __init__(self, app, db):
# Constructor
super().__init__(app)
super().__init__(app=app, db=db)

View File

@@ -18,7 +18,7 @@ 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_Image_Filters,
from business_objects.product import Product, Product_Filters, Product_Permutation # Product_Image_Filters,
from business_objects.image import Resolution_Level_Enum
import lib.argument_validation as av
from datastores.datastore_store import DataStore_Store
@@ -38,19 +38,30 @@ from typing import ClassVar
class Model_View_Store(Model_View_Base):
# Global constants
ATTR_FORM_TYPE: ClassVar[str] = 'form-type'
ATTR_ID_PRODUCT_CATEGORY : ClassVar[str] = 'id-product-category'
ATTR_ID_PRODUCT : ClassVar[str] = 'id-product'
ATTR_ID_PERMUTATION : ClassVar[str] = 'id-permutation'
ATTR_ID_CATEGORY: ClassVar[str] = Product.ATTR_ID_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'
FLAG_BASKET_ITEM_DELETE : ClassVar[str] = 'basket-item-delete'
FLAG_BUTTON_BASKET_ADD : ClassVar[str] = Model_View_Base.FLAG_BUTTON_SUBMIT + '.btnAdd2Basket'
FLAG_BUTTON_BUY_NOW : ClassVar[str] = 'btnBuyNow'
FLAG_BUTTON_BASKET_ADD : ClassVar[str] = Model_View_Base.FLAG_BUTTON_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'
FLAG_DATE_EXPIRATION: ClassVar[str] = 'date-expiration'
FLAG_DATE_PURCHASED: ClassVar[str] = 'date-purchased'
FLAG_DATE_RECEIVED: ClassVar[str] = 'date-received'
FLAG_DATE_UNSEALED: ClassVar[str] = 'date-unsealed'
FLAG_IS_OUT_OF_STOCK: ClassVar[str] = 'is-out-of-stock'
FLAG_LOCATION_STORAGE: ClassVar[str] = 'storage-location'
FLAG_PRODUCT: ClassVar[str] = 'product'
FLAG_VARIATIONS: ClassVar[str] = 'variations'
FLAG_QUANTITY_STOCK: ClassVar[str] = 'quantity-stock'
FLAG_QUANTITY_MIN: ClassVar[str] = 'quantity-min'
FLAG_QUANTITY_MAX: ClassVar[str] = 'quantity-max'
FLAG_COST_LOCAL: ClassVar[str] = 'cost-local'
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'
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'
@@ -62,9 +73,9 @@ class Model_View_Store(Model_View_Base):
ID_BASKET : ClassVar[str] = 'basket'
ID_BASKET_CONTAINER : ClassVar[str] = 'basketContainer'
ID_BASKET_TOTAL : ClassVar[str] = 'basketTotal'
ID_BUTTON_CHECKOUT : ClassVar[str] = 'btnCheckout'
ID_BUTTON_BASKET_ADD : ClassVar[str] = 'btnBasketAdd'
ID_BUTTON_BUY_NOW : ClassVar[str] = 'btnBuyNow'
ID_BUTTON_CHECKOUT : ClassVar[str] = 'buttonCheckout'
ID_BUTTON_BASKET_ADD : ClassVar[str] = 'buttonBasketAdd'
ID_BUTTON_BUY_NOW : ClassVar[str] = 'buttonBuyNow'
ID_CURRENCY : ClassVar[str] = Form_Currency.id_id_currency # 'id_currency'
ID_CURRENCY_DEFAULT : ClassVar[str] = 1
ID_LABEL_BASKET_EMPTY : ClassVar[str] = 'basketEmpty'
@@ -107,7 +118,7 @@ class Model_View_Store(Model_View_Base):
print(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 + '.btnAdd2Basket'
# cls.FLAG_BUTTON_BASKET_ADD = cls.FLAG_BUTTON_SUBMIT + '.buttonAdd2Basket'
return super().__new__(cls, db, info_user, app) # Model_View_Store, cls
"""

View File

@@ -40,13 +40,13 @@ class Model_View_Store_Home(Model_View_Store):
return 'Store Home'
max_products_per_category = -1
def __new__(cls, db, id_user, app, id_currency, id_region_delivery, is_included_VAT):
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, id_user, app, id_currency, id_region_delivery, is_included_VAT)
return super(Model_View_Store_Home, cls).__new__(cls, db, 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, db, app, id_currency, id_region_delivery, is_included_VAT):
# Constructor
super().__init__(db, id_user, app, id_currency, id_region_delivery, is_included_VAT)
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)
"""

View File

@@ -0,0 +1,76 @@
"""
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 import DataStore_Store
from business_objects.category import Category_List
from forms import Form_Filters_Permutation
# from routes import bp_home
from business_objects.product import Product, Product_Filters, Product_Permutation
import lib.argument_validation as av
# external
from pydantic import BaseModel
from typing import ClassVar
class Model_View_Store_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: Category_List = None # (str)
filters_product: Product_Filters
form_filters: Form_Filters_Permutation = None
permutation_blank: Product_Permutation = None
@property
def title(self):
return 'Store Permutations'
def __init__(self, app, db, filters_product, **kwargs):
_m = 'Model_View_Store_Permutation.__init__'
print(f'{_m}\nstarting...')
super().__init__(app=app, db=db, filters_product=filters_product, **kwargs)
# 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(
Product_Filters(
# self.info_user['sub'],
True, False, False, '',
True, False, False, '',
True, False, False, '',
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}')
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)

View File

@@ -1,61 +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 import DataStore_Store
from business_objects.category import Category_List
from forms import Form_Filters_Permutations
# from routes import bp_home
from business_objects.product import Product, Product_Filters, Product_Permutation
import lib.argument_validation as av
# external
from pydantic import BaseModel
from typing import ClassVar
class Model_View_Store_Permutations(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'
category_list: Category_List = None # (str)
filters_product: Product_Filters
form_filters: Form_Filters_Permutations = None
permutation_blank: Product_Permutation = None
@property
def title(self):
return 'Store Permutations'
def __init__(self, app, db, filters_product, **kwargs):
_m = 'Model_View_Store_Permutations.__init__'
print(f'{_m}\nstarting...')
super().__init__(app=app, db=db, filters_product=filters_product, **kwargs)
# BaseModel.__init__(self, app=app, filters_product=filters_product, **kwargs)
self.form_filters = Form_Filters_Permutations()
self.category_list, errors = DataStore_Store(self.app, self.db).get_many_product_category(filters_product)
"""Product_Filters(
self.info_user['sub'],
True, False, False, '',
True, False, False, '',
False, False, False, '',
True, False, False, '',
False, False, False, '',
False, False, False, '',
True, False, '',
False
))
"""
self.permutation_blank = Product_Permutation()

View File

@@ -0,0 +1,81 @@
"""
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 import DataStore_Store
from business_objects.category import Category_List
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
import lib.argument_validation as av
# external
from pydantic import BaseModel
from typing import ClassVar
class Model_View_Store_Stock_Item(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: Category_List = None # (str)
filters_stock_item: Stock_Item_Filters
form_filters: Form_Filters_Stock_Item = None
permutation_blank: Product_Permutation = None
@property
def title(self):
return 'Store Stock Items'
def __init__(self, app, db, filters_stock_item, **kwargs):
_m = 'Model_View_Store_Stock_Item.__init__'
print(f'{_m}\nstarting...')
super().__init__(app=app, db=db, filters_stock_item=filters_stock_item, **kwargs)
# 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)
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(
# 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
)
)
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}')
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)