Skip to content

Commit 2613db5

Browse files
committed
Add annotation.type
1 parent e6f830a commit 2613db5

File tree

5 files changed

+18
-0
lines changed

5 files changed

+18
-0
lines changed

api/filters.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,15 @@ def filter_by_is_favourite(self, queryset, name, value):
263263
)
264264
).filter(is_favourite=value)
265265

266+
type = filters.ChoiceFilter(
267+
choices=[('short', 'short'), ('long', 'long')],
268+
method="filter_by_type"
269+
)
270+
def filter_by_type(self, queryset, name, value):
271+
if not value:
272+
return queryset
273+
return queryset.filter(simplified_annotation=(value == 'short'))
274+
266275
order_by = filters.OrderingFilter(
267276
fields=(("created", "created_at"), ("last_modified", "updated_at"))
268277
)

api/serializers.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,7 @@ class Meta:
809809
best_photo_uuid = serializers.UUIDField(write_only=True, required=False)
810810
best_photo = SimplePhotoSerializer(read_only=True, allow_null=True)
811811
tags = TagListSerializerField(required=False, allow_empty=True)
812+
type = serializers.SerializerMethodField()
812813

813814
is_flagged = WritableSerializerMethodField(
814815
field_class=serializers.BooleanField,
@@ -825,6 +826,9 @@ class Meta:
825826
default=False,
826827
)
827828

829+
def get_type(self, obj) -> Literal['short', 'long']:
830+
return 'short' if obj.simplified_annotation else 'long'
831+
828832
def get_is_flagged(self, obj) -> bool:
829833
return obj.status == ExpertReportAnnotation.STATUS_FLAGGED
830834

@@ -898,6 +902,7 @@ class Meta:
898902
"best_photo",
899903
"classification",
900904
"feedback",
905+
"type",
901906
"is_flagged",
902907
"is_decisive",
903908
"is_favourite",

api/tests/integration/identification_tasks/annotations/create.tavern.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ stages:
8989
public_note: null
9090
internal_note: null
9191
user_note: null
92+
type: !anystr
9293
is_flagged: false
9394
is_decisive: false
9495
is_favourite: false
@@ -152,6 +153,7 @@ stages:
152153
public_note: null
153154
internal_note: null
154155
user_note: null
156+
type: !anystr
155157
is_flagged: false
156158
is_decisive: false
157159
is_favourite: false

api/tests/integration/identification_tasks/annotations/schema.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ variables:
1919
public_note: !anything
2020
internal_note: !anything
2121
user_note: !anything
22+
type: !anystr
2223
is_flagged: !anybool
2324
is_decisive: !anybool
2425
is_favourite: !anybool

tigaserver_project/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@
280280
'ReportTypeEnum': 'tigaserver_app.models.Report.TYPE_CHOICES',
281281
"DeviceTypeEnum": 'fcm_django.models.DeviceType',
282282
"ValidationErrorEnum": "drf_standardized_errors.openapi_serializers.ValidationErrorEnum.choices",
283+
"AnnotationTypeEnum": ['short', 'long'],
283284
"ClientErrorEnum": "drf_standardized_errors.openapi_serializers.ClientErrorEnum.choices",
284285
"ServerErrorEnum": "drf_standardized_errors.openapi_serializers.ServerErrorEnum.choices",
285286
"ErrorCode401Enum": "api.error_serializers.ErrorCode401Enum.choices",

0 commit comments

Comments
 (0)