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


Python ProjectIssue.get_multi_by方法代码示例

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


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

示例1: index

# 需要导入模块: from vilya.models.project_issue import ProjectIssue [as 别名]
# 或者: from vilya.models.project_issue.ProjectIssue import get_multi_by [as 别名]
        def index(request):
            if list_type == 'search':
                key_word = request.get_form_var('q', None)
                if not key_word:
                    return self._index(request)

            milestone_number = request.get_form_var('milestone')
            state = request.get_form_var('state', 'open')
            page = request.get_form_var('page', 1)
            project_name = self.proj_name
            user = request.user
            project = self.project
            order = get_order_type(request, 'project_issues_order')  # noqa 目前支持list_type = repo的sort_by
            n_open_issues = project.n_open_issues
            n_closed_issues = project.n_closed_issues
            n_everyone_issues = 0
            n_assigned_issues = 0
            n_created_issues = 0
            n_pages = 0
            selected_tag_names = request.get_form_var('tags', '')
            start = ISSUES_COUNT_PER_PAGE * (int(page) - 1)
            limit = ISSUES_COUNT_PER_PAGE

            is_closed_tab = None if state == "open" else True
            issue_list = []
            total_issues = 0
            opts = dict(project=project, state=state, start=start,
                        limit=limit, order=order)
            if selected_tag_names:
                selected_tag_names = selected_tag_names.split(',')
                tags = filter(None, [TagName.get_project_issue_tag(
                    name, project) for name in selected_tag_names])
                opts['tags'] = tags
            show_tags = project.get_group_tags(selected_tag_names)

            if milestone_number:
                milestone = Milestone.get_by_project(
                    project, number=milestone_number)
                opts['milestone'] = milestone

            # FIXME: why user or list_type ?
            if user or list_type in ('repo', 'search'):
                if list_type == 'search':
                    # FIXME: search with assigned or creator
                    search_result = IssueSearch.search_a_phrase(
                        key_word, self.project.id,
                        size=n_open_issues + n_closed_issues,
                        state=state) or []
                    search_issue_ids = []
                    if search_result and not search_result.get('error'):
                        search_issue_ids = [
                            id for id, in SearchEngine.decode(
                                search_result, ['issue_id'])]
                    # FIXME: is search_issue_ids int[]?
                    opts['issue_ids'] = search_issue_ids
                elif list_type == 'created_by':
                    opts['creator'] = user
                elif list_type == 'assigned':
                    opts['assignee'] = user
                # FIXME: update n_closed_issues & n_open_issues
                multi_dict = ProjectIssue.get_multi_by(**opts)
                issue_list = multi_dict['issues']
                total_issues = multi_dict['total']

                if user:
                    if list_type == 'repo':
                        n_assigned_issues = user.get_n_assigned_issues_by_project(project.id, state)  # noqa
                        n_created_issues = user.get_n_created_issues_by_project(project.id, state)  # noqa
                    elif list_type == 'created_by':
                        n_assigned_issues = user.get_n_assigned_issues_by_project(project.id, state)  # noqa
                        n_created_issues = total_issues
                    elif list_type == 'assigned':
                        n_assigned_issues = total_issues
                        n_created_issues = user.get_n_created_issues_by_project(project.id, state)  # noqa
                    elif list_type == 'search' and search_issue_ids:
                        n_assigned_issues = ProjectIssue.get_n_by_issue_ids_and_assignee_id(  # noqa
                            search_issue_ids, state, user.name)
                        n_created_issues = ProjectIssue.get_n_by_issue_ids_and_creator_id(  # noqa
                            search_issue_ids, state, user.name)
                n_pages = (total_issues - 1) / ISSUES_COUNT_PER_PAGE + 1

            # tags 的选择只会改变选中的filter的显示issue数
            if list_type in ('repo', 'search'):
                n_everyone_issues = total_issues
            else:
                n_everyone_issues = n_open_issues \
                    if state == "open" else n_closed_issues
            return st('issue/issues.html', **locals())
开发者ID:000fan000,项目名称:code,代码行数:90,代码来源:issue.py


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