Esempio n. 1
0
def report_view(context, request, pictures=False):
    api = TemplateAPI(context, request, context.title)
    peopledir = find_peopledirectory(context)
    section = context.__parent__
    section_name = section.__name__
    while section and not IPeopleSection.providedBy(section):
        section = section.__parent__
    if section:
        section_name = section.__name__
    peopledir_tabs = get_tabs(peopledir, request, section_name)
    report_data = get_grid_data(context, request)
    
    # ux2 slickgrid only
    widgets = {
        'peoplegrid': report_data['slickgrid_info']['widget_options'], 
        #{
            ##'loadData': [],   ##     search_folder(context, request,
                ##from_=0,
                ##to=_pre_fetch,
                ##sort_col='modified',
                ##sort_dir=-1,
                # XXX hint from ux1
                ##_raw_get_container_batch=_raw_get_container_batch,
                #),
            ##'url': resource_url(context, request, 'peoplegrid.json'),
            #},
        }




    batch = report_data['batch']
    if pictures:
        rows = profile_photo_rows(batch['entries'], request, api)
    else:
        rows = None
    del(report_data['batch']) # non-json serializable
    client_json_data = {'grid_data': report_data}


    descriptions = get_report_descriptions(context)
    mgr = ILetterManager(context)
    letter_info = mgr.get_info(request)

    kw, qualifiers = get_search_qualifiers(request)
    print_url = resource_url(context, request, 'print.html', **kw)
    csv_url = resource_url(context, request, 'csv', **kw)
    pictures_url = resource_url(context, request, 'picture_view.html', **kw)
    tabular_url = resource_url(context, request, **kw)
    opensearch_url = resource_url(context, request, 'opensearch.xml')
    mailto=_get_mailto(context, peopledir)

    formats = [   # ux2
        {'name': 'tabular',
         'selected': not pictures,
         'bs-icon': 'icon-th-list',
         'url': tabular_url,
         'title': 'Tabular View',
         'description': 'Show table'},
        {'name': 'picture',
         'selected': pictures,
         'bs-icon': 'icon-th',
         'url': pictures_url,
         'title': 'Picture View',
         'description': 'Show pictures'}
    ]

    actions = [
        {'name': 'print', 'title': 'Print',
         'description': 'Print this report', 'bs-icon': 'icon-print',
         'url': request.resource_url(context, 'print.html')},
        {'name': 'csv', 'title': 'Export as CSV',
         'description': 'Export this report as CSV', 'bs-icon': 'icon-download',
         'url': request.resource_url(context, 'csv')}]

    if mailto:
        actions.insert(0, {
            'name': 'email', 'title': 'Email', 'bs-icon': 'icon-envelope',
            'description': 'Email', 'url': mailto})

    if opensearch_url:
        actions.insert(0, {
            'name': 'opensearch', 'title': 'Opensearch',
            'bs-icon': 'icon-search',
            'description': 'Add KARL People Search to your browser toolbar',
            'url': "javascript:window.external.AddSearchProvider('%s');" %
                   opensearch_url})

    return dict(
        api=api,   # deprecated in ux2
        peopledir=peopledir,   # deprecated in ux2
        peopledir_tabs=peopledir_tabs, # deprecated in ux2
        context_tools=peopledir_tabs,
        head_data=convert_to_script(client_json_data), # deprecated in ux2
        report_data=report_data, # ux2
        batch_info=batch, # deprecated in ux2
        batch=batch, # ux2
        rows=rows,
        descriptions=descriptions,
        letters=letter_info,
        formats=formats, # ux2
        report_actions=actions, # ux2
        print_url=print_url,        # deprecated in ux2
        csv_url=csv_url,            # deprecated in ux2
        pictures_url=pictures_url,  # deprecated in ux2
        tabular_url=tabular_url,    # deprecated in ux2
        qualifiers=qualifiers,      # deprecated in ux2
        opensearch_url=opensearch_url, # deprecated in ux2
        actions=get_actions(context, request),
        mailto=mailto,              # deprecated in ux2
        widgets=widgets, # ux2 with karlgrid (slickgrid)
    )
