1. Refactoring form objects and database objects to use inheritance and abstract base class for consistency and reduced redundancy.\n2. Contact us page button links updated to resolve error of missing link causing page refresh instead of expected functionality.

This commit is contained in:
2024-09-10 12:09:50 +01:00
parent c9dda91dc9
commit 6b730bf8e7
709 changed files with 5158 additions and 1512 deletions

View File

@@ -38,24 +38,19 @@ class Product_Variation_Tree_Node():
class Product_Variation_Tree():
node_root: Product_Variation_Tree_Node
def from_node_root(node_root):
tree = Product_Variation_Tree()
@classmethod
def from_node_root(cls, node_root):
tree = cls()
tree.node_root = node_root
return tree
def get_variation_type_list(self):
variation_types = []
node = self.node_root
at_leaf_node = node.is_leaf()
while not at_leaf_node:
variation_types.append(node.variation.name_variation_type)
at_leaf_node = node.is_leaf()
if not at_leaf_node:
node = node.nodes_child[0]
return variation_types
@classmethod
def from_variation_root(cls, variation_root):
node_root = Product_Variation_Tree_Node.from_variation_and_node_parent(variation_root, None)
return cls.from_node_root(node_root)
def is_equal(self, tree):
my_type_list = self.get_variation_type_list()
my_type_list = self.get_product_variations()
sz_me = len(my_type_list)
other_type_list = tree.get_variation_type_list()
other_type_list = tree.get_product_variations()
sz_other = len(other_type_list)
is_equal = (sz_me == sz_other)
if is_equal:
@@ -71,3 +66,44 @@ class Product_Variation_Tree():
for depth in range(depth_max - 1):
node = Product_Variation_Tree_Node.from_variation_and_node_parent(product_permutation.variations[depth + 1], node)
return Product_Variation_Tree.from_node_root(node_root)
def from_product_variation(product_variation):
node_root = Product_Variation_Tree_Node.from_variation_and_node_parent(product_variation, None)
return Product_Variation_Tree.from_node_root(node_root)
def get_name_variations(self):
node = self.node_root
name = node.variation.name_variation_type
at_leaf_node = node.is_leaf()
while not at_leaf_node:
node = node.nodes_child[0]
name += f', {node.variation.name_variation_type}'
at_leaf_node = node.is_leaf()
return name
def get_node_leaf(self):
node = self.node_root
at_leaf_node = node.is_leaf()
while not at_leaf_node:
node = node.nodes_child[0]
at_leaf_node = node.is_leaf()
return node
def add_product_variation(self, variation):
node_leaf = self.get_node_leaf()
node_new = Product_Variation_Tree_Node.from_variation_and_node_parent(variation, node_leaf)
node_leaf.add_child(node_new)
def get_product_variation_types(self):
types = []
node = self.node_root
at_leaf_node = node.is_leaf()
while not at_leaf_node:
types.append(node.variation.name_variation_type)
node = node.nodes_child[0]
at_leaf_node = node.is_leaf()
return types
def get_product_variations(self):
variations = []
node = self.node_root
at_leaf_node = node.is_leaf()
while not at_leaf_node:
variations.append(node.variation)
node = node.nodes_child[0]
at_leaf_node = node.is_leaf()
return variations