Exemplo n.º 1
0
def get_project_branches(request, project_id, commit_depth, page_index):
    """ Display all the branches of a project """
    if request.method != 'GET':
        return res.get_template_data(request, 'presenter/not_found.html', {})

    project_entry = BluesteelProjectEntry.objects.filter(id=project_id).first()
    if project_entry is None:
        return res.get_template_data(request, 'presenter/not_found.html', {})

    project = GitProjectEntry.objects.filter(
        id=project_entry.git_project.id).first()
    if project is None:
        return res.get_template_data(request, 'presenter/not_found.html', {})

    page = Page(PROJECTS_BRANCHES_PER_PAGE, page_index)
    branches, page_indices = BluesteelProjectController.get_project_git_branch_data(
        page, project, commit_depth)
    branches = BenchmarkExecutionController.add_bench_exec_completed_to_branches(
        branches)

    pagination = ViewPrepareObjects.prepare_pagination_branches(
        project_entry.id, commit_depth, page_indices)

    data = {}
    data['branches'] = ViewPrepareObjects.prepare_branches_for_html(
        project_entry.id, branches)
    data['url'] = {}
    data['url'][
        'change_merge_target'] = ViewUrlGenerator.get_change_merge_target_url(
            project_entry.id)
    data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])
    data['pagination'] = pagination

    return res.get_template_data(request, 'presenter/project_branches.html',
                                 data)
Exemplo n.º 2
0
def get_project_single_branch(request, project_id, branch_id):
    """ Display all the branches of a project """
    if request.method != 'GET':
        return res.get_template_data(request, 'presenter/not_found.html', {})

    project_entry = BluesteelProjectEntry.objects.filter(id=project_id).first()
    if project_entry is None:
        return res.get_template_data(request, 'presenter/not_found.html', {})

    git_project = GitProjectEntry.objects.filter(
        id=project_entry.git_project.id).first()
    if git_project is None:
        return res.get_template_data(request, 'presenter/not_found.html', {})

    branch_entry = GitBranchEntry.objects.filter(id=branch_id,
                                                 project=git_project).first()
    if branch_entry is None:
        return res.get_template_data(request, 'presenter/not_found.html', {})

    branches = BluesteelProjectController.get_project_single_git_branch_data(
        git_project, branch_entry, BRANCH_COMMIT_DEPTH)
    branches = BenchmarkExecutionController.add_bench_exec_completed_to_branches(
        branches)

    data = {}
    data['branches'] = ViewPrepareObjects.prepare_branches_for_html(
        project_entry.id, branches)
    data['url'] = {}
    data['url'][
        'change_merge_target'] = ViewUrlGenerator.get_change_merge_target_url(
            project_entry.id)
    data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])

    return res.get_template_data(request, 'presenter/project_branches.html',
                                 data)