当前位置: 首页>>代码示例>>Python>>正文


Python Milestone.build_tree方法代码示例

本文整理汇总了Python中trac.ticket.model.Milestone.build_tree方法的典型用法代码示例。如果您正苦于以下问题:Python Milestone.build_tree方法的具体用法?Python Milestone.build_tree怎么用?Python Milestone.build_tree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在trac.ticket.model.Milestone的用法示例。


在下文中一共展示了Milestone.build_tree方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: process_request

# 需要导入模块: from trac.ticket.model import Milestone [as 别名]
# 或者: from trac.ticket.model.Milestone import build_tree [as 别名]
    def process_request(self, req):
        """Collect the data needed for a burndown chart and pass to JavaScript. 
        If the original request was via AJAX we use to_json, otherwise
        we return data via add_script_data.

        Remember that our data reflects how a project looked at the end of a 
        day - so if the ticket_bi_historical table has 20 opens tickets on 
        the 1st December, that were 20 open tickets at the end of that day.
        """

        # Get milestone object and all child milestones
        # we already know it exists, as we checked in the match_request()
        milestone = Milestone(self.env, req.args['id'])
        tree = Milestone.build_tree(self.env)
        all_milestones = [m.name for m in tree.find(milestone.name).traverse()]

        # If anyone request burndownchart/milestone_id not via AJAX
        # and not with a format argument (eg when printing) , we redirect to 
        # milestone/milestonename, as we need to load pre_process_request first
        XMLHttp = req.get_header('X-Requested-With') == 'XMLHttpRequest'
        if not XMLHttp and 'format' not in req.args:
            req.redirect(req.href.milestone(milestone.name))

        # Calculate series of dates used to render the burn down charts
        start = self.get_start_date(req, milestone)
        end = self.get_end_date(milestone)
        day_before_start = start - timedelta(days=1)
        dates = self.dates_inbetween(day_before_start, end)

        # Open a database connection
        self.log.debug('Connecting to the database to retrieve chart data')
        db = self.env.get_read_db()

        # If no metric data is posted, use the project default self.unit_value
        metric = req.args.get('metric', self.unit_value)

        # Remaining Effort (aka burndown) Curve
        remaining_effort_args = [db, all_milestones, day_before_start, end]

        burndown_series = []
        if metric == 'tickets':
            burndown_series = self.tickets_open_between_dates(*remaining_effort_args)
        elif metric == 'hours':
            burndown_series = self.hours_remaining_between_dates(*remaining_effort_args)
        elif metric == 'points':
            burndown_series = self.points_remaining_between_dates(*remaining_effort_args)

        # If we don't have any burndown data send a message and stop
        if not burndown_series:
            data = {'result': False}
            # For ajax request
            if XMLHttp:
                req.send(to_json(data), 'text/json')
            else:
                return 'burndown_print.html', data, None

        # Team Effort Curve
        team_effort = self.team_effort_curve(db, metric, all_milestones,
                                                day_before_start, end,
                                                self.dates_as_strings(dates))

        # Ideal Curve (unit value doesnt matter)
        if self.ideal_value == 'fixed':
            original_estimate = burndown_series[0][1]

        ideal_data = self.ideal_curve(original_estimate, day_before_start, 
                                      self.get_due_date(milestone))

        data = {
            'burndowndata': burndown_series,
            'teameffortdata' : team_effort,
            'idealcurvedata': ideal_data,
            'milestone_name': milestone.name,
            'start_date': str(day_before_start),
            'effort_units': metric,
            'yaxix_label': metric.title(),
            'result' : True,
        }

        # we need some logic to work out the end date on the xAxis
        data['due_date'] =  (self.get_due_date(milestone)).strftime("%Y-%m-%d")

        # Ajax request
        if XMLHttp:
            kwargs = { 'daysback':0,
                       'ticket':'on',
                       'ticket_details': 'on',
                       'ticket_milestone_%s' % Milestone._hash_name(milestone.name): 'on'
                     }
            data.update({
              'timeline_url': req.href.timeline(kwargs),
              'print_burndown': False,
              'render_burndown': True,
            })

            req.send(to_json(data), 'text/json')

        # Normal request (eg the print friendly page)
        else:
            if req.args.get('format') == 'print':
#.........这里部分代码省略.........
开发者ID:CGI-define-and-primeportal,项目名称:trac-plugin-burndownchart,代码行数:103,代码来源:burndown.py


注:本文中的trac.ticket.model.Milestone.build_tree方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。