def get_benchmark_definition_edit(request, definition_id):
    """ Returns html for the benchmark definition edit page """
    data = {}
    data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])
    data['controls'] = get_definition_controls()

    def_entry = BenchmarkDefinitionController.get_benchmark_definition(definition_id)

    if def_entry is None:
        return res.get_template_data(request, 'presenter/not_found.html', data)

    obj = def_entry
    obj['url'] = {}
    obj['url']['save'] = ViewUrlGenerator.get_save_benchmark_definition_url(definition_id)
    obj['url']['delete'] = ViewUrlGenerator.get_confirm_delete_benchmark_def_url(definition_id)
    obj['url']['project_info'] = ViewUrlGenerator.get_editable_projects_info_url()
    obj['layout_selection'] = get_layout_selection(def_entry['layout']['id'])
    obj['project_selection'] = get_project_selection(def_entry['layout']['id'], def_entry['project']['id'])

    names_and_sel = []
    count = 0
    for name in obj['priority']['names']:
        nas = {}
        nas['name'] = name
        nas['selected'] = obj['priority']['current'] == count
        count = count +1
        names_and_sel.append(nas)
    obj['priority']['names'] = names_and_sel


    data['definition'] = obj

    return res.get_template_data(request, 'presenter/benchmark_definition_edit.html', data)
def get_benchmark_definition(request, definition_id):
    """ Returns html for the benchmark definition page """
    data = {}
    data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])
    data['controls'] = get_definition_controls()

    def_entry = BenchmarkDefinitionController.get_benchmark_definition(definition_id)

    if def_entry is None:
        return res.get_template_data(request, 'presenter/not_found.html', data)

    obj = def_entry
    obj['url'] = {}
    obj['url']['edit'] = ViewUrlGenerator.get_edit_benchmark_definition_url(definition_id)
    obj['url']['duplicate'] = ViewUrlGenerator.get_duplicate_benchmark_definition_url(definition_id)
    obj['url']['project_info'] = ViewUrlGenerator.get_editable_projects_info_url()
    obj['layout_selection'] = get_layout_selection(def_entry['layout']['id'])
    obj['project_selection'] = get_project_selection(def_entry['layout']['id'], def_entry['project']['id'])

    # Translate priority number to name.
    obj['priority']['name'] = obj['priority']['names'][obj['priority']['current']]

    data['definition'] = obj

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