Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RESTful API #389

Merged
merged 137 commits into from
Apr 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
137 commits
Select commit Hold shift + click to select a range
a3a3604
Squashed commit of the following:
nmanovic Feb 17, 2019
9a8e607
Updated changelog
nmanovic Feb 17, 2019
913bcaf
Add django-filter support for TaskViewSet
Feb 18, 2019
bb3f15b
Add functional test for GET /api/v1/tasks
Feb 18, 2019
5783477
Add test for GET /api/v1/tasks/id
Feb 18, 2019
1318fc1
Fix tests for rest_api and some warnings "Warn if self.object_list is…
nmanovic Feb 18, 2019
5b295c7
Minor update (compare labels as well)
nmanovic Feb 18, 2019
f70bbc3
Add more tests for Task update and partial_update
Feb 19, 2019
4dde924
Add a test for task create API
Feb 19, 2019
77de098
First try to implement TaskData test case.
nmanovic Feb 19, 2019
3ce4dea
Fix TestDataAPITestCase
Feb 20, 2019
2e8e1a8
Slightly improved testing for REST API
Feb 20, 2019
a1f3a37
Fix segment_size == 0 case
Feb 20, 2019
4c0b0bc
Improved performance of unit tests (used MD5PasswordHasher)
Feb 20, 2019
08891c4
Dashboard update for REST API (#328)
bsekachev Feb 20, 2019
f034aeb
Merge remote-tracking branch 'origin/develop' into nm/rest_api
Feb 20, 2019
1946231
Redesign DB for annotations (migrations only, need to fix code)
nmanovic Feb 20, 2019
34a2008
Fixed migration 0016 for engine.
Feb 21, 2019
b00fc5f
Minor changes in DB.
Feb 21, 2019
91d23af
Renamed a couple of models
Feb 21, 2019
3907703
Add serializers for job annotations.
Feb 21, 2019
1bace2e
Different request to clone a git repository (#330)
bsekachev Feb 22, 2019
99f885e
Designed REST API for tasks/jobs annotations
Feb 22, 2019
f99c7ab
Small fix for git decorator (#333)
bsekachev Feb 25, 2019
3cd2e7e
Initial version: db -> client
Feb 25, 2019
5699230
Merge branch 'nm/rest_api' of https://github.com/opencv/cvat into nm/…
Feb 25, 2019
4b3002a
REST API: annotations
Feb 25, 2019
0e879d7
Add a new test
nmanovic Feb 26, 2019
4d76f4b
Add initial version of test for job annotations API.
Feb 27, 2019
9a97294
Remove client_id, rename group_id to group.
Feb 28, 2019
edb2e6c
Remove multi table inheritance due to bulk_create cannot be used.
Feb 28, 2019
9816982
Remove extra dependency.
Feb 28, 2019
30dd5ff
Remove bad import
Feb 28, 2019
75acca6
FloatArrayField for points
Feb 28, 2019
aeb0f6d
Improve test for get/put annotaitons for job, fix tests.
nmanovic Mar 1, 2019
0d08af6
Fix get/put annotations to job. Now it should work.
nmanovic Mar 1, 2019
d9e2354
Merge remote-tracking branch 'origin/develop' into nm/rest_api
Mar 7, 2019
7213805
Continued implementation of PATCH /api/v1/jobs/ID/annotations
Mar 8, 2019
b6eb860
Updated django version (2.1.7)
Mar 11, 2019
cd7a409
Merge remote-tracking branch 'origin/develop' into nm/rest_api
Mar 11, 2019
5ea78d8
Particular support of annotation in client (#352)
bsekachev Mar 18, 2019
9957b48
Merge remote-tracking branch 'origin/develop' into nm/rest_api
nmanovic Mar 18, 2019
2f83120
first version of existed anno migrations (#348)
azhavoro Mar 19, 2019
05b7a98
Implemented /api/v1/server/share
Mar 20, 2019
26b44a5
Merge remote-tracking branch 'origin/develop' into nm/rest_api
Mar 21, 2019
6ae5b9f
Integration of REST/API in client #2 (#355)
bsekachev Mar 21, 2019
d86924e
Fixed a bug in dashboard.js
Mar 21, 2019
5ef2275
Fix creating tasks with share support.
Mar 21, 2019
023414b
Add a test for uploading data from share
Mar 21, 2019
2f3f691
Improve filtering for tasks
Mar 21, 2019
a03d9a3
Implemented DELETE, PATCH, PUT methods for /api/v1/tasks/<id>/annotat…
Mar 21, 2019
6268c84
Fix issue with uploading server files inside a directory.
Mar 22, 2019
c27adab
Fix filtration by status.
Mar 22, 2019
5f76cd4
Updated requirements for Mac OS.
Mar 24, 2019
1e13746
Integration of REST/API in client #3 (#357)
bsekachev Mar 25, 2019
8c0e134
Merge branch 'nm/rest_api' of github.com:opencv/cvat into nm/rest_api
Mar 25, 2019
3c96963
Fix an issue with too long file name.
Mar 28, 2019
b683a19
Splitted 15th migration to db spec and data migration. Also minor fix…
azhavoro Mar 28, 2019
85e9ff8
Slightly renamed migrations
Mar 28, 2019
30a5eb8
Integration of REST/API in client #4 (#364)
bsekachev Mar 29, 2019
2f66482
Merge branch 'nm/rest_api' of github.com:opencv/cvat into nm/rest_api
Mar 29, 2019
36e7ab7
Implement api/v1/server/logs without ELK support
Mar 29, 2019
f0cf418
Fix a problem with share and directory with images.
Mar 29, 2019
1b8a8c3
Integration of REST/API in client #5 (#367)
bsekachev Mar 30, 2019
5abbeb0
Swagger documentation
Apr 1, 2019
d97c368
Merge branch 'develop' into nm/rest_api
Apr 1, 2019
f070815
Merge remote-tracking branch 'origin/develop' into nm/rest_api
Apr 1, 2019
dd4b769
Integration of REST/API in client (Part 6) (#369)
bsekachev Apr 1, 2019
b6323b5
400 error in case of Integrity Error.
Apr 1, 2019
491431a
Fixed auto annotation (#370)
bsekachev Apr 1, 2019
38fade6
Patch job with 'delete' action returns input objects.
Apr 1, 2019
fe3c2f0
Merge branch 'nm/rest_api' of github.com:opencv/cvat into nm/rest_api
Apr 1, 2019
941daa3
Remove max_shape_id
Apr 1, 2019
ea68035
Integration of REST/API in client (Part 8) (#372)
bsekachev Apr 2, 2019
9c9c715
fixed task creation (#366)
azhavoro Apr 2, 2019
03a9175
fixed task creation for archives (#373)
azhavoro Apr 2, 2019
772dcd2
Initial version of get_task_data.
Apr 3, 2019
b4683ef
Add dummy version of dump method for TaskAnnotation (it doesn't work …
Apr 3, 2019
582d262
Az/logger fix (#375)
azhavoro Apr 4, 2019
6beb278
Implementation of dump is in progress
Apr 4, 2019
7ce6eb6
Integration of REST/API in client (Part 9) (#377)
bsekachev Apr 4, 2019
aa02a04
renamed logger Event class (#378)
azhavoro Apr 5, 2019
363f42c
Integration of REST/API in client (Part 10) (#379)
bsekachev Apr 5, 2019
9de57b9
Merge remote-tracking branch 'origin/develop' into nm/rest_api
Apr 5, 2019
463d6eb
Fix rest api functional tests (overlap is None by default)
Apr 5, 2019
443035d
use prefetch_related in JobAnnotation.save methods (#380)
azhavoro Apr 5, 2019
84b98d9
Add tests for /api/v1/tasks/<id>/annotations
Apr 5, 2019
8dd5e4a
Merge branch 'nm/rest_api' of github.com:opencv/cvat into nm/rest_api
Apr 5, 2019
9595629
used prefetch_related for TaskViewSet (#381)
azhavoro Apr 8, 2019
b8f3889
Use drf-yang instead of django rest swagger.
Apr 8, 2019
8a173ae
Merge branch 'nm/rest_api' of github.com:opencv/cvat into nm/rest_api
Apr 8, 2019
4303138
Initial version of tests for dump functionality
Apr 9, 2019
4114c54
Initial version of _check_dump_response inside tests
Apr 10, 2019
439d478
Add merge_shapes functionality.
Apr 10, 2019
4cdb0d2
Dump of annotations (#385)
bsekachev Apr 10, 2019
409345d
Az/perf fix (#384)
azhavoro Apr 10, 2019
21d0162
Updated sync data for git application (#386)
bsekachev Apr 10, 2019
355e417
Improve dump functionality
Apr 10, 2019
5b8af8d
Auto file name for dump (#387)
bsekachev Apr 11, 2019
7e2cae0
removed code cloning (#388)
azhavoro Apr 11, 2019
ac0a5b3
Removed object hash (#390)
bsekachev Apr 11, 2019
2d99d31
Analytics button in dashboard (#391)
bsekachev Apr 11, 2019
61fda19
Add TagManager, ShapeManager, TrackManager
Apr 11, 2019
b8006be
improved uploading annotation for task (#393)
azhavoro Apr 12, 2019
f1995a8
Add first untested/uncomplied version of dump.
Apr 12, 2019
ee03307
Implemented to_tracks and to_shapes methods
Apr 12, 2019
12bac09
Dummy implementation of get_interpolated_shapes method
Apr 13, 2019
4ddeea7
Fixed a couple of typos.
Apr 13, 2019
1dee7cf
Merge branch 'nm/rest_api' of github.com:opencv/cvat into nm/rest_api
Apr 13, 2019
6a181af
Fix a couple of typos in "annotation" mode for dump.
Apr 14, 2019
b6cdd82
Fixed dashboard pagination (#399)
bsekachev Apr 15, 2019
17a4e8e
Az/task meta (#401)
azhavoro Apr 15, 2019
16cf076
collapsed migrations (#402)
azhavoro Apr 16, 2019
a34bf23
Dump in annotation mode works in trivial cases.
Apr 16, 2019
82c9b68
Couple of fixes for Rest API (#404)
bsekachev Apr 16, 2019
50d3c81
Fix a couple of typo in "interpolation" mode.
Apr 16, 2019
b9f7a54
Merge branch 'nm/rest_api' of github.com:opencv/cvat into nm/rest_api
Apr 16, 2019
eec8b9f
Removed annotation.py and renamed annotation_v2.py
Apr 16, 2019
61b725c
Fix funtional tests for REST API.
Apr 17, 2019
3f64a5d
fixed annotation parser for polyshapes (#405)
azhavoro Apr 17, 2019
f794144
Implemented "version" for jobs.
Apr 17, 2019
95a5314
Merge branch 'nm/rest_api' of github.com:opencv/cvat into nm/rest_api
Apr 17, 2019
6db6ea6
Implemented annotation version for task.
Apr 17, 2019
667e311
Fixed codacy issues part 1 (#403)
azhavoro Apr 17, 2019
d7acdb9
Some fixes in dump of annotations (#407)
bsekachev Apr 17, 2019
2d01d35
Merge remote-tracking branch 'origin/develop' into nm/rest_api
Apr 17, 2019
a01555e
Slightly improve code for annotation.py
Apr 17, 2019
2b3e59e
Rest API dump & save fixes (#409)
bsekachev Apr 18, 2019
d1bec5f
Az/fix codacy issues part2 (#408)
azhavoro Apr 18, 2019
74afe9f
Some plugin fixes (#411)
bsekachev Apr 18, 2019
1fa6995
fixed codacy issues (#412)
azhavoro Apr 18, 2019
cc7627f
Fixed annotation parser for z_order (#413)
bsekachev Apr 19, 2019
5fae526
Fixed mutation for server logs (#415)
azhavoro Apr 19, 2019
fd22511
Fixed migration 0015 for tasks that have no segments (in case of (#416)
azhavoro Apr 22, 2019
2cedb8b
Sort shapes by frame (#417)
bsekachev Apr 22, 2019
5951e62
Ignore 403 response code for send exception requests (#418)
azhavoro Apr 22, 2019
da79747
Fixed: extra auto annotation buttons appear (#419)
bsekachev Apr 23, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cvat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@
#
# SPDX-License-Identifier: MIT

from cvat.utils.version import get_version

VERSION = (0, 4, 0, 'alpha', 0)

__version__ = get_version(VERSION)
68 changes: 68 additions & 0 deletions cvat/apps/authentication/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

import os
from django.conf import settings
from django.db.models import Q
import rules
from . import AUTH_ROLE
from rest_framework.permissions import BasePermission

def register_signals():
from django.db.models.signals import post_migrate, post_save
Expand Down Expand Up @@ -67,6 +69,11 @@ def is_job_annotator(db_user, db_job):
return has_rights

# AUTH PERMISSIONS RULES
rules.add_perm('engine.role.user', has_user_role)
rules.add_perm('engine.role.admin', has_admin_role)
rules.add_perm('engine.role.annotator', has_annotator_role)
rules.add_perm('engine.role.observer', has_observer_role)

rules.add_perm('engine.task.create', has_admin_role | has_user_role)
rules.add_perm('engine.task.access', has_admin_role | has_observer_role |
is_task_owner | is_task_annotator)
Expand All @@ -78,3 +85,64 @@ def is_job_annotator(db_user, db_job):
is_job_owner | is_job_annotator)
rules.add_perm('engine.job.change', has_admin_role | is_job_owner |
is_job_annotator)

class AdminRolePermission(BasePermission):
# pylint: disable=no-self-use
def has_permission(self, request, view):
return request.user.has_perm("engine.role.admin")

class UserRolePermission(BasePermission):
# pylint: disable=no-self-use
def has_permission(self, request, view):
return request.user.has_perm("engine.role.user")

class AnnotatorRolePermission(BasePermission):
# pylint: disable=no-self-use
def has_permission(self, request, view):
return request.user.has_perm("engine.role.annotator")

class ObserverRolePermission(BasePermission):
# pylint: disable=no-self-use
def has_permission(self, request, view):
return request.user.has_perm("engine.role.observer")

class TaskCreatePermission(BasePermission):
# pylint: disable=no-self-use
def has_permission(self, request, view):
return request.user.has_perm("engine.task.create")

class TaskAccessPermission(BasePermission):
# pylint: disable=no-self-use
def has_object_permission(self, request, view, obj):
return request.user.has_perm("engine.task.access", obj)

class TaskGetQuerySetMixin(object):
def get_queryset(self):
queryset = super().get_queryset()
user = self.request.user
# Don't filter queryset for admin, observer and detail methods
if has_admin_role(user) or has_observer_role(user) or self.detail:
return queryset
else:
return queryset.filter(Q(owner=user) | Q(assignee=user) |
Q(segment__job__assignee=user) | Q(assignee=None)).distinct()

class TaskChangePermission(BasePermission):
# pylint: disable=no-self-use
def has_object_permission(self, request, view, obj):
return request.user.has_perm("engine.task.change", obj)

class TaskDeletePermission(BasePermission):
# pylint: disable=no-self-use
def has_object_permission(self, request, view, obj):
return request.user.has_perm("engine.task.delete", obj)

class JobAccessPermission(BasePermission):
# pylint: disable=no-self-use
def has_object_permission(self, request, view, obj):
return request.user.has_perm("engine.job.access", obj)

class JobChangePermission(BasePermission):
# pylint: disable=no-self-use
def has_object_permission(self, request, view, obj):
return request.user.has_perm("engine.job.change", obj)
Loading