增加基于时间节点的批量删除deploy接口

pull/103/head
cyl 2020-05-12 22:45:47 +08:00
parent 78c6c9f0e1
commit 16364d729f
2 changed files with 13 additions and 0 deletions

View File

@ -8,4 +8,5 @@ from .views import *
urlpatterns = [
path('request/', RequestView.as_view()),
path('request/<int:r_id>/', RequestDetailView.as_view()),
path('request/batch', RequestBatchView.as_view()),
]

View File

@ -186,3 +186,15 @@ class RequestDetailView(View):
req.reason = form.reason
req.save()
return json_response(error=error)
class RequestBatchView(View):
def delete(self, request):
form, error = JsonParser(
Argument('expire_time', type=str, help="缺少必要参赛"),
).parse(request.body)
if error is None:
DeployRequest.objects.filter(created_at__lt=form.expire_time).delete()
return json_response(error=error)