fix of the json upload format
This commit is contained in:
+24
-1
@@ -11883,6 +11883,20 @@ def upload_csv_batch():
|
||||
|
||||
username = session.get('username', 'System')
|
||||
|
||||
def generate_unique_batch_code(base_code, position):
|
||||
"""
|
||||
Generiert einen eindeutigen Code für einen Artikel innerhalb einer Serie (Batch).
|
||||
|
||||
:param base_code: Der Code des ersten Artikels in der Gruppe (String oder None).
|
||||
:param position: Die Position des aktuellen Artikels in der Gruppe (Integer).
|
||||
:return: Ein eindeutiger Code als String.
|
||||
"""
|
||||
if base_code:
|
||||
return f"{base_code}-{position}"
|
||||
else:
|
||||
random_prefix = str(uuid.uuid4())[:6].upper()
|
||||
return f"BATCH-{random_prefix}-{position}"
|
||||
|
||||
fs = get_gridfs()
|
||||
upload_session_id = str(uuid.uuid4())[:8]
|
||||
app.logger.info(f"Starting CSV Batch upload session {upload_session_id} - User: {username}")
|
||||
@@ -12029,6 +12043,15 @@ def upload_csv_batch():
|
||||
except (ValueError, SyntaxError):
|
||||
pass
|
||||
|
||||
# --- NEU: BILDER-REFERENZEN PRO ARTIKEL DEDUPLIZIEREN ---
|
||||
# Falls die CSV z.B. ['bild1.jpg', 'bild1.jpg'] enthält, filtern wir das hier heraus,
|
||||
# damit die GridFS-Datei nicht doppelt als Referenz gespeichert wird.
|
||||
unique_image_filenames = []
|
||||
for img in item_image_filenames:
|
||||
if img not in unique_image_filenames:
|
||||
unique_image_filenames.append(img)
|
||||
# --------------------------------------------------------
|
||||
|
||||
def parse_filter_col(col_data):
|
||||
try:
|
||||
res = ast.literal_eval(str(col_data))
|
||||
@@ -12056,7 +12079,7 @@ def upload_csv_batch():
|
||||
str(row['Name']), # 1. Name
|
||||
ort_val, # 2. Ort
|
||||
str(row['Beschreibung']), # 3. Beschreibung
|
||||
item_image_filenames, # 4. Image Filenames (GridFS)
|
||||
unique_image_filenames, # 4. Image Filenames (GridFS) -> HIER GEÄNDERT
|
||||
filter_upload, # 5. Filter 1
|
||||
filter_upload2, # 6. Filter 2
|
||||
filter_upload3, # 7. Filter 3
|
||||
|
||||
Reference in New Issue
Block a user