Skip to content

Commit

Permalink
feat: dataset documents rename permission
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhouhaoJiang committed Jul 4, 2024
1 parent 82f5778 commit a515120
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions api/controllers/console/datasets/datasets_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -964,10 +964,11 @@ class DocumentRenameApi(DocumentResource):
@account_initialization_required
@marshal_with(document_fields)
def post(self, dataset_id, document_id):
# The role of the current user in the ta table must be admin or owner
if not current_user.is_admin_or_owner:
# The role of the current user in the ta table must be admin, owner, editor, or dataset_operator
if not current_user.is_dataset_editor:
raise Forbidden()

dataset = DatasetService.get_dataset(dataset_id)
DatasetService.check_dataset_operator_permission(current_user, dataset)
parser = reqparse.RequestParser()
parser.add_argument('name', type=str, required=True, nullable=False, location='json')
args = parser.parse_args()
Expand Down
2 changes: 1 addition & 1 deletion api/services/dataset_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ def check_dataset_permission(dataset, user):

@staticmethod
def check_dataset_operator_permission(user: Account = None, dataset: Dataset = None):
if dataset.permission == 'only_me' or dataset.permission == 'all_team_members':
if dataset.permission == 'only_me':
if dataset.created_by != user.id:
raise NoPermissionError('You do not have permission to access this dataset.')

Expand Down

0 comments on commit a515120

Please sign in to comment.