Esempio n. 2
0
def report_view(context, request, pictures=False):
    api = TemplateAPI(context, request, context.title)
    peopledir = find_peopledirectory(context)
    section = context.__parent__
    section_name = section.__name__
    while section and not IPeopleSection.providedBy(section):
        section = section.__parent__
    if section:
        section_name = section.__name__
    peopledir_tabs = get_tabs(peopledir, request, section_name)

    # make the max limit here ridiculously huge so the frontend can just deal
    # with rendering all of the data. this should scale fairly well up to
    # quite large datasets (several thousand if not tens of thousands) -- if
    # it starts becoming an issue, then the limit will need to be reduced, and
    # the client lib updated to handle the paging interaction with the backend
    report_data = get_grid_data(context, request, limit=2147483647)

    batch = report_data['batch']
    if pictures:
        rows = profile_photo_rows(batch['entries'], request, api)
    else:
        rows = None
    del(report_data['batch']) # non-json serializable
    client_json_data = {'grid_data': report_data}


    descriptions = get_report_descriptions(context)
    mgr = ILetterManager(context)
    letter_info = mgr.get_info(request)

    kw, qualifiers = get_search_qualifiers(request)
    print_url = resource_url(context, request, 'print.html', **kw)
    csv_url = resource_url(context, request, 'csv', **kw)
    pictures_url = resource_url(context, request, 'picture_view.html', **kw)
    tabular_url = resource_url(context, request, **kw)
    opensearch_url = resource_url(context, request, 'opensearch.xml')
    mailto=_get_mailto(context, peopledir)

    actions = [
        {'name': 'print', 'title': 'Print',
         'description': 'Print this report', 'bs-icon': 'icon-print',
         'url': request.resource_url(context, 'print.html')},
        {'name': 'csv', 'title': 'Export as CSV',
         'description': 'Export this report as CSV', 'bs-icon': 'icon-download',
         'url': request.resource_url(context, 'csv')}]

    if mailto:
        actions.insert(0, {
            'name': 'email', 'title': 'Email', 'bs-icon': 'icon-envelope',
            'description': 'Email', 'url': mailto})

    if opensearch_url:
        actions.insert(0, {
            'name': 'opensearch', 'title': 'Opensearch',
            'bs-icon': 'icon-search',
            'description': 'Add KARL People Search to your browser toolbar',
            'url': "javascript:window.external.AddSearchProvider('%s');" %
                   opensearch_url})

    return dict(
        api=api,
        peopledir=peopledir,
        peopledir_tabs=peopledir_tabs,
        context_tools=peopledir_tabs,
        batch_info=batch,
        head_data=convert_to_script(client_json_data),
        rows=rows,
        descriptions=descriptions,
        letters=letter_info,
        print_url=print_url,
        csv_url=csv_url,
        pictures_url=pictures_url,
        tabular_url=tabular_url,
        qualifiers=qualifiers,
        opensearch_url=opensearch_url,
        actions=get_actions(context, request),
        mailto=mailto,
    )
