Пример #1
0
def get_projects(request, page_index):
    """ Display all branch names """
    if request.method != 'GET':
        return res.get_template_data(request, 'presenter/not_found.html', {})

    page = Page(PROJECTS_ITEMS_PER_PAGE, page_index)
    projects, page_indices = BluesteelProjectController.get_paginated_projects_as_objects(
        page)

    items = []
    for project in projects:
        obj = {}
        obj['name'] = project['name']
        obj['url'] = {}
        obj['url']['branches'] = ViewUrlGenerator.get_project_branches_url(
            project['id'], BRANCH_COMMIT_DEPTH, 1)
        obj['url']['edit'] = ViewUrlGenerator.get_project_edit_url(
            project['id'])
        items.append(obj)

    pagination = ViewPrepareObjects.prepare_pagination_project(page_indices)

    data = {}
    data['projects'] = items
    data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])
    data['pagination'] = pagination

    return res.get_template_data(request, 'presenter/project_list.html', data)
Пример #2
0
def prepare_project_for_html(project):
    """ Adds information to project objects for template interaction """
    project['url'] = {}
    project['url']['save'] = ViewUrlGenerator.get_save_project_url(
        project['id'])
    project['url']['delete'] = ViewUrlGenerator.get_delete_project_url(
        project['id'])
    project['url']['edit'] = ViewUrlGenerator.get_project_edit_url(
        project['id'])
    return project