Previous topic

stalker.core.models.ReferenceMixin

Next topic

stalker.core.models.StatusMixin

This Page

stalker.core.models.ScheduleMixin

Inheritance diagram of stalker.core.models.ScheduleMixin

class stalker.core.models.ScheduleMixin(start_date=None, due_date=None, duration=None, **kwargs)[source]

Bases: object

Adds schedule info to the mixed in class.

Adds schedule information like start_date, due_date and duration. There are theree parameters to initialize a class with ScheduleMixin, which are, start_date, due_date and duration. Only two of them are enough to initialize the class. The preceeding order for the parameters is as follows:

start_date > due_date > duration

So if all of the parameters are given only the start_date and the due_date will be used and the duration will be calculated accordingly. In any other conditions the missing parameter will be calculated from the following table:

start_date due_date duration DEFAULTS
     

start_date = datetime.date.today()

duration = datetime.timedelta(days=10)

due_date = start_date + duration

X    

duration = datetime.timedelta(days=10)

due_date = start_date + duration

X X   duration = due_date - start_date
X   X due_date = start_date + duration
X X X duration = due_date - start_date
  X X start_date = due_date - duration
  X  

duration = datetime.timedelta(days=10)

start_date = due_date - duration

    X

start_date = datetime.date.today()

due_date = start_date + duration

The date attributes can be managed with timezones. Follow the Python idioms shown in the documentation of datetime

Parameters:
  • start_date (datetime.datetime) – the start date of the entity, should be a datetime.date instance, the start_date is the pin point for the date calculation. In any condition if the start_date is available then the value will be preserved. If start_date passes the due_date the due_date is also changed to a date to keep the timedelta between dates. The default value is datetime.date.today()
  • due_date (datetime.datetime or datetime.timedelta) – the due_date of the entity, should be a datetime.date instance, when the start_date is changed to a date passing the due_date, then the due_date is also changed to a later date so the timedelta between the dates is kept.
  • duration (datetime.timedelta) – The duration of the entity. It is a datetime.timedelta instance. The default value is read from the defaults module. See the table above for the initialization rules.
__init__(start_date=None, due_date=None, duration=None, **kwargs)[source]

Methods

__init__(**kwargs[, start_date, due_date, ...])