Esempio n. 3
0
def report_view(context, request, pictures=False):
    api = TemplateAPI(context, request, context.title)
    peopledir = find_peopledirectory(context)
    section = context.__parent__
    section_name = section.__name__
    while section and not IPeopleSection.providedBy(section):
        section = section.__parent__
    if section:
        section_name = section.__name__
    peopledir_tabs = get_tabs(peopledir, request, section_name)
    report_data = get_grid_data(context, request)

    # ux2 slickgrid only
    widgets = {
        'peoplegrid': report_data['slickgrid_info']['widget_options'],
        #{
        ##'loadData': [],   ##     search_folder(context, request,
        ##from_=0,
        ##to=_pre_fetch,
        ##sort_col='modified',
        ##sort_dir=-1,
        # XXX hint from ux1
        ##_raw_get_container_batch=_raw_get_container_batch,
        #),
        ##'url': resource_url(context, request, 'peoplegrid.json'),
        #},
    }

    batch = report_data['batch']
    if pictures:
        rows = profile_photo_rows(batch['entries'], request, api)
    else:
        rows = None
    del (report_data['batch'])  # non-json serializable
    client_json_data = {'grid_data': report_data}

    descriptions = get_report_descriptions(context)
    mgr = ILetterManager(context)
    letter_info = mgr.get_info(request)

    kw, qualifiers = get_search_qualifiers(request)
    print_url = resource_url(context, request, 'print.html', **kw)
    csv_url = resource_url(context, request, 'csv', **kw)
    pictures_url = resource_url(context, request, 'picture_view.html', **kw)
    tabular_url = resource_url(context, request, **kw)
    opensearch_url = resource_url(context, request, 'opensearch.xml')
    mailto = _get_mailto(context, peopledir)

    formats = [  # ux2
        {
            'name': 'tabular',
            'selected': not pictures,
            'bs-icon': 'icon-th-list',
            'url': tabular_url,
            'title': 'Tabular View',
            'description': 'Show table'
        }, {
            'name': 'picture',
            'selected': pictures,
            'bs-icon': 'icon-th',
            'url': pictures_url,
            'title': 'Picture View',
            'description': 'Show pictures'
        }
    ]

    actions = [{
        'name': 'print',
        'title': 'Print',
        'description': 'Print this report',
        'bs-icon': 'icon-print',
        'url': request.resource_url(context, 'print.html')
    }, {
        'name': 'csv',
        'title': 'Export as CSV',
        'description': 'Export this report as CSV',
        'bs-icon': 'icon-download',
        'url': request.resource_url(context, 'csv')
    }]

    if mailto:
        actions.insert(
            0, {
                'name': 'email',
                'title': 'Email',
                'bs-icon': 'icon-envelope',
                'description': 'Email',
                'url': mailto
            })

    if opensearch_url:
        actions.insert(
            0, {
                'name':
                'opensearch',
                'title':
                'Opensearch',
                'bs-icon':
                'icon-search',
                'description':
                'Add KARL People Search to your browser toolbar',
                'url':
                "javascript:window.external.AddSearchProvider('%s');" %
                opensearch_url
            })

    return dict(
        api=api,  # deprecated in ux2
        peopledir=peopledir,  # deprecated in ux2
        peopledir_tabs=peopledir_tabs,  # deprecated in ux2
        context_tools=peopledir_tabs,
        head_data=convert_to_script(client_json_data),  # deprecated in ux2
        report_data=report_data,  # ux2
        batch_info=batch,  # deprecated in ux2
        batch=batch,  # ux2
        rows=rows,
        descriptions=descriptions,
        letters=letter_info,
        formats=formats,  # ux2
        report_actions=actions,  # ux2
        print_url=print_url,  # deprecated in ux2
        csv_url=csv_url,  # deprecated in ux2
        pictures_url=pictures_url,  # deprecated in ux2
        tabular_url=tabular_url,  # deprecated in ux2
        qualifiers=qualifiers,  # deprecated in ux2
        opensearch_url=opensearch_url,  # deprecated in ux2
        actions=get_actions(context, request),
        mailto=mailto,  # deprecated in ux2
        widgets=widgets,  # ux2 with karlgrid (slickgrid)
    )
Esempio n. 4
0
def report_view(context, request, pictures=False):
    api = TemplateAPI(context, request, context.title)
    peopledir = find_peopledirectory(context)
    section = context.__parent__
    section_name = section.__name__
    while section and not IPeopleSection.providedBy(section):
        section = section.__parent__
    if section:
        section_name = section.__name__
    peopledir_tabs = get_tabs(peopledir, request, section_name)
    report_data = get_grid_data(context, request)

    batch = report_data['batch']
    if pictures:
        rows = profile_photo_rows(batch['entries'], request, api)
    else:
        rows = None
    del (report_data['batch'])  # non-json serializable
    client_json_data = {'grid_data': report_data}

    descriptions = get_report_descriptions(context)
    mgr = ILetterManager(context)
    letter_info = mgr.get_info(request)

    kw, qualifiers = get_search_qualifiers(request)
    print_url = resource_url(context, request, 'print.html', **kw)
    csv_url = resource_url(context, request, 'csv', **kw)
    pictures_url = resource_url(context, request, 'picture_view.html', **kw)
    tabular_url = resource_url(context, request, **kw)
    opensearch_url = resource_url(context, request, 'opensearch.xml')
    mailto = _get_mailto(context, peopledir)

    actions = [{
        'name': 'print',
        'title': 'Print',
        'description': 'Print this report',
        'bs-icon': 'icon-print',
        'url': request.resource_url(context, 'print.html')
    }, {
        'name': 'csv',
        'title': 'Export as CSV',
        'description': 'Export this report as CSV',
        'bs-icon': 'icon-download',
        'url': request.resource_url(context, 'csv')
    }]

    if mailto:
        actions.insert(
            0, {
                'name': 'email',
                'title': 'Email',
                'bs-icon': 'icon-envelope',
                'description': 'Email',
                'url': mailto
            })

    if opensearch_url:
        actions.insert(
            0, {
                'name':
                'opensearch',
                'title':
                'Opensearch',
                'bs-icon':
                'icon-search',
                'description':
                'Add KARL People Search to your browser toolbar',
                'url':
                "javascript:window.external.AddSearchProvider('%s');" %
                opensearch_url
            })

    return dict(
        api=api,
        peopledir=peopledir,
        peopledir_tabs=peopledir_tabs,
        context_tools=peopledir_tabs,
        batch_info=batch,
        head_data=convert_to_script(client_json_data),
        rows=rows,
        descriptions=descriptions,
        letters=letter_info,
        print_url=print_url,
        csv_url=csv_url,
        pictures_url=pictures_url,
        tabular_url=tabular_url,
        qualifiers=qualifiers,
        opensearch_url=opensearch_url,
        actions=get_actions(context, request),
        mailto=mailto,
    )
