From 73816eaca57a0c1efaa524b2ca5502a0f0110c83 Mon Sep 17 00:00:00 2001 From: alex Date: Sat, 8 Jun 2024 22:45:44 +0200 Subject: [PATCH] product bag label --- .../groups/shx-all-in-one-order/index.json | 70 ++++----- .../shx-fetch-google-sheet-products/script.py | 10 +- .../shx-intern-product-bag-label/index.html | 133 ++++++++++++++++++ .../shx-intern-product-bag-label/index.json | 59 ++++++++ .../shx-intern-product-bag-label/script.py | 84 +++++++++++ .../groups/shx-order-voucher-codes/script.py | 29 +--- .../groups/shx-product-label/index.json | 70 ++++----- groupTasks/groups/shx-product-label/script.py | 3 +- .../groupsData/google-sheet-products.json | 70 ++++----- .../shx-intern-product-bag-label/logo.svg | 14 ++ .../utils/__pycache__/utils.cpython-39.pyc | Bin 3053 -> 3630 bytes groupTasks/libs/utils/utils.py | 33 ++++- 12 files changed, 432 insertions(+), 143 deletions(-) create mode 100644 groupTasks/groups/shx-intern-product-bag-label/index.html create mode 100644 groupTasks/groups/shx-intern-product-bag-label/index.json create mode 100644 groupTasks/groups/shx-intern-product-bag-label/script.py create mode 100644 groupTasks/groupsData/shx-intern-product-bag-label/logo.svg diff --git a/groupTasks/groups/shx-all-in-one-order/index.json b/groupTasks/groups/shx-all-in-one-order/index.json index 35a89a8..b61b951 100644 --- a/groupTasks/groups/shx-all-in-one-order/index.json +++ b/groupTasks/groups/shx-all-in-one-order/index.json @@ -36,41 +36,41 @@ "type": "select", "displayName": "Produkttyp auswählen", "options": [ - "#32420 Gizmo die Eidechse, Farbe, Grün/Blau/Orange, (Glänzend)", - "#83650 Gizmo die Eidechse, Farbe, Gold, (Glänzend)", - "#92784 Gizmo die Eidechse, Farbe, Glitzer Grün, (Seidenmatt)", - "#36521 Charlie das Häschen, Farbe, Hellbraun, (Matt)", - "#48273 Charlie das Häschen, Farbe, Gold, (Glänzend)", - "#71936 Ruby die Schlange, Farbe, Feuerrot, (Glänzend)", - "#58324 Ruby die Schlange, Farbe, Rot/Blau, (Glänzend)", - "#78648 Ruby die Schlange, Farbe, Gold, (Glänzend)", - "#21433 Bruno der Dino, Farbe, Grün/Blau/Orange, (Glänzend)", - "#57953 Bruno der Dino, Farbe, Rot/Blau, (Glänzend)", - "#90578 Bruno der Dino, Farbe, Gold, (Glänzend)", - "#51563 Bruno der Dino, Farbe, Himmelblau, (Fluoreszierend)", - "#23564 Flamara der Drache, Farbe, Feuerrot, (Glänzend)", - "#51139 Flamara der Drache, Farbe, Himmelblau, (Fluoreszierend)", - "#77970 Flamara der Drache, Farbe, Gold, (Glänzend)", - "#43356 Flamara der Drache, Farbe, Schwarz, ", - "#32974 Finn der Sad Hamster, Stil, Standard, Weiblich", - "#60798 Finn der Sad Hamster, Stil, Schlüsselanhänger, Weiblich", - "#30563 Finn der Sad Hamster, Stil, Groß, Weiblich", - "#90586 Finn der Sad Hamster, Stil, Standard, Männlich", - "#99560 Finn der Sad Hamster, Stil, Schlüsselanhänger, Männlich", - "#47364 Finn der Sad Hamster, Stil, Groß, Männlich", - "#93047 Mia das Kätzchen, Farbe, Grau, ", - "#86423 Mia das Kätzchen, Farbe, Weiß, ", - "#X38764 Mia das Kätzchen, Farbe, Weiß, (Schlüsselanhänger)", - "#56083 Hoppel das Häschen, Farbe, Grau, ", - "#78693 Elias der Corgi, Farbe, Braun/Weiß, ", - "#37335 Axel der Axolotl, Farbe, Pink, ", - "#26822 Dilo der Delfin, Farbe, Blau ➔ Weiß, ", - "#51665 Sunny das Einhorn, Farbe, Weiß, ", - "#35717 Stella der Phönix, Farbe, Sonderanfertigung, Rosa/Weiß", - "#26843 Stella der Phönix, Farbe, Verlauf Lila/Pink, ", - "#74943 Brain der Fuchs, Stil, Standard, ", - "#78071 Weißer Hund, Stil, Weiß, ", - "#92734 Amigo der Capybara, Farbe, Braun, " + "#32420 Gizmo die Eidechse, FARBE, Grün/Blau/Orange, (Glänzend)", + "#83650 Gizmo die Eidechse, FARBE, Gold, (Glänzend)", + "#92784 Gizmo die Eidechse, FARBE, Glitzer Grün, (Seidenmatt)", + "#36521 Charlie das Häschen, FARBE, Hellbraun, (Matt)", + "#48273 Charlie das Häschen, FARBE, Gold, (Glänzend)", + "#71936 Ruby die Schlange, FARBE, Feuerrot, (Glänzend)", + "#58324 Ruby die Schlange, FARBE, Rot/Blau, (Glänzend)", + "#78648 Ruby die Schlange, FARBE, Gold, (Glänzend)", + "#21433 Bruno der Dino, FARBE, Grün/Blau/Orange, (Glänzend)", + "#57953 Bruno der Dino, FARBE, Rot/Blau, (Glänzend)", + "#90578 Bruno der Dino, FARBE, Gold, (Glänzend)", + "#51563 Bruno der Dino, FARBE, Himmelblau, (Fluoreszierend)", + "#23564 Flamara der Drache, FARBE, Feuerrot, (Glänzend)", + "#51139 Flamara der Drache, FARBE, Himmelblau, (Fluoreszierend)", + "#77970 Flamara der Drache, FARBE, Gold, (Glänzend)", + "#43356 Flamara der Drache, FARBE, Schwarz, ", + "#32974 Finn der Sad Hamster, STIL, Standard, Weiblich", + "#60798 Finn der Sad Hamster, STIL, Schlüsselanhänger, Weiblich", + "#30563 Finn der Sad Hamster, STIL, Groß, Weiblich", + "#90586 Finn der Sad Hamster, STIL, Standard, Männlich", + "#99560 Finn der Sad Hamster, STIL, Schlüsselanhänger, Männlich", + "#47364 Finn der Sad Hamster, STIL, Groß, Männlich", + "#93047 Mia das Kätzchen, FARBE, Grau, ", + "#86423 Mia das Kätzchen, FARBE, Weiß, ", + "#X38764 Mia das Kätzchen, FARBE, Weiß, (Schlüsselanhänger)", + "#56083 Hoppel das Häschen, FARBE, Grau, ", + "#78693 Elias der Corgi, FARBE, Braun/Weiß, ", + "#37335 Axel der Axolotl, FARBE, Pink, ", + "#26822 Dilo der Delfin, FARBE, Blau ➔ Weiß, ", + "#51665 Sunny das Einhorn, FARBE, Weiß, ", + "#35717 Stella der Phönix, FARBE, Sonderanfertigung, Rosa/Weiß", + "#26843 Stella der Phönix, FARBE, Verlauf Lila/Pink, ", + "#74943 Brain der Fuchs, STIL, Standard, ", + "#78071 Weißer Hund, STIL, Weiß, ", + "#92734 Amigo der Capybara, FARBE, Braun, " ] } ] diff --git a/groupTasks/groups/shx-fetch-google-sheet-products/script.py b/groupTasks/groups/shx-fetch-google-sheet-products/script.py index 2c09f0d..4a3a8f7 100644 --- a/groupTasks/groups/shx-fetch-google-sheet-products/script.py +++ b/groupTasks/groups/shx-fetch-google-sheet-products/script.py @@ -105,7 +105,7 @@ def google_sheets_products(): products.append({ "id": row[rowIndexProductId], "name": add_underscore_at_position(row[1], int(row[rowIndexNameSplitAtPosition])), - "product_variant": row[rowIndexProductVariant], + "product_variant": row[rowIndexProductVariant].upper(), "product_characteristic_line_1": row[rowIndexProductCharacteristicLine1], "product_characteristic_line_2": row[rowIndexProductCharacteristicLine2], }) @@ -116,10 +116,10 @@ def google_sheets_products(): with open('../../groupsData/google-sheet-products.json', 'w', encoding='utf-8') as json_file: json.dump(products_dict, json_file, ensure_ascii=False, indent=2) - update_grouptask_products_list_options( - "../../groups/shx-product-label/index.json", products) - update_grouptask_products_list_options( - "../../groups/shx-all-in-one-order/index.json", products) + for file_path in ["../../groups/shx-product-label/index.json", + "../../groups/shx-all-in-one-order/index.json", + "../../groups/shx-intern-product-bag-label/index.json"]: + update_grouptask_products_list_options(file_path, products) print("Finished. Do not forget to reload the group configuration by clicking on the 'Reload' button above the table on the right side.") diff --git a/groupTasks/groups/shx-intern-product-bag-label/index.html b/groupTasks/groups/shx-intern-product-bag-label/index.html new file mode 100644 index 0000000..cf677d0 --- /dev/null +++ b/groupTasks/groups/shx-intern-product-bag-label/index.html @@ -0,0 +1,133 @@ + + + + + + Intern Product Bag Label + + + +
+
+
+
+

