Skip to content

Commit

Permalink
Replaced get/job and save/status by new REST API.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita Manovich committed Jan 28, 2019
1 parent a66073c commit 09431f3
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 6 deletions.
10 changes: 8 additions & 2 deletions cvat/apps/engine/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@
# SPDX-License-Identifier: MIT

from django.apps import AppConfig

from django.db.models.signals import post_save

class EngineConfig(AppConfig):
name = 'engine'
name = 'cvat.apps.engine'

def ready(self):
from .signals import update_task_status

# FIXME: the signal isn't called (why?)
post_save.connect(update_task_status, sender='cvat.apps.engine.Job',
dispatch_uid="update_task_status")
4 changes: 4 additions & 0 deletions cvat/apps/engine/serializers.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Copyright (C) 2019 Intel Corporation
#
# SPDX-License-Identifier: MIT

from rest_framework import serializers
from cvat.apps.engine.models import (Task, Job, Label, AttributeSpec,
Segment)
Expand Down
19 changes: 19 additions & 0 deletions cvat/apps/engine/signals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright (C) 2019 Intel Corporation
#
# SPDX-License-Identifier: MIT

from .models import Job, StatusChoice

def update_task_status(instance, **kwargs):
db_task = instance.segment.task
db_jobs = list(Job.objects.filter(segment__task_id=db_task.id))
status = StatusChoice.COMPLETED
if list(filter(lambda x: x.status == StatusChoice.ANNOTATION, db_jobs)):
status = StatusChoice.ANNOTATION
elif list(filter(lambda x: x.status == StatusChoice.VALIDATION, db_jobs)):
status = StatusChoice.VALIDATION

if status != db_task.status:
db_task.status = status
db_task.save()

4 changes: 2 additions & 2 deletions cvat/apps/engine/static/engine/js/annotationUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -554,8 +554,8 @@ function setupMenu(job, shapeCollectionModel, annotationParser, aamModel, player
$('#statFlipped').text(job.flipped);
$('#statTaskStatus').prop("value", job.status).on('change', (e) => {
$.ajax({
type: 'POST',
url: 'save/status/job/' + window.cvat.job.id,
type: 'PATCH',
url: '/api/v1/jobs/' + window.cvat.job.id,
data: JSON.stringify({
status: e.target.value
}),
Expand Down
2 changes: 0 additions & 2 deletions cvat/apps/engine/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
path('check/task/<int:tid>', views.check_task), ####
path('delete/task/<int:tid>', views.delete_task), ####
path('update/task/<int:tid>', views.update_task), ####
path('get/job/<int:jid>', views.get_job), ###
path('dump/annotation/task/<int:tid>', views.dump_annotation), ###
path('check/annotation/task/<int:tid>', views.check_annotation), ###
path('download/annotation/task/<int:tid>', views.download_annotation), ###
Expand All @@ -92,7 +91,6 @@
path('delete/annotation/task/<int:tid>', views.delete_annotation_for_task), ###
path('get/annotation/job/<int:jid>', views.get_annotation), ###
path('save/exception/<int:jid>', views.catch_client_exception), ###
path('save/status/job/<int:jid>', views.save_job_status), ###

path('', views.dispatch_request),
]

0 comments on commit 09431f3

Please sign in to comment.