1. def expand_macro(self, formatter, name, content):
  2. # prepare options
  3. req = formatter.req
  4. options, query_args = parse_options(self.env.get_db_cnx(), content, copy.copy(DEFAULT_OPTIONS))
  5. if not options['startdate']:
  6. raise TracError("No start date specified!")
  7. # minimum time frame is one day
  8. if (options['startdate'] >= options['enddate']):
  9. options['enddate'] = options['startdate'] + timedelta(days=1)
  10. # consider user conditions
  11. original_query_args = copy.deepcopy(query_args)
  12. if options['condfield'] and options['cond']:
  13. query_args[options['condfield']] = options['cond']
  14. # calculate data
  15. timetable = self._calculate_timetable(options, query_args, req, self.estimation_field, 0)
  16. timetable_2 = {}
  17. # remove weekends
  18. if not options['weekends']:
  19. for date in timetable.keys():
  20. if date.weekday() >= 5:
  21. del timetable[date]
  22. if (options['graph2_field']):
  23. # consider user conditions
  24. query_args = original_query_args
  25. if options['graph2_condfield'] and options['graph2_cond']:
  26. query_args[options['graph2_condfield']] = options['graph2_cond']
  27. # the estimation field will not be accumulated for the days when the ticket has been closed
  28. always_consider_value = 1
  29. if options['graph2_field'] == self.estimation_field:
  30. always_consider_value = 0
  31. # calculate data
  32. timetable_2 = self._calculate_timetable(options, query_args, req, options['graph2_field'], always_consider_value)
  33. # remove weekends
  34. if not options['weekends']:
  35. for date in timetable_2.keys():
  36. if date.weekday() >= 5:
  37. del timetable_2[date]
  38. ...snip...