Esempio n. 5
0
def report_view(context, request, pictures=False):
    api = TemplateAPI(context, request, context.title)
    peopledir = find_peopledirectory(context)
    section = context.__parent__
    section_name = section.__name__
    while section and not IPeopleSection.providedBy(section):
        section = section.__parent__
    if section:
        section_name = section.__name__
    peopledir_tabs = get_tabs(peopledir, request, section_name)

    # make the max limit here ridiculously huge so the frontend can just deal
    # with rendering all of the data. this should scale fairly well up to
    # quite large datasets (several thousand if not tens of thousands) -- if
    # it starts becoming an issue, then the limit will need to be reduced, and
    # the client lib updated to handle the paging interaction with the backend
    report_data = get_grid_data(context, request, limit=2147483647)

    batch = report_data['batch']
    if pictures:
        rows = profile_photo_rows(batch['entries'], request, api)
    else:
        rows = None
    del (report_data['batch'])  # non-json serializable
    client_json_data = {'grid_data': report_data}

    descriptions = get_report_descriptions(context)
    mgr = ILetterManager(context)
    letter_info = mgr.get_info(request)

    kw, qualifiers = get_search_qualifiers(request)
    print_url = resource_url(context, request, 'print.html', **kw)
    csv_url = resource_url(context, request, 'csv', **kw)
    pictures_url = resource_url(context, request, 'picture_view.html', **kw)
    tabular_url = resource_url(context, request, **kw)
    opensearch_url = resource_url(context, request, 'opensearch.xml')
    mailto = _get_mailto(context, peopledir)

    actions = [{
        'name': 'print',
        'title': 'Print',
        'description': 'Print this report',
        'bs-icon': 'icon-print',
        'url': request.resource_url(context, 'print.html')
    }, {
        'name': 'csv',
        'title': 'Export as CSV',
        'description': 'Export this report as CSV',
        'bs-icon': 'icon-download',
        'url': request.resource_url(context, 'csv')
    }]

    if mailto:
        actions.insert(
            0, {
                'name': 'email',
                'title': 'Email',
                'bs-icon': 'icon-envelope',
                'description': 'Email',
                'url': mailto
            })

    if opensearch_url:
        actions.insert(
            0, {
                'name':
                'opensearch',
                'title':
                'Opensearch',
                'bs-icon':
                'icon-search',
                'description':
                'Add KARL People Search to your browser toolbar',
                'url':
                "javascript:window.external.AddSearchProvider('%s');" %
                opensearch_url
            })

    return dict(
        api=api,
        peopledir=peopledir,
        peopledir_tabs=peopledir_tabs,
        context_tools=peopledir_tabs,
        batch_info=batch,
        head_data=convert_to_script(client_json_data),
        rows=rows,
        descriptions=descriptions,
        letters=letter_info,
        print_url=print_url,
        csv_url=csv_url,
        pictures_url=pictures_url,
        tabular_url=tabular_url,
        qualifiers=qualifiers,
        opensearch_url=opensearch_url,
        actions=get_actions(context, request),
        mailto=mailto,
    )