Skip to content
Snippets Groups Projects
Commit 39a8720b authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

TMSS-207: handling of start/stop times

parent 6d62f7e2
No related branches found
No related tags found
1 merge request!162Intermediate merge of TMSS-207 to master
......@@ -6,6 +6,8 @@ import os
import logging
logger = logging.getLogger(__name__)
from datetime import datetime, timedelta
from django.db.models import ForeignKey, CharField, DateTimeField, BooleanField, IntegerField, BigIntegerField, \
ManyToManyField, CASCADE, SET_NULL, PROTECT, UniqueConstraint, QuerySet
from django.contrib.postgres.fields import ArrayField, JSONField
......@@ -204,9 +206,14 @@ class Subtask(BasicCommon):
validate_json_against_schema(self.specifications_doc, self.specifications_template.schema)
if self.state.value == SubtaskState.Choices.SCHEDULED.value and self.__original_state.value == SubtaskState.Choices.SCHEDULING.value:
if self.start_time is None or self.stop_time is None:
raise SubtaskSchedulingException("Cannot schedule subtask id=%s when start/stop times are NULL. start_time='%s' stoptime='%s'" %
(self.pk, formatDatetime(self.start_time), formatDatetime(self.stop_time)))
if self.start_time is None:
if self.predecessors.all().count() is 0:
raise SubtaskSchedulingException("Cannot schedule subtask id=%s when start time is 'None'." % (self.pk, ))
else:
self.start_time = datetime.utcnow()
if self.state.value == SubtaskState.Choices.FINISHING.value:
self.stop_time = datetime.utcnow()
super().save(force_insert, force_update, using, update_fields)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment