From c72397bf8fc8afbf50417659466f0d3681735577 Mon Sep 17 00:00:00 2001
From: Jorrit Schaap <schaap@astron.nl>
Date: Tue, 17 Nov 2020 13:09:02 +0100
Subject: [PATCH] TMSS-190: parse/use 'time.at'

---
 .../scheduling/lib/constraints/template_constraints_v1.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/SAS/TMSS/services/scheduling/lib/constraints/template_constraints_v1.py b/SAS/TMSS/services/scheduling/lib/constraints/template_constraints_v1.py
index c49cfddb7f2..1a4b74c94c3 100644
--- a/SAS/TMSS/services/scheduling/lib/constraints/template_constraints_v1.py
+++ b/SAS/TMSS/services/scheduling/lib/constraints/template_constraints_v1.py
@@ -109,6 +109,10 @@ def can_run_within_timewindow_with_time_constraints(scheduling_unit: models.Sche
     '''evaluate the time contraint(s)'''
     constraints = scheduling_unit.draft.scheduling_constraints_doc
     # TODO: TMSS-244 (and more?), evaluate the constraints in constraints['time']
+    if has_manual_scheduler_constraint(scheduling_unit):
+        at = parser.parse(constraints['time']['at'], ignoretz=True)
+        return at >= lower_bound and at+scheduling_unit.duration <= upper_bound
+
     if 'before' in constraints['time']:
         before = parser.parse(constraints['time']['before'], ignoretz=True)
         return before <= upper_bound-scheduling_unit.duration
@@ -136,6 +140,10 @@ def get_earliest_possible_start_time(scheduling_unit: models.SchedulingUnitBluep
     constraints = scheduling_unit.draft.scheduling_constraints_doc
 
     try:
+        if has_manual_scheduler_constraint(scheduling_unit):
+            at = parser.parse(constraints['time']['at'], ignoretz=True)
+            return at
+
         if 'after' in constraints['time']:
             return parser.parse(constraints['time']['after'], ignoretz=True)
 
-- 
GitLab