|
|
@@ -26,15 +26,15 @@ Core::addScript("public/js/markerclusterer.js");
|
|
|
|
|
|
$action = http::value("action", "string");
|
|
|
$target_project_id = http::value("target_project_id");
|
|
|
-$location_ids_json = http::value("location_ids_json", "string");
|
|
|
+$test_ids_json = http::value("test_ids_json", "string");
|
|
|
|
|
|
if($action) {
|
|
|
switch($action) {
|
|
|
case "move-tests":
|
|
|
|
|
|
- $location_ids = json_decode($location_ids_json);
|
|
|
- if(!is_array($location_ids)) {
|
|
|
- $location_ids = [];
|
|
|
+ $test_ids = json_decode($test_ids_json);
|
|
|
+ if(!is_array($test_ids)) {
|
|
|
+ $test_ids = [];
|
|
|
}
|
|
|
|
|
|
$target_project = Project::get($target_project_id);
|
|
|
@@ -46,16 +46,21 @@ if($action) {
|
|
|
throw new RuntimeException("Target project template is not the same as this project.");
|
|
|
}
|
|
|
|
|
|
- $source_tests = Test::query(["location_id" => $location_ids, "project_id" => $id]);
|
|
|
+ $source_tests = Test::query(["id" => $test_ids, "project_id" => $id, "status" => Constraint::notEquals(Test::STATUS_CANCELLED)]);
|
|
|
|
|
|
$source_test_count = count($source_tests);
|
|
|
- $expected_test_count = count($location_ids);
|
|
|
+ $expected_test_count = count($test_ids);
|
|
|
|
|
|
if($source_test_count !== $expected_test_count) {
|
|
|
throw new RuntimeException("Tests do not match number of IDs submitted. $source_test_count $expected_test_count");
|
|
|
}
|
|
|
|
|
|
- $conflicting_tests = Test::query(["location_id" => $location_ids, "project_id" => $target_project_id]);
|
|
|
+ $location_ids = [];
|
|
|
+ foreach($source_tests as $source_test) {
|
|
|
+ $location_ids[] = $source_test->location_id;
|
|
|
+ }
|
|
|
+
|
|
|
+ $conflicting_tests = Test::query(["location_id" => $location_ids, "project_id" => $target_project_id, "status" => Constraint::notEquals(Test::STATUS_CANCELLED)]);
|
|
|
$conflicting_test_count = count($conflicting_tests);
|
|
|
if($conflicting_test_count > 0) {
|
|
|
throw new RuntimeException(__("%d conflicting test(s) for a location was found in the target project. Please remove from the target project and try again.", $conflicting_test_count));
|