Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Commit

Permalink
Merge pull request #277 from Bidaya0/fix/feature/issue-247
Browse files Browse the repository at this point in the history
fix delete logic
  • Loading branch information
Bidaya0 authored Dec 2, 2021
2 parents 6daf9fe + 9b0060f commit 0a55e1f
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions iast/views/scan_strategys.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,17 +169,18 @@ def create(self, request):
),
)
def update(self, request, pk):
ser = ScanCreateSerializer(data=request.data,partial=True)
ser = ScanCreateSerializer(data=request.data, partial=True)
try:
if ser.is_valid(True):
pass
except ValidationError as e:
return R.failure(data=e.detail)
if ser.validated_data.get('content',None):
ser.validated_data['content'] = ','.join([str(i) for i in ser.validated_data['content']])
if ser.validated_data.get('content', None):
ser.validated_data['content'] = ','.join(
[str(i) for i in ser.validated_data['content']])
users = self.get_auth_users(request.user)
obj = IastStrategyUser.objects.filter(
pk=pk,user__in=users).update(**ser.validated_data)
pk=pk, user__in=users).update(**ser.validated_data)
return R.success(msg='update success')

@extend_schema_with_envcheck(
Expand All @@ -196,7 +197,9 @@ def destory(self, request, pk):
if checkusing(scan):
return R.failure(msg='someproject is using this scan strategy')
try:
IastStrategyUser.objects.filter(pk=pk).update(status=-1)
IastStrategyUser.objects.filter(
pk=pk,
user__in=self.get_auth_users(request.user)).update(status=-1)
return R.success(msg='delete success')
except Exception as e:
logger.error(e)
Expand Down

0 comments on commit 0a55e1f

Please sign in to comment.