mirror of https://github.com/jumpserver/jumpserver
fix: 修复 Playbook 脚本文件问题
parent
e2d14f5e4b
commit
80035e7cb6
|
@ -79,9 +79,13 @@ class PlaybookFileBrowserAPIView(APIView):
|
||||||
}
|
}
|
||||||
protected_files = ['root', 'main.yml']
|
protected_files = ['root', 'main.yml']
|
||||||
|
|
||||||
|
def get_playbook(self, playbook_id):
|
||||||
|
playbook = get_object_or_404(Playbook, id=playbook_id, creator=self.request.user)
|
||||||
|
return playbook
|
||||||
|
|
||||||
def get(self, request, **kwargs):
|
def get(self, request, **kwargs):
|
||||||
playbook_id = kwargs.get('pk')
|
playbook_id = kwargs.get('pk')
|
||||||
playbook = get_object_or_404(Playbook, id=playbook_id)
|
playbook = self.get_playbook(playbook_id)
|
||||||
work_path = playbook.work_dir
|
work_path = playbook.work_dir
|
||||||
file_key = request.query_params.get('key', '')
|
file_key = request.query_params.get('key', '')
|
||||||
if file_key:
|
if file_key:
|
||||||
|
@ -101,7 +105,7 @@ class PlaybookFileBrowserAPIView(APIView):
|
||||||
|
|
||||||
def post(self, request, **kwargs):
|
def post(self, request, **kwargs):
|
||||||
playbook_id = kwargs.get('pk')
|
playbook_id = kwargs.get('pk')
|
||||||
playbook = get_object_or_404(Playbook, id=playbook_id)
|
playbook = self.get_playbook(playbook_id)
|
||||||
work_path = playbook.work_dir
|
work_path = playbook.work_dir
|
||||||
|
|
||||||
parent_key = request.data.get('key', '')
|
parent_key = request.data.get('key', '')
|
||||||
|
@ -157,7 +161,7 @@ class PlaybookFileBrowserAPIView(APIView):
|
||||||
|
|
||||||
def patch(self, request, **kwargs):
|
def patch(self, request, **kwargs):
|
||||||
playbook_id = kwargs.get('pk')
|
playbook_id = kwargs.get('pk')
|
||||||
playbook = get_object_or_404(Playbook, id=playbook_id)
|
playbook = self.get_playbook(playbook_id)
|
||||||
work_path = playbook.work_dir
|
work_path = playbook.work_dir
|
||||||
|
|
||||||
file_key = request.data.get('key', '')
|
file_key = request.data.get('key', '')
|
||||||
|
@ -197,7 +201,7 @@ class PlaybookFileBrowserAPIView(APIView):
|
||||||
|
|
||||||
def delete(self, request, **kwargs):
|
def delete(self, request, **kwargs):
|
||||||
playbook_id = kwargs.get('pk')
|
playbook_id = kwargs.get('pk')
|
||||||
playbook = get_object_or_404(Playbook, id=playbook_id)
|
playbook = self.get_playbook(playbook_id)
|
||||||
work_path = playbook.work_dir
|
work_path = playbook.work_dir
|
||||||
file_key = request.query_params.get('key', '')
|
file_key = request.query_params.get('key', '')
|
||||||
if not file_key:
|
if not file_key:
|
||||||
|
|
Loading…
Reference in New Issue