|
@@ -25,6 +25,28 @@ import logging
|
|
|
from zoneinfo import ZoneInfo
|
|
from zoneinfo import ZoneInfo
|
|
|
logger = logging.getLogger(__name__)
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
+# unique_brand_list = [
|
|
|
|
|
+# "Durham Mfg.",
|
|
|
|
|
+# "Durham MFG",
|
|
|
|
|
+# "Eagle Mfg",
|
|
|
|
|
+# "Global Industrial",
|
|
|
|
|
+# "Jamco",
|
|
|
|
|
+# "Justrite",
|
|
|
|
|
+# "SciMatCo",
|
|
|
|
|
+# "Securall Products",
|
|
|
|
|
+# ""
|
|
|
|
|
+# ]
|
|
|
|
|
+
|
|
|
|
|
+BRAND_SYMBOL_MAP = {
|
|
|
|
|
+ "Durham MFG": "®", #"®",
|
|
|
|
|
+ "Durham Mfg.": "®", #"®",
|
|
|
|
|
+ "Eagle Mfg": "™",# "™",
|
|
|
|
|
+ "Global Industrial": "™" , #"™"
|
|
|
|
|
+ "Justrite": "®" , # "®"
|
|
|
|
|
+ "Securall Products": "®" #"®", # ®
|
|
|
|
|
+ # Jamco and SciMatCo are omitted or can be "" to add nothing
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
# To login
|
|
# To login
|
|
|
def login_view(request):
|
|
def login_view(request):
|
|
|
if request.method == "POST":
|
|
if request.method == "POST":
|
|
@@ -217,10 +239,14 @@ def extract_title_or_error(product, selected_pt):
|
|
|
if attr.get("attributeDesc") == "Type":
|
|
if attr.get("attributeDesc") == "Type":
|
|
|
product_type = attr.get("attributeValue")
|
|
product_type = attr.get("attributeValue")
|
|
|
break # Stop searching once found
|
|
break # Stop searching once found
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ # 1. Get the raw brand name
|
|
|
|
|
+ raw_brand = product.get("brand", "")
|
|
|
|
|
+ # 2. Look up the symbol (default to empty string if not found)
|
|
|
|
|
+ symbol = BRAND_SYMBOL_MAP.get(raw_brand, "")
|
|
|
# 2. Data Extraction
|
|
# 2. Data Extraction
|
|
|
extracted_data = {
|
|
extracted_data = {
|
|
|
- "Brand": product.get("brand"),
|
|
|
|
|
|
|
+ "Brand": f"{raw_brand}{symbol}".strip(),
|
|
|
"Product Type": product_type
|
|
"Product Type": product_type
|
|
|
}
|
|
}
|
|
|
dimensions = {}
|
|
dimensions = {}
|
|
@@ -273,14 +299,19 @@ def extract_title_or_error(product, selected_pt):
|
|
|
print("Current Title 1 ######## ",current_title,len(current_title))
|
|
print("Current Title 1 ######## ",current_title,len(current_title))
|
|
|
logger.info(f"Current Title 1 Initial ########,{current_title},{len(current_title)}")
|
|
logger.info(f"Current Title 1 Initial ########,{current_title},{len(current_title)}")
|
|
|
# Step 1: Change "Capacity" -> "Cap."
|
|
# Step 1: Change "Capacity" -> "Cap."
|
|
|
|
|
+ # if len(current_title) > 100:
|
|
|
|
|
+ # for i, part in enumerate(final_title_parts):
|
|
|
|
|
+ # if "Capacity" in part:
|
|
|
|
|
+ # final_title_parts[i] = part.replace("Capacity", "Cap.")
|
|
|
|
|
+ # current_title = construct_string(final_title_parts)
|
|
|
|
|
+
|
|
|
if len(current_title) > 100:
|
|
if len(current_title) > 100:
|
|
|
for i, part in enumerate(final_title_parts):
|
|
for i, part in enumerate(final_title_parts):
|
|
|
if "Capacity" in part:
|
|
if "Capacity" in part:
|
|
|
final_title_parts[i] = part.replace("Capacity", "Cap.")
|
|
final_title_parts[i] = part.replace("Capacity", "Cap.")
|
|
|
- current_title = construct_string(final_title_parts)
|
|
|
|
|
-
|
|
|
|
|
- print("Current Title 2 ########",current_title,len(current_title))
|
|
|
|
|
- logger.info(f"Current Title 2 shorting capacity ########,{current_title},{len(current_title)}")
|
|
|
|
|
|
|
+ current_title = construct_string(final_title_parts)
|
|
|
|
|
+ print("Current Title 2 ########",current_title,len(current_title))
|
|
|
|
|
+ logger.info(f"Current Title 2 shorting capacity ########,{current_title},{len(current_title)}")
|
|
|
|
|
|
|
|
# Step 2: Shorten Product Type (e.g., Stainless Steel -> SS)
|
|
# Step 2: Shorten Product Type (e.g., Stainless Steel -> SS)
|
|
|
# Step B: Dynamic Product Type Acronym
|
|
# Step B: Dynamic Product Type Acronym
|
|
@@ -302,8 +333,8 @@ def extract_title_or_error(product, selected_pt):
|
|
|
# Remove white spaces from the current attribute part
|
|
# Remove white spaces from the current attribute part
|
|
|
final_title_parts[i] = final_title_parts[i].replace(" ", "")
|
|
final_title_parts[i] = final_title_parts[i].replace(" ", "")
|
|
|
current_title = construct_string(final_title_parts)
|
|
current_title = construct_string(final_title_parts)
|
|
|
- print("Current Title 4 ########",current_title,len(current_title))
|
|
|
|
|
- logger.info(f"Current Title 4 Removing space ########,{current_title},{len(current_title)}")
|
|
|
|
|
|
|
+ print("Current Title 4 ########",current_title,len(current_title))
|
|
|
|
|
+ logger.info(f"Current Title 4 Removing space ########,{current_title},{len(current_title)}")
|
|
|
return current_title,comment
|
|
return current_title,comment
|
|
|
|
|
|
|
|
def construct_dynamic_title(raw_data,selected_pt):
|
|
def construct_dynamic_title(raw_data,selected_pt):
|