Exemplo n.º 1
0
def reference_outline_view(context, request):

    # Look for moveUp or moveDown in QUERY_STRING, telling us to
    # reorder something
    status_message = None
    subpath = request.params.get('subpath')

    backto = {
        'href': resource_url(context.__parent__, request),
        'title': context.__parent__.title,
        }

    user_can_edit = False
    actions = []
    if has_permission('create', context, request):
        addables = get_folder_addables(context, request)
        if addables is not None:
            actions.extend(addables())
    if has_permission('edit', context, request):
        user_can_edit = True
        actions.append(('Edit', 'edit.html'))
        if subpath:
            direction = request.params['direction']
            status_message = move_subpath(context, subpath, direction)
    if has_permission('delete', context, request):
        actions.append(('Delete', 'delete.html'))
    if has_permission('administer', context, request):
        actions.append(('Advanced', 'advanced.html'))

    page_title = context.title
    api = TemplateAPI(context, request, page_title)

    # Get a layout
    layout_provider = get_layout_provider(context, request)
    layout = layout_provider()

    # provide client data for rendering current tags in the tagbox
    client_json_data = dict(
        tagbox=get_tags_client_data(context, request),
        )

    previous, next = get_previous_next(context, request)

    api.status_message = status_message
    return render_to_response(
        'templates/show_referencemanual.pt',
        dict(api=api,
             actions=actions,
             user_can_edit=user_can_edit,
             head_data=convert_to_script(client_json_data),
             tree=getTree(context, request, api),
             backto=backto,
             layout=layout,
             previous_entry=previous,
             next_entry=next),
        request=request,
        )
Exemplo n.º 2
0
def reference_outline_view(context, request):

    # Look for moveUp or moveDown in QUERY_STRING, telling us to
    # reorder something
    status_message = None
    subpath = request.params.get('subpath')

    backto = {
        'href': resource_url(context.__parent__, request),
        'title': context.__parent__.title,
    }

    user_can_edit = False
    actions = []
    if has_permission('create', context, request):
        addables = get_folder_addables(context, request)
        if addables is not None:
            actions.extend(addables())
    if has_permission('edit', context, request):
        user_can_edit = True
        actions.append(('Edit', 'edit.html'))
        if subpath:
            direction = request.params['direction']
            status_message = move_subpath(context, subpath, direction)
    if has_permission('delete', context, request):
        actions.append(('Delete', 'delete.html'))
    if has_permission('administer', context, request):
        actions.append(('Advanced', 'advanced.html'))

    page_title = context.title
    api = TemplateAPI(context, request, page_title)

    # Get a layout
    layout_provider = get_layout_provider(context, request)
    layout = layout_provider()

    # provide client data for rendering current tags in the tagbox
    client_json_data = dict(tagbox=get_tags_client_data(context, request), )

    previous, next = get_previous_next(context, request)

    api.status_message = status_message
    return render_to_response(
        'templates/show_referencemanual.pt',
        dict(api=api,
             actions=actions,
             user_can_edit=user_can_edit,
             head_data=convert_to_script(client_json_data),
             tree=getTree(context, request, api),
             backto=backto,
             layout=layout,
             previous_entry=previous,
             next_entry=next),
        request=request,
    )
Exemplo n.º 3
0
def show_newsitem_view(context, request):
    backto = {
        'href': resource_url(context.__parent__, request),
        'title': context.__parent__.title,
        }

    actions = []
    if has_permission('edit', context, request):
        actions.append(('Edit', 'edit.html'))
    if has_permission('delete', context, request):
        actions.append(('Delete', 'delete.html'))
    if has_permission('administer', context, request):
        actions.append(('Advanced', 'advanced.html'))

    page_title = context.title
    api = TemplateAPI(context, request, page_title)

    previous, next = get_previous_next(context, request)

    # provide client data for rendering current tags in the tagbox
    client_json_data = dict(
        tagbox = get_tags_client_data(context, request),
        )

    # Display photo
    photo = context.get('photo')
    if photo is not None:
        photo = {
            "url": thumb_url(photo, request, PHOTO_DISPLAY_SIZE),
        }

    # Get a layout
    layout_provider = get_layout_provider(context, request)
    layout = layout_provider('generic')

    ux2_layout = request.layout_manager.layout
    ux2_layout.section_style = None

    return render_to_response(
        'templates/show_newsitem.pt',
        dict(api=api,
             actions=actions,
             attachments=fetch_attachments(context['attachments'], request),
             formfields=api.formfields,
             head_data=convert_to_script(client_json_data),
             backto=backto,
             previous=previous,
             next=next,
             old_layout=layout,
             photo=photo),
        request=request,
        )
