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


Python Ticket.get_value_or_default方法代码示例

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


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

示例1: post_process_request

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import get_value_or_default [as 别名]
    def post_process_request(self, req, template, data, content_type):
        if template == 'timeline.html':
            filter_projects = self._filtered_projects(req)
            if not filter_projects: #no filter means likely more than 1 project, so we insert the project name
                filter_projects = [project[1] for project in self.__SmpModel.get_all_projects()]
            
            if filter_projects:               
                filtered_events = []
                tickettypes = ("newticket", "editedticket", "closedticket", "attachment", "reopenedticket")
                self._old_render_fn = []
                self._current_project = []
                self._read_idx = -1
                for event in data['events']:
                    if event['kind'] in tickettypes:
                        resource = event['kind'] == "attachment" and event['data'][0].parent or event['data'][0]
                        if resource.realm == "ticket":
                            ticket = Ticket( self.env, resource.id )   
                            project = ticket.get_value_or_default('project')
                            if project and project in filter_projects:
                                if len(filter_projects) > 1: #only if more than 1 filtered project
                                    #store the old render function and the project to be inserted
                                    self._old_render_fn.append(event['render'])
                                    self._current_project.append(project)
                                    #redirect to our new render function (which will insert the project name)
                                    event['render'] = self._render_ticket_event
                                #add to the list of displayed events
                                filtered_events.append(event)
                        
                    else:
                        filtered_events.append(event)
    
                data['events'] = filtered_events

        return template, data, content_type
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:36,代码来源:timeline.py

示例2: test_validate_ticket_negativevalue_returnstuple

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import get_value_or_default [as 别名]
 def test_validate_ticket_negativevalue_returnstuple(self):
     req = {}
     ticket = Ticket(self.env)
     ticket['estimatedhours'] = '-1'
     self.assertTrue(ticket.get_value_or_default('estimatedhours'))
     msg = _("Please enter a positive value for Estimated Hours")
     self.assertEquals(msg, self.hours_thp.validate_ticket(req, ticket)[0][1])
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:9,代码来源:hours.py

示例3: _get_user_data_

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import get_value_or_default [as 别名]
    def _get_user_data_(self, req, milestone, field, results, fields):
        """Get data grouped by users. Includes extra user info."""
        ats = AgileToolsSystem(self.env)
        sp = SimplifiedPermissions(self.env)

        tickets_json = defaultdict(lambda: defaultdict(dict))

        all_users = []
        user_data = {}
        use_avatar = self.config.get('avatar','mode').lower() != 'off'

        # TODO: allow the task board to respect user groups
        for group, data in sp.group_memberships().items():
            for member in data['members']:
                if member.sid not in user_data:
                    all_users.append(member.sid);
                    user_data[member.sid] = {
                        'name': member.get("name", member.sid),
                        'avatar': use_avatar and req.href.avatar(member.sid) or None
                    }

        def name_for_sid(sid):
            return user_data[sid]["name"] if sid in user_data else sid

        options = [""] + sorted(all_users, key=name_for_sid)

        for result in results:
            ticket = Ticket(self.env, result['id'])
            filtered_result = dict((k, v)
                                   for k, v in result.iteritems()
                                   if k in fields)
            filtered_result['position'] = ats.position(result['id'])
            filtered_result['_changetime'] = to_utimestamp(result['changetime'])
            # we use Trac's to_json() (through add_script_data), so
            # we'll replace any types which can't be json serialised
            for k, v in filtered_result.items():
                if isinstance(v, datetime): filtered_result[k] = pretty_age(v)
            group_field_val = ticket.get_value_or_default(field["name"]) or ""
            tickets_json[group_field_val][result["id"]] = filtered_result

        return (field["name"], tickets_json, options, user_data)
开发者ID:CGI-define-and-primeportal,项目名称:trac-plugin-agiletools,代码行数:43,代码来源:taskboard.py

示例4: _get_standard_data_

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import get_value_or_default [as 别名]
    def _get_standard_data_(self, req, milestone, field, results, fields):
        """Get ticket information when no custom grouped-by method present."""
        ats = AgileToolsSystem(self.env)
        tickets_json = defaultdict(lambda: defaultdict(dict))

        # Allow for the unset option
        options = [""] + [option for option in field["options"]]

        for result in results:
            ticket = Ticket(self.env, result['id'])
            filtered_result = dict((k, v)
                                   for k, v in result.iteritems()
                                   if k in fields)
            filtered_result['position'] = ats.position(result['id'])
            filtered_result['_changetime'] = to_utimestamp(result['changetime'])
            # we use Trac's to_json() (through add_script_data), so
            # we'll replace any types which can't be json serialised
            for k, v in filtered_result.items():
                if isinstance(v, datetime): filtered_result[k] = pretty_age(v)
            group_field_val = ticket.get_value_or_default(field["name"]) or ""
            tickets_json[group_field_val][result["id"]] = filtered_result

        return (field["name"], tickets_json, options)
开发者ID:CGI-define-and-primeportal,项目名称:trac-plugin-agiletools,代码行数:25,代码来源:taskboard.py


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