Spaces:
Running
Running
rejection 2 step implementation in phase 2
Browse files
components/review_dashboard_page.py
CHANGED
@@ -162,7 +162,7 @@ class ReviewDashboardPage:
|
|
162 |
log.error(f"Target annotator {target_annotator} not found in database")
|
163 |
return [], 0, f"Review Target Error: Annotator '{target_annotator}' not found.", "", "", "", "", "", "", "", gr.update(value=None, autoplay=False), gr.update(visible=False, value=""), False, gr.update(value="❌ Reject")
|
164 |
|
165 |
-
log.info(f"Found target annotator
|
166 |
|
167 |
# Get all annotations by target annotator
|
168 |
annotations = db.query(Annotation).join(TTSData).filter(
|
@@ -174,7 +174,7 @@ class ReviewDashboardPage:
|
|
174 |
orm.joinedload(Annotation.annotator)
|
175 |
).order_by(Annotation.id).all() # Added order_by for consistency
|
176 |
|
177 |
-
log.info(f"Fetched {len(annotations)} annotations for target annotator ID {target_annotator_obj.id}
|
178 |
|
179 |
items = []
|
180 |
for annotation in annotations:
|
@@ -355,11 +355,17 @@ class ReviewDashboardPage:
|
|
355 |
|
356 |
def handle_rejection_fn(items, idx, session, rejection_reason, rejection_mode_active):
|
357 |
"""Handle rejection button click - two-step process"""
|
|
|
|
|
|
|
|
|
|
|
|
|
358 |
if not rejection_mode_active:
|
359 |
# First click - show rejection reason input and change button text
|
360 |
return (
|
361 |
items, # items unchanged
|
362 |
-
|
363 |
gr.update(visible=True, value=""), # Show rejection reason input, clear any existing value
|
364 |
True, # Set rejection mode active
|
365 |
gr.update(value="⚠️ Confirm Reject") # Change button text
|
@@ -370,7 +376,7 @@ class ReviewDashboardPage:
|
|
370 |
gr.Warning("Rejection reason cannot be empty. Please provide a reason before confirming rejection.")
|
371 |
return (
|
372 |
items, # items unchanged
|
373 |
-
|
374 |
gr.update(visible=True, value=rejection_reason), # Keep input visible
|
375 |
True, # Keep rejection mode active
|
376 |
gr.update(value="⚠️ Confirm Reject") # Keep button text
|
@@ -487,8 +493,20 @@ class ReviewDashboardPage:
|
|
487 |
inputs=[self.items_state, self.idx_state, self.rejection_mode_active],
|
488 |
outputs=[self.idx_state]
|
489 |
).then(
|
490 |
-
fn=show_current_review_item_fn,
|
491 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
492 |
outputs=review_display_outputs
|
493 |
)
|
494 |
|
|
|
162 |
log.error(f"Target annotator {target_annotator} not found in database")
|
163 |
return [], 0, f"Review Target Error: Annotator '{target_annotator}' not found.", "", "", "", "", "", "", "", gr.update(value=None, autoplay=False), gr.update(visible=False, value=""), False, gr.update(value="❌ Reject")
|
164 |
|
165 |
+
log.info(f"Found target annotator with ID: {target_annotator_obj.id}")
|
166 |
|
167 |
# Get all annotations by target annotator
|
168 |
annotations = db.query(Annotation).join(TTSData).filter(
|
|
|
174 |
orm.joinedload(Annotation.annotator)
|
175 |
).order_by(Annotation.id).all() # Added order_by for consistency
|
176 |
|
177 |
+
log.info(f"Fetched {len(annotations)} annotations for target annotator ID {target_annotator_obj.id}")
|
178 |
|
179 |
items = []
|
180 |
for annotation in annotations:
|
|
|
355 |
|
356 |
def handle_rejection_fn(items, idx, session, rejection_reason, rejection_mode_active):
|
357 |
"""Handle rejection button click - two-step process"""
|
358 |
+
if not items or idx >= len(items):
|
359 |
+
return items, "Error: Invalid item", gr.update(visible=False), False, gr.update(value="❌ Reject")
|
360 |
+
|
361 |
+
current_item = items[idx]
|
362 |
+
current_status = current_item["validation_status"]
|
363 |
+
|
364 |
if not rejection_mode_active:
|
365 |
# First click - show rejection reason input and change button text
|
366 |
return (
|
367 |
items, # items unchanged
|
368 |
+
current_status, # Keep current validation status
|
369 |
gr.update(visible=True, value=""), # Show rejection reason input, clear any existing value
|
370 |
True, # Set rejection mode active
|
371 |
gr.update(value="⚠️ Confirm Reject") # Change button text
|
|
|
376 |
gr.Warning("Rejection reason cannot be empty. Please provide a reason before confirming rejection.")
|
377 |
return (
|
378 |
items, # items unchanged
|
379 |
+
current_status, # Keep current validation status
|
380 |
gr.update(visible=True, value=rejection_reason), # Keep input visible
|
381 |
True, # Keep rejection mode active
|
382 |
gr.update(value="⚠️ Confirm Reject") # Keep button text
|
|
|
493 |
inputs=[self.items_state, self.idx_state, self.rejection_mode_active],
|
494 |
outputs=[self.idx_state]
|
495 |
).then(
|
496 |
+
fn=lambda items, idx, session, rejection_mode: show_current_review_item_fn(items, idx, session) if not rejection_mode else (
|
497 |
+
str(items[idx]["tts_id"]) if items and idx < len(items) else "",
|
498 |
+
items[idx]["filename"] if items and idx < len(items) else "",
|
499 |
+
items[idx]["sentence"] if items and idx < len(items) else "",
|
500 |
+
items[idx]["annotated_sentence"] if items and idx < len(items) else "",
|
501 |
+
items[idx]["annotated_at"] if items and idx < len(items) else "",
|
502 |
+
items[idx]["validation_status"] if items and idx < len(items) else "",
|
503 |
+
"", # annotator placeholder
|
504 |
+
gr.update(value=None, autoplay=False), # audio
|
505 |
+
gr.update(), # rejection_reason_input - don't change
|
506 |
+
rejection_mode, # keep rejection mode as is
|
507 |
+
gr.update() # btn_reject - don't change
|
508 |
+
),
|
509 |
+
inputs=[self.items_state, self.idx_state, session_state, self.rejection_mode_active],
|
510 |
outputs=review_display_outputs
|
511 |
)
|
512 |
|