Add reclaim assigned tasks button

This commit is contained in:
simon987
2019-03-27 19:35:06 -04:00
parent 470b1b162b
commit ae32cb43d1
9 changed files with 85 additions and 2 deletions

View File

@@ -756,3 +756,35 @@ func (api *WebAPI) HardReset(r *Request) {
},
})
}
func (api *WebAPI) ReclaimAssignedTasks(r *Request) {
pid, err := strconv.ParseInt(r.Ctx.UserValue("id").(string), 10, 64)
if err != nil || pid <= 0 {
r.Json(JsonResponse{
Ok: false,
Message: "Invalid project id",
}, 400)
return
}
sess := api.Session.StartFasthttp(r.Ctx)
manager := sess.Get("manager")
if !isActionOnProjectAuthorized(pid, manager, storage.RoleMaintenance, api.Database) {
r.Json(JsonResponse{
Ok: false,
Message: "Unauthorized",
}, 403)
return
}
res := api.Database.ReclaimAssignedTasks(pid)
r.OkJson(JsonResponse{
Ok: true,
Content: ReclaimAssignedTasksResponse{
AffectedTasks: res,
},
})
}