Spaces:
Sleeping
Sleeping
Commit
·
4c9108c
1
Parent(s):
a69cb9e
update
Browse files- src/demo/views.py +11 -5
src/demo/views.py
CHANGED
@@ -366,7 +366,7 @@ def get_surveys(request):
|
|
366 |
|
367 |
@csrf_exempt
|
368 |
def upload_refs(request):
|
369 |
-
|
370 |
start_time = time.time()
|
371 |
RECOMMENDED_PDF_DIR = get_path('pdf', 'recommend_pdfs')
|
372 |
if request.method == 'POST':
|
@@ -374,7 +374,6 @@ def upload_refs(request):
|
|
374 |
if not os.path.exists(RECOMMENDED_PDF_DIR):
|
375 |
return JsonResponse({'error': 'No file part'}, status=400)
|
376 |
|
377 |
-
|
378 |
is_valid_submission = True
|
379 |
has_label_id = False
|
380 |
has_ref_link = False
|
@@ -416,15 +415,22 @@ def upload_refs(request):
|
|
416 |
|
417 |
shutil.rmtree(RECOMMENDED_PDF_DIR)
|
418 |
|
|
|
419 |
survey_id_choice = request.POST.get('survey_id')
|
|
|
|
|
|
|
420 |
if survey_id_choice == "new":
|
421 |
-
custom_survey_id = request.POST.get('custom_survey_id', '').strip()
|
422 |
if custom_survey_id:
|
423 |
Global_survey_id = custom_survey_id
|
424 |
else:
|
425 |
-
Global_survey_id = 'test_4'
|
426 |
else:
|
427 |
-
Global_survey_id = survey_id_choice
|
|
|
|
|
|
|
|
|
428 |
uid_str = Global_survey_id
|
429 |
|
430 |
for file_name in file_dict:
|
|
|
366 |
|
367 |
@csrf_exempt
|
368 |
def upload_refs(request):
|
369 |
+
print("upload_refs called, method:", request.method)
|
370 |
start_time = time.time()
|
371 |
RECOMMENDED_PDF_DIR = get_path('pdf', 'recommend_pdfs')
|
372 |
if request.method == 'POST':
|
|
|
374 |
if not os.path.exists(RECOMMENDED_PDF_DIR):
|
375 |
return JsonResponse({'error': 'No file part'}, status=400)
|
376 |
|
|
|
377 |
is_valid_submission = True
|
378 |
has_label_id = False
|
379 |
has_ref_link = False
|
|
|
415 |
|
416 |
shutil.rmtree(RECOMMENDED_PDF_DIR)
|
417 |
|
418 |
+
# 修正 survey_id 获取逻辑,防止 undefined
|
419 |
survey_id_choice = request.POST.get('survey_id')
|
420 |
+
custom_survey_id = request.POST.get('custom_survey_id', '').strip()
|
421 |
+
topic = request.POST.get('topic', '').strip()
|
422 |
+
|
423 |
if survey_id_choice == "new":
|
|
|
424 |
if custom_survey_id:
|
425 |
Global_survey_id = custom_survey_id
|
426 |
else:
|
427 |
+
Global_survey_id = topic or 'test_4'
|
428 |
else:
|
429 |
+
Global_survey_id = survey_id_choice or topic or 'test_4'
|
430 |
+
|
431 |
+
# 防止 undefined
|
432 |
+
if not Global_survey_id or Global_survey_id == 'undefined':
|
433 |
+
Global_survey_id = 'test_4'
|
434 |
uid_str = Global_survey_id
|
435 |
|
436 |
for file_name in file_dict:
|