Exemplo n.º 4
0
def show_file_view(context, request):

    page_title = context.title
    api = TemplateAPI(context, request, page_title)

    client_json_data = dict(
        tagbox = get_tags_client_data(context, request),
        )

    actions = []
    if has_permission('create', context, request):
        actions.append(
            ('Edit', 'edit.html'),
            )
        actions.append(
            ('Delete', 'delete.html'),
            )

    # If we are in an attachments folder, the backto skips the
    # attachments folder and goes up to the grandparent
    from karl.models.interfaces import IAttachmentsFolder
    from repoze.bfg.traversal import find_interface
    attachments = find_interface(context, IAttachmentsFolder)
    if attachments is not None:
        up_to = context.__parent__.__parent__
    else:
        up_to = context.__parent__
    backto = {
        'href': model_url(up_to, request),
        'title': up_to.title,
        }

    fileinfo = getMultiAdapter((context, request), IFileInfo)
    previous, next = get_previous_next(context, request)

    # Get a layout
    layout_provider = get_layout_provider(context, request)
    layout = layout_provider('community')

    return render_template_to_response(
        'templates/show_file.pt',
        api=api,
        actions=actions,
        fileinfo=fileinfo,
        head_data=convert_to_script(client_json_data),
        backto=backto,
        previous=previous,
        next=next,
        layout=layout,
        )
Exemplo n.º 5
0
def reference_viewall_view(context, request):

    backto = {
        'href': resource_url(context.__parent__, request),
        'title': context.__parent__.title,
        }

    actions = []
    if has_permission('create', context, request):
        addables = get_folder_addables(context, request)
        if addables is not None:
            actions.extend(addables())
    if has_permission('edit', context, request):
        actions.append(('Edit', 'edit.html'))
    if has_permission('delete', context, request):
        actions.append(('Delete', 'delete.html'))
    if has_permission('administer', context, request):
        actions.append(('Advanced', 'advanced.html'))

    page_title = context.title
    api = TemplateAPI(context, request, page_title)

    # Get a layout
    layout_provider = get_layout_provider(context, request)
    old_layout = layout_provider('intranet')

    # provide client data for rendering current tags in the tagbox
    client_json_data = dict(
        tagbox = get_tags_client_data(context, request),
        )

    previous, next = get_previous_next(context, request, 'view_all.html')

    intranet = find_intranet(context)
    if intranet is not None:
        ux2_layout = request.layout_manager.layout
        ux2_layout.section_style = "none"

    return render_to_response(
        'templates/viewall_referencemanual.pt',
        dict(api=api,
             actions=actions,
             head_data=convert_to_script(client_json_data),
             tree=getTree(context, request, api),
             backto=backto,
             old_layout=old_layout,
             previous_entry=previous,
             next_entry=next),
        request=request,
        )
Exemplo n.º 6
0
def show_newsitem_view(context, request):
    backto = {
        'href': resource_url(context.__parent__, request),
        'title': context.__parent__.title,
    }

    actions = []
    if has_permission('edit', context, request):
        actions.append(('Edit', 'edit.html'))
    if has_permission('delete', context, request):
        actions.append(('Delete', 'delete.html'))
    if has_permission('administer', context, request):
        actions.append(('Advanced', 'advanced.html'))

    page_title = context.title
    api = TemplateAPI(context, request, page_title)

    previous, next = get_previous_next(context, request)

    # provide client data for rendering current tags in the tagbox
    client_json_data = dict(tagbox=get_tags_client_data(context, request), )

    # Display photo
    photo = context.get('photo')
    if photo is not None:
        photo = {
            "url": thumb_url(photo, request, PHOTO_DISPLAY_SIZE),
        }

    # Get a layout
    layout_provider = get_layout_provider(context, request)
    layout = layout_provider('generic')

    ux2_layout = request.layout_manager.layout
    ux2_layout.section_style = None

    return render_to_response(
        'templates/show_newsitem.pt',
        dict(api=api,
             actions=actions,
             attachments=fetch_attachments(context['attachments'], request),
             formfields=api.formfields,
             head_data=convert_to_script(client_json_data),
             backto=backto,
             previous=previous,
             next=next,
             old_layout=layout,
             photo=photo),
        request=request,
    )
