1. View, filter, and save Product Permutation. \n 2. Synchronised with Product Category page and all common functionality moved into base and base table css, js, and python files.
This commit is contained in:
@@ -11,7 +11,9 @@ Business object for product
|
||||
"""
|
||||
|
||||
# internal
|
||||
from business_objects.store.store_base import Store_Base
|
||||
from extensions import db
|
||||
from lib import argument_validation as av
|
||||
# external
|
||||
from typing import ClassVar
|
||||
|
||||
@@ -39,13 +41,10 @@ class Currency_Enum(Enum):
|
||||
# return Resolution_Level_Enum.HIGH
|
||||
"""
|
||||
|
||||
class Currency(db.Model):
|
||||
ATTR_ID_CURRENCY: ClassVar[str] = 'id-currency'
|
||||
FLAG_CODE: ClassVar[str] = 'code-currency'
|
||||
FLAG_NAME: ClassVar[str] = 'name-currency'
|
||||
FLAG_SYMBOL: ClassVar[str] = 'symbol-currency'
|
||||
FLAG_FACTOR_FROM_GBP: ClassVar[str] = 'factor-from-GBP-currency'
|
||||
FLAG_DISPLAY_ORDER: ClassVar[str] = 'display-order-currency'
|
||||
class Currency(db.Model, Store_Base):
|
||||
FLAG_FACTOR_FROM_GBP: ClassVar[str] = 'factor-from-GBP'
|
||||
NAME_ATTR_OPTION_VALUE: ClassVar[str] = Store_Base.ATTR_ID_CURRENCY
|
||||
NAME_ATTR_OPTION_TEXT: ClassVar[str] = Store_Base.FLAG_NAME
|
||||
|
||||
id_currency = db.Column(db.Integer, primary_key=True)
|
||||
code = db.Column(db.String(50))
|
||||
@@ -53,29 +52,35 @@ class Currency(db.Model):
|
||||
symbol = db.Column(db.String(50))
|
||||
factor_from_GBP = db.Column(db.Float)
|
||||
display_order = db.Column(db.Integer)
|
||||
|
||||
def from_DB_currency(query_row):
|
||||
# _m = 'Currency.from_DB_currency'
|
||||
# v_arg_type = 'class attribute'
|
||||
currency = Currency()
|
||||
active = db.Column(db.Boolean)
|
||||
@classmethod
|
||||
def from_DB_currency(cls, query_row):
|
||||
_m = 'Currency.from_DB_currency'
|
||||
v_arg_type = 'class attribute'
|
||||
currency = cls()
|
||||
currency.id_currency = query_row[0]
|
||||
currency.code = query_row[1]
|
||||
currency.name = query_row[2]
|
||||
currency.symbol = query_row[3]
|
||||
currency.factor_from_GBP = query_row[4]
|
||||
currency.display_order = query_row[5]
|
||||
currency.active = av.input_bool(query_row[6], 'active', _m, v_arg_type=v_arg_type)
|
||||
return currency
|
||||
"""
|
||||
def from_DB_get_many_product_catalogue(query_row):
|
||||
_m = 'Currency.from_DB_get_many_product_catalogue'
|
||||
@classmethod
|
||||
def from_DB_get_many_product_catalogue_product_permutation(cls, query_row):
|
||||
_m = 'Currency.from_DB_get_many_product_catalogue_product_permutation'
|
||||
v_arg_type = 'class attribute'
|
||||
currency = Currency()
|
||||
currency.id_permutation = query_row[0]
|
||||
currency.id_product = query_row[1]
|
||||
currency.id_category = query_row[2]
|
||||
currency.id_variation = query_row[3]
|
||||
currency = cls()
|
||||
currency.id_currency = query_row[5]
|
||||
currency.code = query_row[6]
|
||||
currency.symbol = query_row[7]
|
||||
return currency
|
||||
@classmethod
|
||||
def from_DB_get_many_product_price_and_discount_and_delivery_region(cls, query_row):
|
||||
_m = 'Currency.from_DB_get_many_product_price_and_discount_and_delivery_region'
|
||||
v_arg_type = 'class attribute'
|
||||
currency = cls()
|
||||
return currency
|
||||
"""
|
||||
def __repr__(self):
|
||||
return f'''
|
||||
id: {self.id_currency}
|
||||
@@ -84,23 +89,35 @@ class Currency(db.Model):
|
||||
symbol: {self.symbol}
|
||||
factor from GBP: {self.factor_from_GBP}
|
||||
display_order: {self.display_order}
|
||||
active: {self.active}
|
||||
'''
|
||||
def to_json(self):
|
||||
return {
|
||||
Currency.ATTR_ID_CURRENCY: self.id_currency,
|
||||
Currency.FLAG_CODE: self.code,
|
||||
Currency.FLAG_NAME: self.name,
|
||||
Currency.FLAG_SYMBOL: self.symbol,
|
||||
Currency.FLAG_FACTOR_FROM_GBP: self.factor_from_GBP,
|
||||
Currency.FLAG_DISPLAY_ORDER: self.display_order
|
||||
**self.get_shared_json_attributes(self),
|
||||
self.NAME_ATTR_OPTION_TEXT: self.FLAG_NAME,
|
||||
self.NAME_ATTR_OPTION_VALUE: self.ATTR_ID_CURRENCY,
|
||||
self.ATTR_ID_CURRENCY: self.id_currency,
|
||||
self.FLAG_CODE: self.code,
|
||||
self.FLAG_NAME: self.name,
|
||||
self.FLAG_SYMBOL: self.symbol,
|
||||
self.FLAG_FACTOR_FROM_GBP: self.factor_from_GBP,
|
||||
self.FLAG_DISPLAY_ORDER: self.display_order,
|
||||
self.FLAG_ACTIVE: self.active,
|
||||
}
|
||||
@staticmethod
|
||||
def from_json(json_currency):
|
||||
currency = Currency()
|
||||
currency.id_currency = json_currency[Currency.ATTR_ID_CURRENCY]
|
||||
currency.code = json_currency[Currency.FLAG_CODE]
|
||||
currency.name = json_currency[Currency.FLAG_NAME]
|
||||
currency.symbol = json_currency[Currency.FLAG_SYMBOL]
|
||||
currency.factor_from_GBP = json_currency[Currency.FLAG_FACTOR_FROM_GBP]
|
||||
currency.display_order = json_currency[Currency.FLAG_DISPLAY_ORDER]
|
||||
return currency
|
||||
@classmethod
|
||||
def from_json(cls, json_currency, key_suffix = ''):
|
||||
currency = cls()
|
||||
currency.id_currency = json_currency[f'{cls.ATTR_ID_CURRENCY}{key_suffix}']
|
||||
currency.code = json_currency.get(f'{cls.FLAG_CODE}{key_suffix}')
|
||||
currency.name = json_currency.get(f'{cls.FLAG_NAME}{key_suffix}')
|
||||
currency.symbol = json_currency.get(f'{cls.FLAG_SYMBOL}{key_suffix}')
|
||||
currency.factor_from_GBP = json_currency.get(f'{cls.FLAG_FACTOR_FROM_GBP}{key_suffix}')
|
||||
currency.display_order = json_currency.get(f'{cls.FLAG_DISPLAY_ORDER}{key_suffix}')
|
||||
currency.active = json_currency.get(f'{cls.FLAG_ACTIVE}{key_suffix}')
|
||||
return currency
|
||||
|
||||
def to_json_option(self):
|
||||
return {
|
||||
'value': self.id_currency,
|
||||
'text': self.name
|
||||
}
|
||||
Reference in New Issue
Block a user