Răsfoiți Sursa

Set new due date when moving tests from one project to another

Alan Lam 1 an în urmă
părinte
comite
a67ed95d09
1 a modificat fișierele cu 9 adăugiri și 0 ștergeri
  1. 9 0
      controllers/project.php

+ 9 - 0
controllers/project.php

@@ -4,6 +4,8 @@
  * @var int $id
  * @var int $id
  */
  */
 
 
+use Carbon\CarbonImmutable;
+
 $project = Project::get($id);
 $project = Project::get($id);
 if(!$project) {
 if(!$project) {
 	throw new RuntimeException("Project not found.");
 	throw new RuntimeException("Project not found.");
@@ -73,9 +75,16 @@ if($action) {
 			}
 			}
 
 
 			// OK at this point
 			// OK at this point
+			$dt_new_due = CarbonImmutable::now(TIMEZONE)->addDays(7);
 
 
 			foreach($source_tests as $source_test) {
 			foreach($source_tests as $source_test) {
+				$dt_deadline = $target_project->getDateTimeDeadline();
+
+				/** @var CarbonImmutable $dt_due */
+				$dt_due = min($dt_deadline, $dt_new_due);
+
 				$source_test->project_id = $target_project_id;
 				$source_test->project_id = $target_project_id;
+				$source_test->dts_due = $dt_due->utc()->toDateTimeString();
 				$source_test->commit();
 				$source_test->commit();
 			}
 			}