Quellcode durchsuchen

changes for the html code

VISHAL BHANUSHALI vor 4 Wochen
Ursprung
Commit
9aca015e93
1 geänderte Dateien mit 39 neuen und 8 gelöschten Zeilen
  1. 39 8
      title_creator_app/views.py

+ 39 - 8
title_creator_app/views.py

@@ -25,6 +25,28 @@ import logging
 from zoneinfo import ZoneInfo
 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
 def login_view(request):
     if request.method == "POST":
@@ -217,10 +239,14 @@ def extract_title_or_error(product, selected_pt):
             if attr.get("attributeDesc") == "Type":
                 product_type = attr.get("attributeValue")
                 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
     extracted_data = {
-        "Brand": product.get("brand"),
+        "Brand": f"{raw_brand}{symbol}".strip(),
         "Product Type": product_type
     }
     dimensions = {}
@@ -273,14 +299,19 @@ def extract_title_or_error(product, selected_pt):
     print("Current Title 1 ######## ",current_title,len(current_title))
     logger.info(f"Current Title 1 Initial ########,{current_title},{len(current_title)}")
     # 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:
         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)
-
-    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 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
             final_title_parts[i] = final_title_parts[i].replace(" ", "")
             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
 
 def construct_dynamic_title(raw_data,selected_pt):