fix: application query (#3344)
This commit is contained in:
parent
bb109d65cf
commit
a00860528a
@ -298,15 +298,12 @@ class Query(serializers.Serializer):
|
|||||||
folder_query_set = QuerySet(ApplicationFolder)
|
folder_query_set = QuerySet(ApplicationFolder)
|
||||||
application_query_set = QuerySet(Application)
|
application_query_set = QuerySet(Application)
|
||||||
workspace_id = self.data.get('workspace_id')
|
workspace_id = self.data.get('workspace_id')
|
||||||
user_id = instance.get('user_id')
|
user_id = self.data.get('user_id')
|
||||||
desc = instance.get('desc')
|
desc = instance.get('desc')
|
||||||
name = instance.get('name')
|
name = instance.get('name')
|
||||||
if workspace_id is not None:
|
if workspace_id is not None:
|
||||||
folder_query_set = folder_query_set.filter(workspace_id=workspace_id)
|
folder_query_set = folder_query_set.filter(workspace_id=workspace_id)
|
||||||
application_query_set = application_query_set.filter(workspace_id=workspace_id)
|
application_query_set = application_query_set.filter(workspace_id=workspace_id)
|
||||||
if user_id is not None:
|
|
||||||
folder_query_set = folder_query_set.filter(user_id=user_id)
|
|
||||||
application_query_set = application_query_set.filter(user_id=user_id)
|
|
||||||
folder_id = instance.get('folder_id')
|
folder_id = instance.get('folder_id')
|
||||||
if folder_id is not None:
|
if folder_id is not None:
|
||||||
folder_query_set = folder_query_set.filter(parent=folder_id)
|
folder_query_set = folder_query_set.filter(parent=folder_id)
|
||||||
@ -319,12 +316,15 @@ class Query(serializers.Serializer):
|
|||||||
application_query_set = application_query_set.filter(desc__contains=desc)
|
application_query_set = application_query_set.filter(desc__contains=desc)
|
||||||
application_custom_sql_query_set = application_query_set
|
application_custom_sql_query_set = application_query_set
|
||||||
application_query_set = application_query_set.order_by("-update_time")
|
application_query_set = application_query_set.order_by("-update_time")
|
||||||
|
workspace_user_role_mapping_model = DatabaseModelManage.get_model('workspace_user_role_mapping')
|
||||||
return {
|
return {
|
||||||
'folder_query_set': folder_query_set,
|
'folder_query_set': folder_query_set,
|
||||||
'application_query_set': application_query_set,
|
'application_query_set': application_query_set,
|
||||||
'application_custom_sql': application_custom_sql_query_set
|
'application_custom_sql': application_custom_sql_query_set
|
||||||
} if workspace_manage else {'folder_query_set': folder_query_set,
|
} if workspace_manage else {'folder_query_set': folder_query_set,
|
||||||
'application_query_set': application_query_set}
|
'application_query_set': application_query_set,
|
||||||
|
'user_query_set': QuerySet(workspace_user_role_mapping_model).filter(
|
||||||
|
user_id=user_id, workspace_id=workspace_id)}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def is_x_pack_ee():
|
def is_x_pack_ee():
|
||||||
|
|||||||
@ -12,15 +12,17 @@ from (select application."id"::text,
|
|||||||
application."create_time",
|
application."create_time",
|
||||||
application."update_time"
|
application."update_time"
|
||||||
from application left join "user" on user_id = "user".id
|
from application left join "user" on user_id = "user".id
|
||||||
where application."id" in (select target
|
where "application".id in (select target
|
||||||
from workspace_user_resource_permission
|
from workspace_user_resource_permission
|
||||||
where auth_target_type = 'APPLICATION'
|
where auth_target_type = 'APPLICATION'
|
||||||
and case
|
and case
|
||||||
when auth_type = 'ROLE' then
|
when auth_type = 'ROLE' then
|
||||||
'APPLICATION_READ' in (select permission_id
|
'APPLICATION:READ' in (select (case when user_role_relation.role_id = any (array ['USER']) THEN 'APPLICATION:READ' else role_permission.permission_id END)
|
||||||
from role_permission
|
from role_permission role_permission
|
||||||
where role_id in (select role_id
|
right join user_role_relation user_role_relation
|
||||||
from user_role_relation))
|
on user_role_relation.role_id=role_permission.role_id
|
||||||
|
${user_query_set})
|
||||||
|
|
||||||
else
|
else
|
||||||
'VIEW' = any (permission_list)
|
'VIEW' = any (permission_list)
|
||||||
end)
|
end)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user