@@ -512,6 +512,7 @@ def _reset_fields(self) -> None:
512512 self .public_note = None
513513 self .message_for_user = None
514514 self .taxon = None
515+ self .result_source = None
515516 self .confidence = self ._meta .get_field ('confidence' ).default
516517 self .uncertainty = self ._meta .get_field ('uncertainty' ).default
517518 self .agreement = self ._meta .get_field ('agreement' ).default
@@ -615,40 +616,39 @@ def get_most_voted_field(
615616 )
616617 else :
617618 if self .total_finished_annotations >= settings .MAX_N_OF_EXPERTS_ASSIGNED_PER_REPORT :
618- # Case 3: Sufficient annotations for final decision
619619 self .status = self .Status .DONE
620- self .result_source = self .ResultSource .EXPERT
621- taxon , confidence , uncertainty , agreement = self .get_taxon_consensus (
622- annotations = list (finished_experts_annotations_qs )
623- )
624- if uncertainty > 0.92 :
625- self .taxon = Taxon .get_root ()
626- self .confidence = Decimal ('1.0' )
627- self .uncertainty = 1.0
628- self .agreement = 0.0
620+
621+ # Case 3: Sufficient annotations for final decision
622+ self .result_source = self .ResultSource .EXPERT
623+ taxon , confidence , uncertainty , agreement = self .get_taxon_consensus (
624+ annotations = list (finished_experts_annotations_qs )
625+ )
626+ if uncertainty > 0.92 :
627+ self .taxon = Taxon .get_root ()
628+ self .confidence = Decimal ('1.0' )
629+ self .uncertainty = 1.0
630+ self .agreement = 0.0
631+ self .status = self .Status .CONFLICT
632+ else :
633+ self .taxon = taxon
634+ self .confidence = confidence
635+ self .uncertainty = uncertainty
636+ self .agreement = agreement
637+
638+ if self .agreement == 0 and finished_experts_annotations_qs .filter (taxon__is_relevant = True ).exists ():
639+ # All experts has choosen different things.
629640 self .status = self .Status .CONFLICT
630- else :
631- self .taxon = taxon
632- self .confidence = confidence
633- self .uncertainty = uncertainty
634- self .agreement = agreement
635-
636- if self .agreement == 0 and finished_experts_annotations_qs .filter (taxon__is_relevant = True ).exists ():
637- # All experts has choosen different things.
638- self .status = self .Status .CONFLICT
639-
640- if self .taxon :
641- taxon_filter = {
642- 'taxon__in' : Taxon .get_tree (parent = self .taxon )
643- }
644- else :
645- taxon_filter = {
646- 'taxon__isnull' : True
647- }
648- self .photo_id = get_most_voted_field (field_name = 'best_photo' , lookup_filter = taxon_filter )
649- self .public_note = get_most_voted_field (field_name = 'edited_user_notes' , lookup_filter = taxon_filter )
641+
642+ if self .taxon :
643+ taxon_filter = {
644+ 'taxon__in' : Taxon .get_tree (parent = self .taxon )
645+ }
650646 else :
651- self ._reset_fields ()
647+ taxon_filter = {
648+ 'taxon__isnull' : True
649+ }
650+ self .photo_id = get_most_voted_field (field_name = 'best_photo' , lookup_filter = taxon_filter )
651+ self .public_note = get_most_voted_field (field_name = 'edited_user_notes' , lookup_filter = taxon_filter )
652652
653653 self .is_safe = not finished_experts_annotations_qs .filter (status = ExpertReportAnnotation .STATUS_HIDDEN ).exists ()
654654 self .is_flagged = finished_experts_annotations_qs .filter (status = ExpertReportAnnotation .STATUS_FLAGGED ).exists ()
0 commit comments