def prepare_branches_for_html(project_id, branches): """ Prepare branch data adding urls before html """ ret_branches = [] for branch in branches: for commit in branch['commits']: commit['url'] = {} commit['url'][ 'executions'] = ViewUrlGenerator.get_commit_ordered_by_worker_url( commit['id']) branch['url'] = {} branch['url'][ 'single'] = ViewUrlGenerator.get_project_branch_single_url( project_id, branch['id']) branch['url'][ 'links'] = ViewUrlGenerator.get_project_branch_single_links_url( project_id, branch['id']) ret_branches.append(branch) return ret_branches
def get_project_single_branch_links(request, project_id, branch_id): """ Display single branch links """ if request.method != 'GET': return res.get_template_data(request, 'presenter/not_found.html', {}) project_entry = GitProjectEntry.objects.filter(id=project_id).first() if project_entry is None: return res.get_template_data(request, 'presenter/not_found.html', {}) branch_entry = GitBranchEntry.objects.filter( id=branch_id, project=project_entry).first() if branch_entry is None: return res.get_template_data(request, 'presenter/not_found.html', {}) def_entries = BenchmarkDefinitionEntry.objects.all() worker_entries = WorkerEntry.objects.all() links = [] for def_entry in def_entries: definition = {} definition['name'] = def_entry.name definition['id'] = def_entry.id definition['workers'] = [] for worker_entry in worker_entries: worker = {} worker['name'] = worker_entry.name worker['uuid'] = worker_entry.uuid worker[ 'stacked_benchmarks'] = ViewUrlGenerator.get_benchmark_execution_stacked_url( project_id, branch_id, def_entry.id, worker_entry.id, 1) definition['workers'].append(worker) links.append(definition) branch_names_and_orders = GitController.get_branch_names_and_order_values( project_entry) update_order_selection = [] for name_and_order in branch_names_and_orders: obj = {} obj['name'] = name_and_order['name'] obj['order'] = name_and_order['order'] obj['current'] = name_and_order['id'] == branch_entry.id obj['url'] = {} obj['url']['update'] = ViewUrlGenerator.get_branch_update_order_url( branch_id, project_id, obj['order']) update_order_selection.append(obj) data = {} data['branch'] = {} data['branch']['name'] = branch_entry.name data['branch']['order'] = branch_entry.order data['branch']['url'] = {} data['branch']['url'][ 'single'] = ViewUrlGenerator.get_project_branch_single_url( project_id, branch_id) data['branch']['links'] = links data['branch']['update_order_selection'] = update_order_selection data['menu'] = ViewPrepareObjects.prepare_menu_for_html([]) return res.get_template_data(request, 'presenter/project_branch_links.html', data)