Пример #1
0
def show_folder_view(context, request):

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

    # Now get the data that goes with this


    # Actions
    backto = False
    actions = []
    if has_permission('create', context, request):
        # Allow "policy" to override list of addables in a particular context
        addables = get_folder_addables(context, request)
        if addables is not None:
            actions.extend(addables())

    if not (ICommunityRootFolder.providedBy(context) or
        IIntranetRootFolder.providedBy(context)):
        # Root folders for the tools aren't editable or deletable
        if has_permission('create', context, request):
            actions.append(('Edit', 'edit.html'))
            actions.append(('Delete', 'delete.html'))

        in_intranets = find_interface(context, IIntranets) is not None
        if has_permission('administer', context, request) and in_intranets:
            # admins see an Advanced action that puts markers on a
            # folder.
            actions.append(
                ('Advanced','advanced.html'),
                )
        backto = {
            'href': model_url(context.__parent__, request),
            'title': context.__parent__.title,
            }

    # Only provide atom feed links on root folder.
    if ICommunityRootFolder.providedBy(context):
        feed_url = model_url(context, request, "atom.xml")
    else:
        feed_url = None

    # Folder and tag data for Ajax
    client_json_data = dict(
        filegrid = get_filegrid_client_data(context, request,
                                            start = 0,
                                            limit = 10,
                                            sort_on = 'modified_date',
                                            reverse = True,
                                            ),
        tagbox = get_tags_client_data(context, request),
        )

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

    return render_template_to_response(
        'templates/show_folder.pt',
        api=api,
        actions=actions,
        head_data=convert_to_script(client_json_data),
        backto=backto,
        layout=layout,
        feed_url=feed_url,
        )