Skip to content

Commit

Permalink
fix: datasets patch error
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhouhaoJiang committed Jun 28, 2024
1 parent cbc096a commit 53c035e
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions api/controllers/console/datasets/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ def get(self):
else:
item['embedding_available'] = True

if item.get('permission') == 'partial_members':
part_users_list = DatasetPermissionService.get_dataset_partial_member_list(item['id'])
item.update({'partial_member_list': part_users_list})
else:
item.update({'partial_member_list': []})

response = {
'data': data,
'has_more': len(datasets) == limit,
Expand All @@ -108,8 +114,8 @@ def post(self):
help='Invalid indexing technique.')
args = parser.parse_args()

# The role of the current user in the ta table must be admin, owner, or editor
if not current_user.is_editor:
# The role of the current user in the ta table must be admin, owner, or editor, or dataset_operator
if not current_user.is_dataset_editing:
raise Forbidden()

try:
Expand Down Expand Up @@ -140,6 +146,10 @@ def get(self, dataset_id):
except services.errors.account.NoPermissionError as e:
raise Forbidden(str(e))
data = marshal(dataset, dataset_detail_fields)
if data.get('permission') == 'partial_members':
part_users_list = DatasetPermissionService.get_dataset_partial_member_list(dataset_id_str)
data.update({'partial_member_list': part_users_list})

# check embedding setting
provider_manager = ProviderManager()
configurations = provider_manager.get_configurations(
Expand Down Expand Up @@ -204,7 +214,7 @@ def patch(self, dataset_id):
args = parser.parse_args()
data = request.get_json()
# The role of the current user in the ta table must be admin, owner, or editor
if not current_user.is_dataset_editing_role:
if not current_user.is_dataset_editing:
raise Forbidden()

dataset = DatasetService.update_dataset(
Expand Down

0 comments on commit 53c035e

Please sign in to comment.