def remaining_for_date(self, date): # for edits past the sprint end if same_date(date, datetime.date.today()) or date > self.user_story.iteration.end_date: return self.remaining or 0 # find the oldest tasklog that is newer than date and check # what the estimate on this task was then try: log = self.tasklog_set.filter(date__gt=date).order_by('date')[0:1].get() except TaskLog.DoesNotExist: # no tasklog between here and there return self.remaining or 0 else: if log.old_remaining is not None: return log.old_remaining else: # the info isn't there :( # return something almost but not quite useful return self.estimate or 0
def remaining_storypoints(self, date): is_start = same_date(date, self.start_date) return sum(us.size or 0 for us in self.userstory_set.all() if is_start or us.remaining_for_date(date) > 0)