Commit ea656830f23c3f7439478f295495b88dd4454ba6

Authored by Alexis Koralewski
1 parent 8a9bdc27
Exists in dev

Add creation of new period 2 month before end of current

Showing 1 changed file with 5 additions and 0 deletions   Show diff stats
src/core/pyros_django/scp_mgmt/A_SCP_Manager.py
... ... @@ -169,6 +169,11 @@ class A_SCP_Manager(Agent):
169 169 today = timezone.now().date()
170 170 next_period = Period.objects.next_period()
171 171 # check if next_period has changed
  172 + if next_period is None:
  173 + # Check if we have to create a new period (2 month before end of current exploitation period)
  174 + current_period_end_date = self.period.end_date
  175 + if today <= current_period_end_date - relativedelta(month=2):
  176 + next_period = Period.objects.create(start_date=self.period.end_date)
172 177 if self.period != next_period:
173 178 self.period = next_period
174 179 # get scientific program for next_period
... ...