Skip to content

Commit cbcb2c9

Browse files
committed
'Not sure' should be label as taxon Insecta
1 parent 543c201 commit cbcb2c9

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

tigacrafting/migrations/0026_populate_expertreportannotation_taxon.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ def set_expertreportannotation_taxon(apps, schema_editor):
4242
)
4343
)
4444

45+
# Case 'Not sure':
46+
expert_report_annotation_qs.filter(category_id=9).update(
47+
confidence=1.0,
48+
taxon_id=1 # This is Taxon.get_root().
49+
)
50+
4551
# Otherwise, use category.
4652
expert_report_annotation_qs.filter(category__isnull=False).update(
4753
taxon=models.Subquery(

tigacrafting/models.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -499,9 +499,9 @@ def assign_to_user(self, user: User) -> None:
499499
)
500500

501501
def get_display_identification_label(self) -> str:
502-
if not self.is_done:
502+
if not self.is_done or not self.taxon:
503503
return _("species_unclassified")
504-
if not self.taxon:
504+
if self.taxon.is_root():
505505
return _("species_notsure")
506506

507507
return self.taxon.get_display_friendly_common_name()
@@ -1115,11 +1115,13 @@ def get_category_euro(self) -> str:
11151115
return dict([(-3, 'Unclassified')] + list(SITE_CATEGORIES))[self.get_score()]
11161116
elif self.report.type == 'adult':
11171117
if not self.taxon:
1118-
return "Not sure"
1118+
return "Unclassified"
11191119
if self.taxon.is_relevant:
11201120
with translation.override('en'):
11211121
return "{} {}".format(self.confidence_label, self.taxon.name)
11221122
if self.taxon.is_root():
1123+
if self.category_id == 9: # Not sure
1124+
return "Not sure"
11231125
return "Other species"
11241126
return "Other species - " + self.taxon.name
11251127

@@ -1522,6 +1524,9 @@ def get_from_old_classification(cls, category: Optional[Categories] = None, comp
15221524
return other_species.taxa.first()
15231525

15241526
if category:
1527+
# Special case for 'Not sure':
1528+
if category.pk == 9:
1529+
return cls.get_root()
15251530
return category.taxa.first()
15261531

15271532
return None

tigaserver_app/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2355,6 +2355,7 @@ def get_final_combined_expert_category_euro(self) -> str:
23552355
if not identification_task:
23562356
return "Unclassified"
23572357
if not identification_task.taxon:
2358+
# TODO: At some point this should be rename to Off-topic.
23582359
return "Not sure"
23592360
if identification_task.status == IdentificationTask.Status.CONFLICT:
23602361
return "Conflict"

tigaserver_app/tests/tests.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,6 +1410,9 @@ def test_annotate_coarse(self):
14101410
category_text = classification['category']
14111411
category_id = int(classification['category_id'])
14121412
value = classification['value']
1413+
if category.pk == 9:
1414+
# Not sure is displayed as 'Other species'
1415+
category = Categories.objects.get(pk=2)
14131416
self.assertEqual(category_text, category.name, "Category should be {0}, is {1}".format(category.name, category_text))
14141417
self.assertEqual(category_id, category.id, "Category id should be {0}, is {1}".format(category.id, category_id))
14151418
if category.specify_certainty_level:

0 commit comments

Comments
 (0)