Exemplo n.º 7
0
def show_newsitem_view(context, request):
    backto = {
        'href': model_url(context.__parent__, request),
        'title': context.__parent__.title,
        }

    actions = []
    if has_permission('create', context, request):
        actions.append(
            ('Edit', 'edit.html')
            )
        actions.append(
            ('Delete', 'delete.html'),
        )

    page_title = context.title
    api = TemplateAPI(context, request, page_title)

    previous, next = get_previous_next(context, request)

    # provide client data for rendering current tags in the tagbox
    client_json_data = dict(
        tagbox = get_tags_client_data(context, request),
        )

    # Display photo
    photo = context.get_photo()
    if photo is not None:
        photo = {
            "url": model_url(photo, request),
        }

    # Get a layout
    layout_provider = get_layout_provider(context, request)
    layout = layout_provider('generic')

    return render_template_to_response(
        'templates/show_newsitem.pt',
        api=api,
        actions=actions,
        attachments=fetch_attachments(context['attachments'], request),
        formfields=api.formfields,
        head_data=convert_to_script(client_json_data),
        backto=backto,
        previous=previous,
        next=next,
        layout=layout,
        photo=photo,
        )
Exemplo n.º 8
0
Arquivo: page.py Projeto: hj91/karl
def show_page_view(context, request):

    backto = {
        'href': resource_url(context.__parent__, request),
        'title': context.__parent__.title,
        }

    actions = []
    if has_permission('edit', context, request):
        actions.append(('Edit', 'edit.html'))
    if has_permission('delete', context, request):
        actions.append(('Delete', 'delete.html'))
    if has_permission('administer', context, request):
        actions.append(('Advanced', 'advanced.html'))

    page_title = context.title
    api = TemplateAPI(context, request, page_title)

    previous, next = get_previous_next(context, request)

    # provide client data for rendering current tags in the tagbox
    client_json_data = dict(
        tagbox = get_tags_client_data(context, request),
        )

    # Get a layout
    community = find_community(context)
    layout_provider = get_layout_provider(context, request)
    if community is not None:
        layout = layout_provider('community')
    else:
        layout = layout_provider('generic')

    ux2_layout = request.layout_manager.layout
    ux2_layout.section_style = "none"
    return render_to_response(
        'templates/show_page.pt',
        dict(api=api,
             actions=actions,
             attachments=fetch_attachments(context['attachments'], request),
             formfields=api.formfields,
             head_data=convert_to_script(client_json_data),
             backto=backto,
             previous_entry=previous,
             next_entry=next,
             old_layout=layout),
        request = request,
        )
Exemplo n.º 9
0
def show_page_view(context, request):

    backto = {
        'href': resource_url(context.__parent__, request),
        'title': context.__parent__.title,
    }

    actions = []
    if has_permission('edit', context, request):
        actions.append(('Edit', 'edit.html'))
    if has_permission('delete', context, request):
        actions.append(('Delete', 'delete.html'))
    if has_permission('administer', context, request):
        actions.append(('Advanced', 'advanced.html'))

    page_title = context.title
    api = TemplateAPI(context, request, page_title)

    previous, next = get_previous_next(context, request)

    # provide client data for rendering current tags in the tagbox
    client_json_data = dict(tagbox=get_tags_client_data(context, request), )

    # Get a layout
    community = find_community(context)
    layout_provider = get_layout_provider(context, request)
    if community is not None:
        layout = layout_provider('community')
    else:
        layout = layout_provider('generic')

    ux2_layout = request.layout_manager.layout
    ux2_layout.section_style = "none"
    return render_to_response(
        'templates/show_page.pt',
        dict(api=api,
             actions=actions,
             attachments=fetch_attachments(context['attachments'], request),
             formfields=api.formfields,
             head_data=convert_to_script(client_json_data),
             backto=backto,
             previous_entry=previous,
             next_entry=next,
             old_layout=layout),
        request=request,
    )
Exemplo n.º 10
0
def show_referencesection_view(context, request):

    backto = {
        'href': model_url(context.__parent__, request),
        'title': context.__parent__.title,
        }

    actions = []
    if has_permission('create', context, request):
        addables = get_folder_addables(context, request)
        if addables is not None:
            actions.extend(addables())
        actions.append(('Edit', 'edit.html'))
        if has_permission('delete', context, request):
            actions.append(('Delete', 'delete.html'))

    page_title = context.title
    api = TemplateAPI(context, request, page_title)

    # Get a layout
    layout_provider = get_layout_provider(context, request)
    layout = layout_provider('intranet')

    previous, next = get_previous_next(context, request)

    # provide client data for rendering current tags in the tagbox
    client_json_data = dict(
        tagbox = get_tags_client_data(context, request),
        )

    return render_template_to_response(
        'templates/show_referencesection.pt',
        api=api,
        actions=actions,
        entries=_get_ordered_listing(context, request),
        head_data=convert_to_script(client_json_data),
        backto=backto,
        previous=previous,
        next=next,
        layout=layout,
        )