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


Python TicketModule._populate方法代码示例

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


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

示例1: _implementation

# 需要导入模块: from trac.ticket.web_ui import TicketModule [as 别名]
# 或者: from trac.ticket.web_ui.TicketModule import _populate [as 别名]
        def _implementation(db):
            tkt = Ticket(self.env, ticket_id)
            tm = TicketModule(self.env)
            req.args[field] = new_value
            tm._populate(req, tkt, plain_fields=True)

            changes, problems = tm.get_ticket_changes(req, tkt, "btn_save")

            if problems:
                raise ValueError(problems)

            tm._apply_ticket_changes(tkt, changes)
            valid = tm._validate_ticket(req, tkt, force_collision_check=True)
            if not valid:
                raise ValueError(req.chrome['warnings'])
            else:
                tkt.save_changes(req.authname, "", when=datetime.now(utc))
开发者ID:CGI-define-and-primeportal,项目名称:trac-plugin-agiletools,代码行数:19,代码来源:taskboard.py

示例2: do_save

# 需要导入模块: from trac.ticket.web_ui import TicketModule [as 别名]
# 或者: from trac.ticket.web_ui.TicketModule import _populate [as 别名]
        def do_save(db):
            tm = TicketModule(self.env)
            req.args["milestone"] = milestone

            if ts:
                req.args["ts"] = ts
                
            tm._populate(req, ticket, plain_fields=True)

            changes, problems = tm.get_ticket_changes(req, ticket, "btn_save")

            if problems:
                raise ValueError(problems)

            tm._apply_ticket_changes(ticket, changes)
            valid = tm._validate_ticket(req, ticket, force_collision_check=True)
            if not valid:
                raise ValueError(req.chrome['warnings'])
            else:
                ticket.save_changes(req.authname, "", when=datetime.now(utc))
开发者ID:CGI-define-and-primeportal,项目名称:trac-plugin-agiletools,代码行数:22,代码来源:backlog.py

示例3: _do_save

# 需要导入模块: from trac.ticket.web_ui import TicketModule [as 别名]
# 或者: from trac.ticket.web_ui.TicketModule import _populate [as 别名]
    def _do_save(self, req, db, milestone):
        if milestone.exists:
            req.perm(milestone.resource).require('MILESTONE_MODIFY')
        else:
            req.perm(milestone.resource).require('MILESTONE_CREATE')
        
        ticket_module = TicketModule(self.env)
        ticket_module._populate(req, milestone.ticket, False)
        if not milestone.exists:
            reporter_id = get_reporter_id(req, 'author')
            milestone.ticket.values['reporter'] = reporter_id

        action = req.args.get('action', 'leave')

        field_changes, problems = ticket_module.get_ticket_changes(req, milestone.ticket,
                                    action)
        if problems:
            for problem in problems:
                add_warning(req, problem)
                add_warning(req,
                            tag(tag.p('Please review your configuration, '
                                      'probably starting with'),
                                tag.pre('[trac]\nworkflow = ...\n'),
                                tag.p('in your ', tag.tt('trac.ini'), '.'))
                            )

        ticket_module._apply_ticket_changes(milestone.ticket, field_changes)

        old_name = milestone.name
        new_name = milestone.ticket['summary']
        
        milestone.name = new_name
        milestone.description = milestone.ticket['description']

        due = req.args.get('duedate', '')
        milestone.due = due and parse_date(due, tzinfo=req.tz) or None
        milestone.ticket['duedate']=milestone.due and str(to_timestamp(milestone.due)) or None

        completed = req.args.get('completedate', '')
        retarget_to = req.args.get('target')

        # Instead of raising one single error, check all the constraints and
        # let the user fix them by going back to edit mode showing the warnings
        warnings = []
        def warn(msg):
            add_warning(req, msg)
            warnings.append(msg)

        # -- check the name
        if new_name:
            if new_name != old_name:
                # check that the milestone doesn't already exists
                # FIXME: the whole .exists business needs to be clarified
                #        (#4130) and should behave like a WikiPage does in
                #        this respect.
                try:
                    other_milestone = StructuredMilestone(self.env, new_name, db)
                    warn(_('Milestone "%(name)s" already exists, please '
                           'choose another name', name=new_name))
                except ResourceNotFound:
                    pass
        else:
            warn(_('You must provide a name for the milestone.'))

        # -- check completed date
        if action in MilestoneSystem(self.env).starting_action:
            milestone.ticket['started'] = str(to_timestamp(datetime.now(utc)))
        if action in MilestoneSystem(self.env).completing_action:
            milestone.completed = datetime.now(utc)
            
        if warnings:
            return self._render_editor(req, db, milestone)
        
        # -- actually save changes
        if milestone.exists:
            cnum = req.args.get('cnum')
            replyto = req.args.get('replyto')
            internal_cnum = cnum
            if cnum and replyto: # record parent.child relationship
                internal_cnum = '%s.%s' % (replyto, cnum)

            now = datetime.now(utc)
            milestone.save_changes(get_reporter_id(req, 'author'),
                                         req.args.get('comment'), when=now,
                                         cnum=internal_cnum)
            # eventually retarget opened tickets associated with the milestone
            if 'retarget' in req.args and completed:
                cursor = db.cursor()
                cursor.execute("UPDATE ticket SET milestone=%s WHERE "
                               "milestone=%s and status != 'closed'",
                                (retarget_to, old_name))
                self.env.log.info('Tickets associated with milestone %s '
                                  'retargeted to %s' % (old_name, retarget_to))
        else:
            milestone.insert()
        db.commit()

        add_notice(req, _('Your changes have been saved.'))
        jump_to = req.args.get('jump_to', 'roadmap')
        if jump_to=='roadmap':
#.........这里部分代码省略.........
开发者ID:esogs,项目名称:IttecoTracPlugin,代码行数:103,代码来源:roadmap.py


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