Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 91ddc6e864 | |||
| 88f124c991 | |||
| 33c65f21b6 | |||
| fd242a6a0a |
+1
-7
@@ -417,8 +417,6 @@ def _is_csrf_exempt_request():
|
||||
|
||||
@app.before_request
|
||||
def _enforce_csrf_protection():
|
||||
if request.endpoint == 'upload_csv_batch':
|
||||
return None
|
||||
if _is_csrf_exempt_request():
|
||||
_get_csrf_token()
|
||||
return None
|
||||
@@ -11865,12 +11863,8 @@ def batch_upload_page():
|
||||
return render_template('upload_batch.html')
|
||||
|
||||
|
||||
from flask_wtf.csrf import CSRFProtect
|
||||
csrf = CSRFProtect(app)
|
||||
|
||||
|
||||
@app.route('/upload_csv_batch', methods=['POST'])
|
||||
@csrf.exempt
|
||||
def upload_csv_batch():
|
||||
"""
|
||||
Route for batch adding new items to the inventory via CSV.
|
||||
@@ -11910,7 +11904,7 @@ def upload_csv_batch():
|
||||
|
||||
# 2. CSV Einlesen und Validieren
|
||||
try:
|
||||
df = pd.read_csv(csv_file)
|
||||
df = pd.read_csv(csv_file, sep=';')
|
||||
except Exception as e:
|
||||
app.logger.error(f"[Upload {upload_session_id}] Fehler beim Lesen der CSV: {str(e)}")
|
||||
return jsonify({"success": False, "message": f"Fehler beim Lesen der CSV: {str(e)}"}), 400
|
||||
|
||||
@@ -127,6 +127,7 @@
|
||||
padding-bottom: 0;
|
||||
}
|
||||
</style>
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -221,7 +222,7 @@ document.getElementById('batchUploadForm').addEventListener('submit', async func
|
||||
log(`${uniqueDataRows.length} einzigartige Einträge gefunden. ${duplicateCount} Duplikate entfernt.`);
|
||||
|
||||
// Den Index der "Images" Spalte finden
|
||||
const headers = header.split(',');
|
||||
const headers = header.split(';');
|
||||
const imagesColIndex = headers.findIndex(h => h.trim().replace(/['"]/g, '') === 'Images');
|
||||
|
||||
// 4. In Batches (Häppchen) aufteilen
|
||||
@@ -272,11 +273,15 @@ document.getElementById('batchUploadForm').addEventListener('submit', async func
|
||||
formData.append('images', img);
|
||||
});
|
||||
|
||||
// An Server senden
|
||||
try {
|
||||
const csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
|
||||
|
||||
const response = await fetch('/upload_csv_batch', {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
body: formData,
|
||||
headers: {
|
||||
'X-CSRFToken': csrfToken
|
||||
}
|
||||
});
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
Reference in New Issue
Block a user