def index(request, schedule_id): fromSchedules = request.GET.get('fromschedules', False) reportType = int(request.GET["reporttype"]) weather = Weather(schedule_id) statusDate = GetStatusDate(schedule_id) originalLabel = "Planned dur" newLabel = "Actual dur" if reportType == 2: activities, duration, _ = weather.CalcScheduleDuration( calcType=ReportType.WEATHER_AWARE) activities2, duration2, _ = weather.CalcScheduleDuration( calcType=ReportType.NORMAL) for idx, _ in enumerate(activities): activities2[idx].NewDuration = activities[idx].NewDuration if reportType == 4: # Get the weather aware durations as we want to work backwards from these predictions activities, duration, _ = weather.CalcScheduleDuration( calcType=ReportType.WEATHER_AWARE) for activity in activities: activity.Duration, activity.NewDuration = activity.NewDuration, activity.Duration for activity in weather.activityList: activity.Duration = activity.NewDuration # Get the planned activity durations from the weather aware durations activities2, duration2, _ = weather.CalcScheduleDuration( calcType=ReportType.REVERSE) originalLabel, newLabel = newLabel, originalLabel context = { 'activities': activities, 'activities2': activities2, 'dependencies': weather.dependencyList, 'scheduleId': schedule_id, 'duration': duration, 'duration2': duration2, 'reportType': reportType, 'originalLabel': originalLabel, 'newLabel': newLabel, 'fromSchedules': fromSchedules, 'statusDate': statusDate } template = loader.get_template('report/index.html') return HttpResponse(template.render(context, request))
def CalcReverseReport(scheduleId): """"This is to mark a point on the reverse report that shows where the weather aware duration appears""" # Get the weather aware durations and set these durations for the reverse report weather = Weather(scheduleId) weather.schedule.StatusTypeId = 1 result = weather.CalcScheduleDuration(calcType=ReportType.WEATHER_AWARE) for idx, activity in enumerate(weather.activityList): weather.activityList[idx].Duration = result[0][idx].NewDuration # Get the planned durations from the weather aware durations result = weather.CalcScheduleDuration(calcType=ReportType.REVERSE) return result
def testGanttReverse(self): weather = Weather(2) weather.schedule.StatusTypeId = 1 # get the end date with no weather aware extensions result = weather.CalcScheduleDuration(calcType=ReportType.NORMAL) originalEndDate = result[0][-1].EndDate # now go forwards and then backwards result = weather.CalcScheduleDuration( calcType=ReportType.WEATHER_AWARE) for idx, activity in enumerate(weather.activityList): weather.activityList[idx].Duration = result[0][idx].NewDuration result = weather.CalcScheduleDuration(calcType=ReportType.REVERSE) reversedEndDate = result[0][-1].EndDate self.assertEqual(originalEndDate, reversedEndDate)
def testGanttWeatherStatusdate(self): weather = Weather(2) weather.schedule.StatusDate = datetime.date(2017, 4, 1) weather.schedule.StatusTypeId = 2 result = weather.CalcScheduleDuration() self.assertEqual(result[0][-1].EndDate, datetime.date(2018, 12, 31))
def testGanttWeather(self): weather = Weather(2) weather.schedule.StatusTypeId = 1 activities = weather.CalcScheduleDuration()[0] self.assertEqual(activities[-1].EndDate, datetime.date(2019, 3, 14))