Spaces:
Paused
Paused
Update app.py via AI Editor
Browse files
app.py
CHANGED
@@ -496,70 +496,164 @@ def handle_shred_upload(contents, filenames, current_shred, file_list):
|
|
496 |
return latest_text, file_previews, filenames[-1]
|
497 |
|
498 |
@app.callback(
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
523 |
prevent_initial_call=True
|
524 |
)
|
525 |
-
def
|
526 |
-
stores = [dash.no_update]*8
|
527 |
-
names = [dash.no_update]*8
|
528 |
if not contents_list or not filenames_list:
|
529 |
-
return
|
530 |
-
for
|
531 |
if contents and filenames:
|
532 |
if isinstance(contents, str):
|
533 |
contents = [contents]
|
534 |
filenames = [filenames]
|
535 |
for content, name in zip(contents, filenames):
|
536 |
file_text = process_document(content, name)
|
537 |
-
|
538 |
-
|
539 |
-
stores[1] = file_text
|
540 |
-
names[1] = name
|
541 |
-
elif 'pink' in name.lower() and 'review' not in name.lower():
|
542 |
-
stores[0] = file_text
|
543 |
-
names[0] = name
|
544 |
-
elif 'red_review' in name.lower():
|
545 |
-
stores[3] = file_text
|
546 |
-
names[3] = name
|
547 |
-
elif 'red' in name.lower() and 'review' not in name.lower():
|
548 |
-
stores[2] = file_text
|
549 |
-
names[2] = name
|
550 |
-
elif 'gold_review' in name.lower():
|
551 |
-
stores[5] = file_text
|
552 |
-
names[5] = name
|
553 |
-
elif 'gold' in name.lower() and 'review' not in name.lower():
|
554 |
-
stores[4] = file_text
|
555 |
-
names[4] = name
|
556 |
-
elif 'loe' in name.lower():
|
557 |
-
stores[6] = file_text
|
558 |
-
names[6] = name
|
559 |
-
elif 'virtual' in name.lower():
|
560 |
-
stores[7] = file_text
|
561 |
-
names[7] = name
|
562 |
-
return stores + names
|
563 |
|
564 |
@app.callback(
|
565 |
Output('document-preview', 'children'),
|
|
|
496 |
return latest_text, file_previews, filenames[-1]
|
497 |
|
498 |
@app.callback(
|
499 |
+
Output('store-pink', 'data'),
|
500 |
+
Output('uploaded-doc-name-pink', 'children'),
|
501 |
+
Input({'type': 'upload-doc-type', 'subtype': 'pink', 'index': ALL}, 'contents'),
|
502 |
+
State({'type': 'upload-doc-type', 'subtype': 'pink', 'index': ALL}, 'filename'),
|
503 |
+
prevent_initial_call=True
|
504 |
+
)
|
505 |
+
def handle_pink_upload(contents_list, filenames_list):
|
506 |
+
if not contents_list or not filenames_list:
|
507 |
+
return dash.no_update, dash.no_update
|
508 |
+
for contents, filenames in zip(contents_list, filenames_list):
|
509 |
+
if contents and filenames:
|
510 |
+
if isinstance(contents, str):
|
511 |
+
contents = [contents]
|
512 |
+
filenames = [filenames]
|
513 |
+
for content, name in zip(contents, filenames):
|
514 |
+
file_text = process_document(content, name)
|
515 |
+
return file_text, name
|
516 |
+
return dash.no_update, dash.no_update
|
517 |
+
|
518 |
+
@app.callback(
|
519 |
+
Output('store-pink-review', 'data'),
|
520 |
+
Output('uploaded-doc-name-pink_review', 'children'),
|
521 |
+
Input({'type': 'upload-doc-type', 'subtype': 'pink_review', 'index': ALL}, 'contents'),
|
522 |
+
State({'type': 'upload-doc-type', 'subtype': 'pink_review', 'index': ALL}, 'filename'),
|
523 |
+
prevent_initial_call=True
|
524 |
+
)
|
525 |
+
def handle_pink_review_upload(contents_list, filenames_list):
|
526 |
+
if not contents_list or not filenames_list:
|
527 |
+
return dash.no_update, dash.no_update
|
528 |
+
for contents, filenames in zip(contents_list, filenames_list):
|
529 |
+
if contents and filenames:
|
530 |
+
if isinstance(contents, str):
|
531 |
+
contents = [contents]
|
532 |
+
filenames = [filenames]
|
533 |
+
for content, name in zip(contents, filenames):
|
534 |
+
file_text = process_document(content, name)
|
535 |
+
return file_text, name
|
536 |
+
return dash.no_update, dash.no_update
|
537 |
+
|
538 |
+
@app.callback(
|
539 |
+
Output('store-red', 'data'),
|
540 |
+
Output('uploaded-doc-name-red', 'children'),
|
541 |
+
Input({'type': 'upload-doc-type', 'subtype': 'red', 'index': ALL}, 'contents'),
|
542 |
+
State({'type': 'upload-doc-type', 'subtype': 'red', 'index': ALL}, 'filename'),
|
543 |
+
prevent_initial_call=True
|
544 |
+
)
|
545 |
+
def handle_red_upload(contents_list, filenames_list):
|
546 |
+
if not contents_list or not filenames_list:
|
547 |
+
return dash.no_update, dash.no_update
|
548 |
+
for contents, filenames in zip(contents_list, filenames_list):
|
549 |
+
if contents and filenames:
|
550 |
+
if isinstance(contents, str):
|
551 |
+
contents = [contents]
|
552 |
+
filenames = [filenames]
|
553 |
+
for content, name in zip(contents, filenames):
|
554 |
+
file_text = process_document(content, name)
|
555 |
+
return file_text, name
|
556 |
+
return dash.no_update, dash.no_update
|
557 |
+
|
558 |
+
@app.callback(
|
559 |
+
Output('store-red-review', 'data'),
|
560 |
+
Output('uploaded-doc-name-red_review', 'children'),
|
561 |
+
Input({'type': 'upload-doc-type', 'subtype': 'red_review', 'index': ALL}, 'contents'),
|
562 |
+
State({'type': 'upload-doc-type', 'subtype': 'red_review', 'index': ALL}, 'filename'),
|
563 |
+
prevent_initial_call=True
|
564 |
+
)
|
565 |
+
def handle_red_review_upload(contents_list, filenames_list):
|
566 |
+
if not contents_list or not filenames_list:
|
567 |
+
return dash.no_update, dash.no_update
|
568 |
+
for contents, filenames in zip(contents_list, filenames_list):
|
569 |
+
if contents and filenames:
|
570 |
+
if isinstance(contents, str):
|
571 |
+
contents = [contents]
|
572 |
+
filenames = [filenames]
|
573 |
+
for content, name in zip(contents, filenames):
|
574 |
+
file_text = process_document(content, name)
|
575 |
+
return file_text, name
|
576 |
+
return dash.no_update, dash.no_update
|
577 |
+
|
578 |
+
@app.callback(
|
579 |
+
Output('store-gold', 'data'),
|
580 |
+
Output('uploaded-doc-name-gold', 'children'),
|
581 |
+
Input({'type': 'upload-doc-type', 'subtype': 'gold', 'index': ALL}, 'contents'),
|
582 |
+
State({'type': 'upload-doc-type', 'subtype': 'gold', 'index': ALL}, 'filename'),
|
583 |
+
prevent_initial_call=True
|
584 |
+
)
|
585 |
+
def handle_gold_upload(contents_list, filenames_list):
|
586 |
+
if not contents_list or not filenames_list:
|
587 |
+
return dash.no_update, dash.no_update
|
588 |
+
for contents, filenames in zip(contents_list, filenames_list):
|
589 |
+
if contents and filenames:
|
590 |
+
if isinstance(contents, str):
|
591 |
+
contents = [contents]
|
592 |
+
filenames = [filenames]
|
593 |
+
for content, name in zip(contents, filenames):
|
594 |
+
file_text = process_document(content, name)
|
595 |
+
return file_text, name
|
596 |
+
return dash.no_update, dash.no_update
|
597 |
+
|
598 |
+
@app.callback(
|
599 |
+
Output('store-gold-review', 'data'),
|
600 |
+
Output('uploaded-doc-name-gold_review', 'children'),
|
601 |
+
Input({'type': 'upload-doc-type', 'subtype': 'gold_review', 'index': ALL}, 'contents'),
|
602 |
+
State({'type': 'upload-doc-type', 'subtype': 'gold_review', 'index': ALL}, 'filename'),
|
603 |
+
prevent_initial_call=True
|
604 |
+
)
|
605 |
+
def handle_gold_review_upload(contents_list, filenames_list):
|
606 |
+
if not contents_list or not filenames_list:
|
607 |
+
return dash.no_update, dash.no_update
|
608 |
+
for contents, filenames in zip(contents_list, filenames_list):
|
609 |
+
if contents and filenames:
|
610 |
+
if isinstance(contents, str):
|
611 |
+
contents = [contents]
|
612 |
+
filenames = [filenames]
|
613 |
+
for content, name in zip(contents, filenames):
|
614 |
+
file_text = process_document(content, name)
|
615 |
+
return file_text, name
|
616 |
+
return dash.no_update, dash.no_update
|
617 |
+
|
618 |
+
@app.callback(
|
619 |
+
Output('store-loe', 'data'),
|
620 |
+
Output('uploaded-doc-name-loe', 'children'),
|
621 |
+
Input({'type': 'upload-doc-type', 'subtype': 'loe', 'index': ALL}, 'contents'),
|
622 |
+
State({'type': 'upload-doc-type', 'subtype': 'loe', 'index': ALL}, 'filename'),
|
623 |
+
prevent_initial_call=True
|
624 |
+
)
|
625 |
+
def handle_loe_upload(contents_list, filenames_list):
|
626 |
+
if not contents_list or not filenames_list:
|
627 |
+
return dash.no_update, dash.no_update
|
628 |
+
for contents, filenames in zip(contents_list, filenames_list):
|
629 |
+
if contents and filenames:
|
630 |
+
if isinstance(contents, str):
|
631 |
+
contents = [contents]
|
632 |
+
filenames = [filenames]
|
633 |
+
for content, name in zip(contents, filenames):
|
634 |
+
file_text = process_document(content, name)
|
635 |
+
return file_text, name
|
636 |
+
return dash.no_update, dash.no_update
|
637 |
+
|
638 |
+
@app.callback(
|
639 |
+
Output('store-virtual-board', 'data'),
|
640 |
+
Output('uploaded-doc-name-virtual_board', 'children'),
|
641 |
+
Input({'type': 'upload-doc-type', 'subtype': 'virtual_board', 'index': ALL}, 'contents'),
|
642 |
+
State({'type': 'upload-doc-type', 'subtype': 'virtual_board', 'index': ALL}, 'filename'),
|
643 |
prevent_initial_call=True
|
644 |
)
|
645 |
+
def handle_virtual_board_upload(contents_list, filenames_list):
|
|
|
|
|
646 |
if not contents_list or not filenames_list:
|
647 |
+
return dash.no_update, dash.no_update
|
648 |
+
for contents, filenames in zip(contents_list, filenames_list):
|
649 |
if contents and filenames:
|
650 |
if isinstance(contents, str):
|
651 |
contents = [contents]
|
652 |
filenames = [filenames]
|
653 |
for content, name in zip(contents, filenames):
|
654 |
file_text = process_document(content, name)
|
655 |
+
return file_text, name
|
656 |
+
return dash.no_update, dash.no_update
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
657 |
|
658 |
@app.callback(
|
659 |
Output('document-preview', 'children'),
|