Skip to content

Commit

Permalink
[hotfix] completed_by attribute in full UserSerializer (HumanSignal#1510
Browse files Browse the repository at this point in the history
)

* [hotfix] completed_by attribute in full UserSerializer

* Add tests

* Fix test

Co-authored-by: nik <[email protected]>
  • Loading branch information
niklub and nik authored Sep 22, 2021
1 parent 19eb118 commit 82248cf
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion label_studio/tasks/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def many_init(cls, *args, **kwargs):
def to_representation(self, instance):
annotation = super(AnnotationSerializer, self).to_representation(instance)
if self.context.get('completed_by', '') == 'full':
annotation['completed_by'] = UserSerializer(annotation.completed_by).data
annotation['completed_by'] = UserSerializer(instance.completed_by).data
return annotation

def get_fields(self):
Expand Down
21 changes: 21 additions & 0 deletions label_studio/tests/shared_stages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,24 @@ stages:
json:
task_pk: id
status_code: 201
- id: create_annotation
name: create_annotation
request:
headers:
content-type: application/json
json:
lead_time: 12.34
result:
- from_name: label
to_name: text
type: choices
value:
choices:
- pos
method: POST
url: '{django_live_url}/api/tasks/{task_pk}/annotations'
response:
save:
json:
annotation_pk: id
status_code: 201
10 changes: 9 additions & 1 deletion label_studio/tests/tasks_api.tavern.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,17 @@ stages:
type: ref
- id: create_task
type: ref
- name: stage
- name: get list of tasks
request:
method: GET
url: '{django_live_url}/api/tasks?project={project_pk}'
response:
status_code: 200
- id: create_annotation
type: ref
- name: get task by id from data manager
request:
method: GET
url: '{django_live_url}/api/dm/tasks/{task_pk}?project={project_pk}'
response:
status_code: 200

0 comments on commit 82248cf

Please sign in to comment.