This commit is contained in:
dingguodong
2021-09-09 18:00:03 +08:00
3 changed files with 15 additions and 10 deletions
+9 -5
View File
@@ -24,10 +24,14 @@ class buildEntry extends Entry
$control->view($buildID);
$data = $this->getData();
if(!$data or (isset($data->status) and $data->message == '404 Not found')) return $this->send404();
if(isset($data->status) and $data->status == 'success') return $this->send(200, $data->data->build);
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
/* Exception handling. */
if(isset($data->status) and $data->status == 'fail')
{
if($data->message == '404 Not found') return $this->send404();
else return $this->sendError(400, $data->message);
}
$this->sendError(400, 'error');
}
@@ -40,10 +44,10 @@ class buildEntry extends Entry
*/
public function put($buildID)
{
$old = $this->loadModel('build')->getByID($buildID);
$oldBuild = $this->loadModel('build')->getByID($buildID);
/* Set $_POST variables. */
$fields = 'type,title,severity,pri,assignedTo,deadline,desc';
$fields = 'execution,product,name,builder,date,scmPath,filePath,desc';
$this->batchSetPost($fields, $oldBuild);
$control = $this->loadController('build', 'edit');
@@ -54,7 +58,7 @@ class buildEntry extends Entry
if(isset($data->result) and $data->result == 'fail') return $this->sendError(400, $data->message);
$build = $this->build->getByID($buildID);
$this->send(200, $this->format($build, 'createdDate:time,editedDate:time,assignedDate:time'));
$this->send(200, $build);
}
/**
+5 -5
View File
@@ -50,20 +50,20 @@ class buildsEntry extends entry
$project = $this->loadModel('project')->getByID($projectID);
if(!$project) return $this->send404();
$fields = 'type,title,severity,pri,assignedTo,deadline,desc';
$fields = 'execution,product,name,builder,date,scmPath,filePath,desc';
$this->batchSetPost($fields);
$control = $this->loadController('build', 'create');
$this->requireFields('type,title,severity');
$this->requireFields('execution,product,name,builder,date');
$control->create($projectID);
$control->create(0,0,$projectID);
$data = $this->getData();
if(isset($data->result) and $data->result == 'fail') return $this->sendError(400, $data->message);
if(isset($data->result) and!isset($data->id)) return $this->sendError(400, $data->message);
if(isset($data->result) and !isset($data->id)) return $this->sendError(400, $data->message);
$build = $this->loadModel('build')->getByID($data->id);
$this->send(201, $this->format($build, 'createdDate:time,editedDate:time,assignedDate:time'));
$this->send(201, $build);
}
}
+1
View File
@@ -305,6 +305,7 @@ class build extends control
}
$link = $this->app->tab == 'project' ? $this->createLink('project', 'build', "projectID=$build->project") : $this->createLink('execution', 'build', "executionID=$build->execution");
if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'success'));
die(js::locate($link, 'parent'));
}
}