Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
疯人忠
Cvat
提交
876784eb
C
Cvat
项目概览
疯人忠
/
Cvat
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
Cvat
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
876784eb
编写于
3月 01, 2022
作者:
N
Nikita Manovich
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/develop' into release-2.0.0
上级
41a92e70
cc98ff05
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
45 addition
and
6 deletion
+45
-6
cvat/apps/engine/views.py
cvat/apps/engine/views.py
+3
-3
cvat/apps/iam/permissions.py
cvat/apps/iam/permissions.py
+12
-2
tests/rest_api/test_organizations.py
tests/rest_api/test_organizations.py
+27
-1
tests/rest_api/utils/config.py
tests/rest_api/utils/config.py
+3
-0
未找到文件。
cvat/apps/engine/views.py
浏览文件 @
876784eb
...
...
@@ -260,7 +260,7 @@ class ProjectViewSet(viewsets.ModelViewSet):
ordering_fields
=
filter_fields
ordering
=
"-id"
lookup_fields
=
{
'owner'
:
'owner__username'
,
'assignee'
:
'assignee__username'
}
http_method_names
=
(
'get'
,
'post'
,
'head'
,
'patch'
,
'delete'
)
http_method_names
=
(
'get'
,
'post'
,
'head'
,
'patch'
,
'delete'
,
'options'
)
iam_organization_field
=
'organization'
def
get_serializer_class
(
self
):
...
...
@@ -1243,7 +1243,7 @@ class CommentViewSet(viewsets.ModelViewSet):
class
UserViewSet
(
viewsets
.
GenericViewSet
,
mixins
.
ListModelMixin
,
mixins
.
RetrieveModelMixin
,
mixins
.
UpdateModelMixin
,
mixins
.
DestroyModelMixin
):
queryset
=
User
.
objects
.
prefetch_related
(
'groups'
).
all
()
http_method_names
=
[
'get'
,
'post'
,
'head'
,
'patch'
,
'delete'
]
http_method_names
=
[
'get'
,
'post'
,
'head'
,
'patch'
,
'delete'
,
'options'
]
search_fields
=
(
'username'
,
'first_name'
,
'last_name'
)
iam_organization_field
=
'memberships__organization'
...
...
@@ -1313,7 +1313,7 @@ class UserViewSet(viewsets.GenericViewSet, mixins.ListModelMixin,
'201'
:
CloudStorageWriteSerializer
,
},
tags
=
[
'cloud storages'
],
versions
=
[
'2.0'
]))
class
CloudStorageViewSet
(
viewsets
.
ModelViewSet
):
http_method_names
=
[
'get'
,
'post'
,
'patch'
,
'delete'
]
http_method_names
=
[
'get'
,
'post'
,
'patch'
,
'delete'
,
'options'
]
queryset
=
CloudStorageModel
.
objects
.
all
().
prefetch_related
(
'data'
)
search_fields
=
(
'provider_type'
,
'display_name'
,
'resource'
,
...
...
cvat/apps/iam/permissions.py
浏览文件 @
876784eb
...
...
@@ -1015,8 +1015,14 @@ class PolicyEnforcer(BasePermission):
# pylint: disable=no-self-use
def
check_permission
(
self
,
request
,
view
,
obj
):
permissions
=
[]
for
perm
in
OpenPolicyAgentPermission
.
__subclasses__
():
permissions
.
extend
(
perm
.
create
(
request
,
view
,
obj
))
# DRF can send OPTIONS request. Internally it will try to get
# information about serializers for PUT and POST requests (clone
# request and replace the http method). To avoid handling
# ('POST', 'metadata') and ('PUT', 'metadata') in every request,
# the condition below is enough.
if
not
self
.
is_metadata_request
(
request
,
view
):
for
perm
in
OpenPolicyAgentPermission
.
__subclasses__
():
permissions
.
extend
(
perm
.
create
(
request
,
view
,
obj
))
return
all
(
permissions
)
...
...
@@ -1029,6 +1035,10 @@ class PolicyEnforcer(BasePermission):
def
has_object_permission
(
self
,
request
,
view
,
obj
):
return
self
.
check_permission
(
request
,
view
,
obj
)
@
staticmethod
def
is_metadata_request
(
request
,
view
):
return
request
.
method
==
'OPTIONS'
or
view
.
action
==
'metadata'
class
IsMemberInOrganization
(
BasePermission
):
message
=
'You should be an active member in the organization.'
...
...
tests/rest_api/test_organizations.py
浏览文件 @
876784eb
...
...
@@ -4,9 +4,35 @@
from
http
import
HTTPStatus
import
pytest
from
.utils.config
import
get_method
,
patch_method
,
delete_method
from
.utils.config
import
get_method
,
options_method
,
patch_method
,
delete_method
from
deepdiff
import
DeepDiff
class
TestMetadataOrganizations
:
_ORG
=
2
@
pytest
.
mark
.
parametrize
(
'privilege, role, is_member'
,
[
(
'admin'
,
None
,
None
),
(
'user'
,
None
,
False
),
(
'business'
,
None
,
False
),
(
'worker'
,
None
,
False
),
(
None
,
'owner'
,
True
),
(
None
,
'maintainer'
,
True
),
(
None
,
'worker'
,
True
),
(
None
,
'supervisor'
,
True
),
])
def
test_can_send_options_request
(
self
,
privilege
,
role
,
is_member
,
find_users
,
organizations
):
exclude_org
=
None
if
is_member
else
self
.
_ORG
org
=
self
.
_ORG
if
is_member
else
None
user
=
find_users
(
privilege
=
privilege
,
role
=
role
,
org
=
org
,
exclude_org
=
exclude_org
)[
0
][
'username'
]
response
=
options_method
(
user
,
f
'organizations'
)
assert
response
.
status_code
==
HTTPStatus
.
OK
response
=
options_method
(
user
,
f
'organizations/
{
self
.
_ORG
}
'
)
assert
response
.
status_code
==
HTTPStatus
.
OK
class
TestGetOrganizations
:
_ORG
=
2
...
...
tests/rest_api/utils/config.py
浏览文件 @
876784eb
...
...
@@ -24,6 +24,9 @@ def get_api_url(endpoint, **kwargs):
def
get_method
(
username
,
endpoint
,
**
kwargs
):
return
requests
.
get
(
get_api_url
(
endpoint
,
**
kwargs
),
auth
=
(
username
,
USER_PASS
))
def
options_method
(
username
,
endpoint
,
**
kwargs
):
return
requests
.
options
(
get_api_url
(
endpoint
,
**
kwargs
),
auth
=
(
username
,
USER_PASS
))
def
delete_method
(
username
,
endpoint
,
**
kwargs
):
return
requests
.
delete
(
get_api_url
(
endpoint
,
**
kwargs
),
auth
=
(
username
,
USER_PASS
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录