+ {{PRODUCT_ID}} +

+ +
+ +

+ {{PRODUCT_NAME}} +

+
+

+ {{PRODUCT_VARIANT}} +

+

+ {{PRODUCT_CHARACTERISTIC_LINE_1}} +

+

+ {{PRODUCT_CHARACTERISTIC_LINE_2}} +

+
+
+ +
+ + +
+

+ {{DATE}} +

+
+ +
+
+
+
+ + diff --git a/groupTasks/groups/shx-intern-product-bag-label/index.json b/groupTasks/groups/shx-intern-product-bag-label/index.json new file mode 100644 index 0000000..e2249d6 --- /dev/null +++ b/groupTasks/groups/shx-intern-product-bag-label/index.json @@ -0,0 +1,59 @@ +{ + "category": "Shinnex", + "name": "Internes Etikett für Produktbeutel", + "globalInputs": [], + "tasks": [ + { + "name": "Internes Etikett für Produktbeutel erstellen", + "onFinish": "next", + "undoPossible": false, + "repeatPossible": true, + "scriptPath": "script.py", + "parameters": [ + { + "parameterName": "product_type_id", + "type": "select", + "displayName": "Produkttyp auswählen", + "global": false, + "options": [ + "#32420 Gizmo die Eidechse, FARBE, Grün/Blau/Orange, (Glänzend)", + "#83650 Gizmo die Eidechse, FARBE, Gold, (Glänzend)", + "#92784 Gizmo die Eidechse, FARBE, Glitzer Grün, (Seidenmatt)", + "#36521 Charlie das Häschen, FARBE, Hellbraun, (Matt)", + "#48273 Charlie das Häschen, FARBE, Gold, (Glänzend)", + "#71936 Ruby die Schlange, FARBE, Feuerrot, (Glänzend)", + "#58324 Ruby die Schlange, FARBE, Rot/Blau, (Glänzend)", + "#78648 Ruby die Schlange, FARBE, Gold, (Glänzend)", + "#21433 Bruno der Dino, FARBE, Grün/Blau/Orange, (Glänzend)", + "#57953 Bruno der Dino, FARBE, Rot/Blau, (Glänzend)", + "#90578 Bruno der Dino, FARBE, Gold, (Glänzend)", + "#51563 Bruno der Dino, FARBE, Himmelblau, (Fluoreszierend)", + "#23564 Flamara der Drache, FARBE, Feuerrot, (Glänzend)", + "#51139 Flamara der Drache, FARBE, Himmelblau, (Fluoreszierend)", + "#77970 Flamara der Drache, FARBE, Gold, (Glänzend)", + "#43356 Flamara der Drache, FARBE, Schwarz, ", + "#32974 Finn der Sad Hamster, STIL, Standard, Weiblich", + "#60798 Finn der Sad Hamster, STIL, Schlüsselanhänger, Weiblich", + "#30563 Finn der Sad Hamster, STIL, Groß, Weiblich", + "#90586 Finn der Sad Hamster, STIL, Standard, Männlich", + "#99560 Finn der Sad Hamster, STIL, Schlüsselanhänger, Männlich", + "#47364 Finn der Sad Hamster, STIL, Groß, Männlich", + "#93047 Mia das Kätzchen, FARBE, Grau, ", + "#86423 Mia das Kätzchen, FARBE, Weiß, ", + "#X38764 Mia das Kätzchen, FARBE, Weiß, (Schlüsselanhänger)", + "#56083 Hoppel das Häschen, FARBE, Grau, ", + "#78693 Elias der Corgi, FARBE, Braun/Weiß, ", + "#37335 Axel der Axolotl, FARBE, Pink, ", + "#26822 Dilo der Delfin, FARBE, Blau ➔ Weiß, ", + "#51665 Sunny das Einhorn, FARBE, Weiß, ", + "#35717 Stella der Phönix, FARBE, Sonderanfertigung, Rosa/Weiß", + "#26843 Stella der Phönix, FARBE, Verlauf Lila/Pink, ", + "#74943 Brain der Fuchs, STIL, Standard, ", + "#78071 Weißer Hund, STIL, Weiß, ", + "#92734 Amigo der Capybara, FARBE, Braun, " + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/groupTasks/groups/shx-intern-product-bag-label/script.py b/groupTasks/groups/shx-intern-product-bag-label/script.py new file mode 100644 index 0000000..2fc066f --- /dev/null +++ b/groupTasks/groups/shx-intern-product-bag-label/script.py @@ -0,0 +1,84 @@ +import json +import subprocess +import sys +import os +from datetime import datetime + +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) + +from libs.utils import utils + +json_object = json.loads(sys.argv[1]) +product_type_id = json_object["product_type_id"] + +if product_type_id is None: + print("Missing required parameters") + sys.exit(1) + +product_type_id = product_type_id["value"] + +def createHighDpiPng(sourceHtml, outputPng): + # Calculate scaled dimensions + scale_factor = 1 + width = int(1020 * scale_factor) # Original width in pixels multiplied by the scale factor + height = int(1020 * scale_factor) # Original height in pixels multiplied by the scale factor + + command = [ + "google-chrome-stable", + "--headless", + "--no-sandbox", + "--disable-gpu", + "--screenshot=" + outputPng, + "--window-size={},{}".format(width, height), # Set window size to scaled dimensions + "--force-device-scale-factor={}".format(scale_factor), # Set device scale factor + sourceHtml, + ] + + process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + _, stderr = process.communicate() + + if process.returncode != 0: + print("Error creating PNG") + print(stderr.decode()) # Decoding the stderr for better readability + sys.exit(1) + +if __name__ == "__main__": + utils.move_files_back_from_old_files() + + # replace placeholders in index.html + p_type_id = utils.extract_product_id(product_type_id) + + data = { + "shx_id": p_type_id + } + + utils.create_qrcode(json.dumps(data), "./qrcode.png", "#fff") + + with open('../../groupsData/google-sheet-products.json', 'r', encoding='utf-8') as json_file: + data = json.load(json_file) + + for product in data["products"]: + if product["id"] == p_type_id: + with open("index.html", "r") as file: + indexhtml = file.read() + + indexhtml = indexhtml.replace("{{PRODUCT_ID}}", "#" + product["id"]) + indexhtml = indexhtml.replace("{{PRODUCT_NAME}}", product["name"].replace("_", " ")) + indexhtml = indexhtml.replace("{{PRODUCT_VARIANT}}", product["product_variant"]) + indexhtml = indexhtml.replace("{{PRODUCT_CHARACTERISTIC_LINE_1}}", product["product_characteristic_line_1"]) + indexhtml = indexhtml.replace("{{PRODUCT_CHARACTERISTIC_LINE_2}}", product["product_characteristic_line_2"]) + + now = datetime.now() + formatted_date = now.strftime("%d.%m.%Y") + + indexhtml = indexhtml.replace("{{DATE}}", formatted_date) + + with open("index.html", "w") as file: + file.write(indexhtml) + + break + + + createHighDpiPng("index.html", "product-bag-label.png") + + utils.clear_workspace(["index.html", "qrcode.png"]) \ No newline at end of file diff --git a/groupTasks/groups/shx-order-voucher-codes/script.py b/groupTasks/groups/shx-order-voucher-codes/script.py index 7b3e999..b606015 100644 --- a/groupTasks/groups/shx-order-voucher-codes/script.py +++ b/groupTasks/groups/shx-order-voucher-codes/script.py @@ -140,29 +140,6 @@ def CreateCrmActivityLink(customerId, thirdVoucher): req("10 € Gutschein", f"https://docs.google.com/forms/d/e/1FAIpQLSd2GXFbidzazuQnh_Lf2mgeA1npuwHkWjsdmjrxDmSkDQTfew/viewform?entry.347359844={orderId}") -def create_qrcode(type, id): - data = f"{QR_CODE_URL}{id}" - - # Generate QR code - qr = qrcode.QRCode( - version=1, - error_correction=qrcode.constants.ERROR_CORRECT_L, - box_size=10, - border=0, - ) - qr.add_data(data) - qr.make(fit=True) - - # Create an image from the QR Code instance - img = qr.make_image(fill_color="black", back_color="#fdf8ef") - - # Save image to a file - img.save(f"./{type}.png") - - # Display the generated QR code image - #img.show() - - def GetCustomerActivityLinks(customerId): response = requests.get( url=f"{ENDPOINT_URL}/customer/view/{customerId}", @@ -203,9 +180,9 @@ def GetCustomerActivityLinks(customerId): print("Gift links not found") sys.exit(1) - create_qrcode("5euro", linkGift5["Id"]) - create_qrcode("10euro", linkGift10["Id"]) - create_qrcode("10percent", linkGift10Percent["Id"]) + utils.create_qrcode(f"{QR_CODE_URL}{linkGift5['Id']}", "./5euro.png", "#fdf8ef") + utils.create_qrcode(f"{QR_CODE_URL}{linkGift10['Id']}", "./10euro.png", "#fdf8ef") + utils.create_qrcode(f"{QR_CODE_URL}{linkGift10Percent['Id']}", "./10percent.png", "#fdf8ef") def ReplaceHtmlVariables(): diff --git a/groupTasks/groups/shx-product-label/index.json b/groupTasks/groups/shx-product-label/index.json index 3a589e3..fe67c1b 100644 --- a/groupTasks/groups/shx-product-label/index.json +++ b/groupTasks/groups/shx-product-label/index.json @@ -20,41 +20,41 @@ "type": "select", "displayName": "Produkttyp auswählen", "options": [ - "#32420 Gizmo die Eidechse, Farbe, Grün/Blau/Orange, (Glänzend)", - "#83650 Gizmo die Eidechse, Farbe, Gold, (Glänzend)", - "#92784 Gizmo die Eidechse, Farbe, Glitzer Grün, (Seidenmatt)", - "#36521 Charlie das Häschen, Farbe, Hellbraun, (Matt)", - "#48273 Charlie das Häschen, Farbe, Gold, (Glänzend)", - "#71936 Ruby die Schlange, Farbe, Feuerrot, (Glänzend)", - "#58324 Ruby die Schlange, Farbe, Rot/Blau, (Glänzend)", - "#78648 Ruby die Schlange, Farbe, Gold, (Glänzend)", - "#21433 Bruno der Dino, Farbe, Grün/Blau/Orange, (Glänzend)", - "#57953 Bruno der Dino, Farbe, Rot/Blau, (Glänzend)", - "#90578 Bruno der Dino, Farbe, Gold, (Glänzend)", - "#51563 Bruno der Dino, Farbe, Himmelblau, (Fluoreszierend)", - "#23564 Flamara der Drache, Farbe, Feuerrot, (Glänzend)", - "#51139 Flamara der Drache, Farbe, Himmelblau, (Fluoreszierend)", - "#77970 Flamara der Drache, Farbe, Gold, (Glänzend)", - "#43356 Flamara der Drache, Farbe, Schwarz, ", - "#32974 Finn der Sad Hamster, Stil, Standard, Weiblich", - "#60798 Finn der Sad Hamster, Stil, Schlüsselanhänger, Weiblich", - "#30563 Finn der Sad Hamster, Stil, Groß, Weiblich", - "#90586 Finn der Sad Hamster, Stil, Standard, Männlich", - "#99560 Finn der Sad Hamster, Stil, Schlüsselanhänger, Männlich", - "#47364 Finn der Sad Hamster, Stil, Groß, Männlich", - "#93047 Mia das Kätzchen, Farbe, Grau, ", - "#86423 Mia das Kätzchen, Farbe, Weiß, ", - "#X38764 Mia das Kätzchen, Farbe, Weiß, (Schlüsselanhänger)", - "#56083 Hoppel das Häschen, Farbe, Grau, ", - "#78693 Elias der Corgi, Farbe, Braun/Weiß, ", - "#37335 Axel der Axolotl, Farbe, Pink, ", - "#26822 Dilo der Delfin, Farbe, Blau ➔ Weiß, ", - "#51665 Sunny das Einhorn, Farbe, Weiß, ", - "#35717 Stella der Phönix, Farbe, Sonderanfertigung, Rosa/Weiß", - "#26843 Stella der Phönix, Farbe, Verlauf Lila/Pink, ", - "#74943 Brain der Fuchs, Stil, Standard, ", - "#78071 Weißer Hund, Stil, Weiß, ", - "#92734 Amigo der Capybara, Farbe, Braun, " + "#32420 Gizmo die Eidechse, FARBE, Grün/Blau/Orange, (Glänzend)", + "#83650 Gizmo die Eidechse, FARBE, Gold, (Glänzend)", + "#92784 Gizmo die Eidechse, FARBE, Glitzer Grün, (Seidenmatt)", + "#36521 Charlie das Häschen, FARBE, Hellbraun, (Matt)", + "#48273 Charlie das Häschen, FARBE, Gold, (Glänzend)", + "#71936 Ruby die Schlange, FARBE, Feuerrot, (Glänzend)", + "#58324 Ruby die Schlange, FARBE, Rot/Blau, (Glänzend)", + "#78648 Ruby die Schlange, FARBE, Gold, (Glänzend)", + "#21433 Bruno der Dino, FARBE, Grün/Blau/Orange, (Glänzend)", + "#57953 Bruno der Dino, FARBE, Rot/Blau, (Glänzend)", + "#90578 Bruno der Dino, FARBE, Gold, (Glänzend)", + "#51563 Bruno der Dino, FARBE, Himmelblau, (Fluoreszierend)", + "#23564 Flamara der Drache, FARBE, Feuerrot, (Glänzend)", + "#51139 Flamara der Drache, FARBE, Himmelblau, (Fluoreszierend)", + "#77970 Flamara der Drache, FARBE, Gold, (Glänzend)", + "#43356 Flamara der Drache, FARBE, Schwarz, ", + "#32974 Finn der Sad Hamster, STIL, Standard, Weiblich", + "#60798 Finn der Sad Hamster, STIL, Schlüsselanhänger, Weiblich", + "#30563 Finn der Sad Hamster, STIL, Groß, Weiblich", + "#90586 Finn der Sad Hamster, STIL, Standard, Männlich", + "#99560 Finn der Sad Hamster, STIL, Schlüsselanhänger, Männlich", + "#47364 Finn der Sad Hamster, STIL, Groß, Männlich", + "#93047 Mia das Kätzchen, FARBE, Grau, ", + "#86423 Mia das Kätzchen, FARBE, Weiß, ", + "#X38764 Mia das Kätzchen, FARBE, Weiß, (Schlüsselanhänger)", + "#56083 Hoppel das Häschen, FARBE, Grau, ", + "#78693 Elias der Corgi, FARBE, Braun/Weiß, ", + "#37335 Axel der Axolotl, FARBE, Pink, ", + "#26822 Dilo der Delfin, FARBE, Blau ➔ Weiß, ", + "#51665 Sunny das Einhorn, FARBE, Weiß, ", + "#35717 Stella der Phönix, FARBE, Sonderanfertigung, Rosa/Weiß", + "#26843 Stella der Phönix, FARBE, Verlauf Lila/Pink, ", + "#74943 Brain der Fuchs, STIL, Standard, ", + "#78071 Weißer Hund, STIL, Weiß, ", + "#92734 Amigo der Capybara, FARBE, Braun, " ], "global": false } diff --git a/groupTasks/groups/shx-product-label/script.py b/groupTasks/groups/shx-product-label/script.py index 2fb33a3..9e90eaf 100644 --- a/groupTasks/groups/shx-product-label/script.py +++ b/groupTasks/groups/shx-product-label/script.py @@ -42,8 +42,7 @@ if __name__ == "__main__": utils.move_files_back_from_old_files() # replace placeholders in index.js - - p_type_id = product_type_id.split(" ")[0].split("#")[1] + p_type_id = utils.extract_product_id(product_type_id) print(f"Creating product label for product type #{p_type_id}") diff --git a/groupTasks/groupsData/google-sheet-products.json b/groupTasks/groupsData/google-sheet-products.json index a9a0be2..5dd8c2f 100644 --- a/groupTasks/groupsData/google-sheet-products.json +++ b/groupTasks/groupsData/google-sheet-products.json @@ -3,245 +3,245 @@ { "id": "32420", "name": "Gizmo_die Eidechse", - "product_variant": "Farbe", + "product_variant": "FARBE", "product_characteristic_line_1": "Grün/Blau/Orange", "product_characteristic_line_2": "(Glänzend)" }, { "id": "83650", "name": "Gizmo_die Eidechse", - "product_variant": "Farbe", + "product_variant": "FARBE", "product_characteristic_line_1": "Gold", "product_characteristic_line_2": "(Glänzend)" }, { "id": "92784", "name": "Gizmo_die Eidechse", - "product_variant": "Farbe", + "product_variant": "FARBE", "product_characteristic_line_1": "Glitzer Grün", "product_characteristic_line_2": "(Seidenmatt)" }, { "id": "36521", "name": "Charlie_das Häschen", - "product_variant": "Farbe", + "product_variant": "FARBE", "product_characteristic_line_1": "Hellbraun", "product_characteristic_line_2": "(Matt)" }, { "id": "48273", "name": "Charlie_das Häschen", - "product_variant": "Farbe", + "product_variant": "FARBE", "product_characteristic_line_1": "Gold", "product_characteristic_line_2": "(Glänzend)" }, { "id": "71936", "name": "Ruby_die Schlange", - "product_variant": "Farbe", + "product_variant": "FARBE", "product_characteristic_line_1": "Feuerrot", "product_characteristic_line_2": "(Glänzend)" }, { "id": "58324", "name": "Ruby_die Schlange", - "product_variant": "Farbe", + "product_variant": "FARBE", "product_characteristic_line_1": "Rot/Blau", "product_characteristic_line_2": "(Glänzend)" }, { "id": "78648", "name": "Ruby_die Schlange", - "product_variant": "Farbe", + "product_variant": "FARBE", "product_characteristic_line_1": "Gold", "product_characteristic_line_2": "(Glänzend)" }, { "id": "21433", "name": "Bruno_der Dino", - "product_variant": "Farbe", + "product_variant": "FARBE", "product_characteristic_line_1": "Grün/Blau/Orange", "product_characteristic_line_2": "(Glänzend)" }, { "id": "57953", "name": "Bruno_der Dino", - "product_variant": "Farbe", + "product_variant": "FARBE", "product_characteristic_line_1": "Rot/Blau", "product_characteristic_line_2": "(Glänzend)" }, { "id": "90578", "name": "Bruno_der Dino", - "product_variant": "Farbe", + "product_variant": "FARBE", "product_characteristic_line_1": "Gold", "product_characteristic_line_2": "(Glänzend)" }, { "id": "51563", "name": "Bruno_der Dino", - "product_variant": "Farbe", + "product_variant": "FARBE", "product_characteristic_line_1": "Himmelblau", "product_characteristic_line_2": "(Fluoreszierend)" }, { "id": "23564", "name": "Flamara_der Drache", - "product_variant": "Farbe", + "product_variant": "FARBE", "product_characteristic_line_1": "Feuerrot", "product_characteristic_line_2": "(Glänzend)" }, { "id": "51139", "name": "Flamara_der Drache", - "product_variant": "Farbe", + "product_variant": "FARBE", "product_characteristic_line_1": "Himmelblau", "product_characteristic_line_2": "(Fluoreszierend)" }, { "id": "77970", "name": "Flamara_der Drache", - "product_variant": "Farbe", + "product_variant": "FARBE", "product_characteristic_line_1": "Gold", "product_characteristic_line_2": "(Glänzend)" }, { "id": "43356", "name": "Flamara_der Drache", - "product_variant": "Farbe", + "product_variant": "FARBE", "product_characteristic_line_1": "Schwarz", "product_characteristic_line_2": "" }, { "id": "32974", "name": "Finn der_Sad Hamster", - "product_variant": "Stil", + "product_variant": "STIL", "product_characteristic_line_1": "Standard", "product_characteristic_line_2": "Weiblich" }, { "id": "60798", "name": "Finn der_Sad Hamster", - "product_variant": "Stil", + "product_variant": "STIL", "product_characteristic_line_1": "Schlüsselanhänger", "product_characteristic_line_2": "Weiblich" }, { "id": "30563", "name": "Finn der_Sad Hamster", - "product_variant": "Stil", + "product_variant": "STIL", "product_characteristic_line_1": "Groß", "product_characteristic_line_2": "Weiblich" }, { "id": "90586", "name": "Finn der_Sad Hamster", - "product_variant": "Stil", + "product_variant": "STIL", "product_characteristic_line_1": "Standard", "product_characteristic_line_2": "Männlich" }, { "id": "99560", "name": "Finn der_Sad Hamster", - "product_variant": "Stil", + "product_variant": "STIL", "product_characteristic_line_1": "Schlüsselanhänger", "product_characteristic_line_2": "Männlich" }, { "id": "47364", "name": "Finn der_Sad Hamster", - "product_variant": "Stil", + "product_variant": "STIL", "product_characteristic_line_1": "Groß", "product_characteristic_line_2": "Männlich" }, { "id": "93047", "name": "Mia_das Kätzchen", - "product_variant": "Farbe", + "product_variant": "FARBE", "product_characteristic_line_1": "Grau", "product_characteristic_line_2": "" }, { "id": "86423", "name": "Mia_das Kätzchen", - "product_variant": "Farbe", + "product_variant": "FARBE", "product_characteristic_line_1": "Weiß", "product_characteristic_line_2": "" }, { "id": "X38764", "name": "Mia_das Kätzchen", - "product_variant": "Farbe", + "product_variant": "FARBE", "product_characteristic_line_1": "Weiß", "product_characteristic_line_2": "(Schlüsselanhänger)" }, { "id": "56083", "name": "Hoppel_das Häschen", - "product_variant": "Farbe", + "product_variant": "FARBE", "product_characteristic_line_1": "Grau", "product_characteristic_line_2": "" }, { "id": "78693", "name": "Elias_der Corgi", - "product_variant": "Farbe", + "product_variant": "FARBE", "product_characteristic_line_1": "Braun/Weiß", "product_characteristic_line_2": "" }, { "id": "37335", "name": "Axel_der Axolotl", - "product_variant": "Farbe", + "product_variant": "FARBE", "product_characteristic_line_1": "Pink", "product_characteristic_line_2": "" }, { "id": "26822", "name": "Dilo_der Delfin", - "product_variant": "Farbe", + "product_variant": "FARBE", "product_characteristic_line_1": "Blau ➔ Weiß", "product_characteristic_line_2": "" }, { "id": "51665", "name": "Sunny_das Einhorn", - "product_variant": "Farbe", + "product_variant": "FARBE", "product_characteristic_line_1": "Weiß", "product_characteristic_line_2": "" }, { "id": "35717", "name": "Stella_der Phönix", - "product_variant": "Farbe", + "product_variant": "FARBE", "product_characteristic_line_1": "Sonderanfertigung", "product_characteristic_line_2": "Rosa/Weiß" }, { "id": "26843", "name": "Stella_der Phönix", - "product_variant": "Farbe", + "product_variant": "FARBE", "product_characteristic_line_1": "Verlauf Lila/Pink", "product_characteristic_line_2": "" }, { "id": "74943", "name": "Brain_der Fuchs", - "product_variant": "Stil", + "product_variant": "STIL", "product_characteristic_line_1": "Standard", "product_characteristic_line_2": "" }, { "id": "78071", "name": "Weißer_Hund", - "product_variant": "Stil", + "product_variant": "STIL", "product_characteristic_line_1": "Weiß", "product_characteristic_line_2": "" }, { "id": "92734", "name": "Amigo_der Capybara", - "product_variant": "Farbe", + "product_variant": "FARBE", "product_characteristic_line_1": "Braun", "product_characteristic_line_2": "" } diff --git a/groupTasks/groupsData/shx-intern-product-bag-label/logo.svg b/groupTasks/groupsData/shx-intern-product-bag-label/logo.svg new file mode 100644 index 0000000..7c07479 --- /dev/null +++ b/groupTasks/groupsData/shx-intern-product-bag-label/logo.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/groupTasks/libs/utils/__pycache__/utils.cpython-39.pyc b/groupTasks/libs/utils/__pycache__/utils.cpython-39.pyc index a8b5f5ff8202e0ff32b275327903de17b0ed972b..f36f72e8ada4988d1ce18dde054d7515dbb9d165 100644 GIT binary patch delta 1031 zcma)4&r20i6u#%qouBWAW~C_-Mj;GEEh0lmio{lu^fH1e7{)nc&GYH#ovAcN-lDcb zGVMZm?kf-%1+}Uct@;Dr9}on!7irPC?-^99?&W^p;ofuRoNvzgG4Oi08dNF{qqYAA z=RfprR)- zxPpCnn7E2?letHBo}UD;i?^@`eY-pS5Qo9yqu7J|(;7LUwv_`17e)}j9zeKs9d zN}&wB;BW^laEc4|*|9JGo$;V9pq$gimOWIwvnNV-Z?mOKf@RLy=UvUY49z<#)$u=4 zbrW*#Xckmy_i=@Cgj_;Ueg{k08l6cx=`jLQNR8MA$vIjZd|l7= zmYI_-V5rpC*Ec*N&R{b=79C^lEA~BM) zE_m8}oO$|OBM6%dF87@IxY3}XMk3qJTo5jFZP#iWD>6)wVsF$Y729F5lxD$FmU=x? zwc1S0pPZ@HrY2|oY0nA}eGIa|6N|w@n A!vFvP delta 398 zcmZ9Gu}cFn6o>P2xl1nBi&vFajte20W4M5o;jG&l3@gj#Q`zl7z%${8d z(6VpdLi9<}gmob0JvM;utUdMP8nQO)vD8CB(PrYHdj`M~k-F#%=tgt9B^Tk&UdSc* z$R1?};&s~8tx{u9fCw}Qu0iFrYknhop}~JqDHr{OK&l;5i5}Q#IqBq%dw(UsU3SzG zEYT;!OzKr=?$e^~%pcFMk8|xPFjV6_@5fboRxj8zjO{~MgTM~liA!VR66K0M_g#+i Kl~l3P#PSz||4)Db diff --git a/groupTasks/libs/utils/utils.py b/groupTasks/libs/utils/utils.py index 902d0ba..3effe58 100644 --- a/groupTasks/libs/utils/utils.py +++ b/groupTasks/libs/utils/utils.py @@ -3,6 +3,7 @@ import PyPDF2 import os import shutil import sys +import qrcode def clear_workspace(files): @@ -70,12 +71,10 @@ def execute_python_file(file_path): if not os.path.exists(file_path): print(f"The file {file_path} does not exist.") sys.exit(1) - return if not file_path.endswith('.py'): print("The specified file is not a Python file.") sys.exit(1) - return try: #base_dir = os.path.dirname(os.path.abspath(file_path)) @@ -93,12 +92,10 @@ def copy_files(source_folder, destination_folder): if not os.path.exists(source_folder): print(f"The source folder {source_folder} does not exist.") sys.exit(1) - return if not os.path.exists(destination_folder): print(f"The destination folder {destination_folder} does not exist.") sys.exit(1) - return try: # List all files in the source folder @@ -112,4 +109,30 @@ def copy_files(source_folder, destination_folder): except Exception as e: print(f"An error occurred while copying files: {e}") - sys.exit(1) \ No newline at end of file + sys.exit(1) + + +# this will extract the product id from the string which is provided as arg from the select dropdown where the user can select a product +def extract_product_id(product_type_id): + return product_type_id.split(" ")[0].split("#")[1] + + +def create_qrcode(qr_code_url, save_path, back_color): + data = qr_code_url + + # Generate QR code + qr = qrcode.QRCode( + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_L, + box_size=10, + border=0, + ) + qr.add_data(data) + qr.make(fit=True) + + # Create an image from the QR Code instance + img = qr.make_image(fill_color="black", back_color=back_color) + + # Save image to a file + # like ./test.png + img.save(save_path) \ No newline at end of file