Exemple #1
0
def show_profiles_view(context, request):
    system_name = get_setting(context, 'system_name', 'KARL')
    page_title = '%s Profiles' % system_name
    api = TemplateAPI(context, request, page_title)

    # Grab the data for the two listings, main communities and portlet
    search = ICatalogSearch(context)

    query = dict(sort_index='title', interfaces=[IProfile], limit=5)

    titlestartswith = request.params.get('titlestartswith')
    if titlestartswith:
        query['titlestartswith'] = (titlestartswith, titlestartswith)

    num, docids, resolver = search(**query)

    profiles = []
    for docid in docids:
        model = resolver(docid)
        if model is None:
            continue
        profiles.append(model)

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

    return render_to_response(
        'templates/profiles.pt',
        dict(api=api,
             profiles=profiles,
             letters=letter_info),
        request=request,
        )
Exemple #2
0
def report_view(context, request):
    api = TemplateAPI(context, request, context.title)
    peopledir = find_peopledirectory(context)
    section = context.__parent__
    peopledir_tabs = get_tabs(peopledir, request, section.__name__)
    client_json_data = {"grid_data": get_grid_data(context, request)}

    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)
    opensearch_url = resource_url(context, request, "opensearch.xml")

    return dict(
        api=api,
        peopledir=peopledir,
        peopledir_tabs=peopledir_tabs,
        head_data=convert_to_script(client_json_data),
        descriptions=descriptions,
        letters=letter_info,
        print_url=print_url,
        csv_url=csv_url,
        pictures_url=pictures_url,
        qualifiers=qualifiers,
        opensearch_url=opensearch_url,
        actions=get_actions(context, request),
        mailto=_get_mailto(context, peopledir),
    )
Exemple #3
0
def report_view(context, request):
    client_json_data = {
        'grid_data': get_grid_data(context, request),
        }
    api = TemplateAPI(context, request, context.title)
    peopledir = find_peopledirectory(context)
    section = context.__parent__
    peopledir_tabs = get_tabs(peopledir, request, section.__name__)

    mgr = ILetterManager(context)
    letter_info = mgr.get_info(request)
    kw, qualifiers = get_search_qualifiers(request)

    descriptions = get_report_descriptions(context)
    print_url = model_url(context, request, 'print.html', **kw)
    csv_url = model_url(context, request, 'csv', **kw)
    pictures_url = model_url(context, request, 'picture_view.html', **kw)
    opensearch_url = model_url(context, request, 'opensearch.xml')

    return render_template_to_response(
        'templates/people_report.pt',
        api=api,
        peopledir=peopledir,
        peopledir_tabs=peopledir_tabs,
        head_data=convert_to_script(client_json_data),
        descriptions=descriptions,
        letters=letter_info,
        print_url=print_url,
        csv_url=csv_url,
        pictures_url=pictures_url,
        qualifiers=qualifiers,
        opensearch_url=opensearch_url,
        actions=get_actions(context, request),
        )
Exemple #4
0
def show_communities_view(context, request):
    system_name = get_setting(context, 'system_name', 'KARL')
    page_title = '%s Communities' % system_name
    actions = []

    if has_permission('create', context, request):
        actions.append(('Add Community', 'add_community.html'))
    api = TemplateAPI(context, request, page_title)

    # Grab the data for the two listings, main communities and portlet
    communities_path = model_path(context)

    query = dict(
        sort_index='title',
        interfaces=[ICommunity],
        path={'query': communities_path, 'depth': 1},
        allowed={'query': effective_principals(request), 'operator': 'or'},
        )

    titlestartswith = request.params.get('titlestartswith')
    if titlestartswith:
        query['titlestartswith'] = (titlestartswith, titlestartswith)

    batch_info = get_catalog_batch_grid(context, request, **query)

    communities = []
    for community in batch_info['entries']:
        adapted = getMultiAdapter((community, request), ICommunityInfo)
        communities.append(adapted)

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

    my_communities = get_my_communities(context, request)

    return render_template_to_response(
        'templates/communities.pt',
        api=api,
        actions=actions,
        communities=communities,
        my_communities=my_communities,
        batch_info=batch_info,
        letters=letter_info,
        )
Exemple #5
0
def show_profiles_view(context, request):
    """
    This view is basically deprecated.  If there is a people directory present,
    we'll redirect there.
    """
    people = find_peopledirectory(context)
    if people:
        return HTTPFound(request.resource_url(people))

    # No people directory, show basic listing of profiles
    system_name = get_setting(context, 'system_name', 'KARL')
    page_title = '%s Profiles' % system_name
    api = TemplateAPI(context, request, page_title)

    # Grab the data for the two listings, main communities and portlet
    search = ICatalogSearch(context)

    query = dict(sort_index='title', interfaces=[IProfile], limit=5)

    titlestartswith = request.params.get('titlestartswith')
    if titlestartswith:
        query['titlestartswith'] = (titlestartswith, titlestartswith)

    num, docids, resolver = search(**query)

    profiles = []
    for docid in docids:
        model = resolver(docid)
        if model is None:
            continue
        profiles.append(model)

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

    return render_to_response(
        'templates/profiles.pt',
        dict(api=api,
             profiles=profiles,
             letters=letter_info),
        request=request,
        )
Exemple #6
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)
    )
Exemple #7
0
def alpha_removed(obj, event):
    adapter = ILetterManager(obj)
    adapter.delta(-1)
Exemple #8
0
def alpha_added(obj, event):
    adapter = ILetterManager(obj)
    adapter.delta(1)
Exemple #9
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,
    )
Exemple #10
0
        query['texts'] = body
        qualifiers.append('Search for "%s"' % body)

    error = None
    try:
        batch_info = get_catalog_batch_grid(context, request, **query)
    except ParseError, e:
        batch_info = {'entries': [], 'batching_required': False}
        error = _(u'Error: ${message}', mapping={'message': e})

    communities = []
    for community in batch_info['entries']:
        adapted = getMultiAdapter((community, request), ICommunityInfo)
        communities.append(adapted)

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

    view_cookie = request.cookies.get(_VIEW_COOKIE)
    classes = []
    for name, title, description, urlname in _VIEWS:
        classes.append({'name': name,
                        'title': title,
                        'description': description,
                        'href': urlname,
                        'selected': name == view_cookie,
                       })

    actions = []
    if has_permission('create', context, request):
        actions.append((_(u'Add Community'), 'add_community.html'))
Exemple #11
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,
    )
Exemple #12
0
def alpha_removed(obj, event):
    adapter = ILetterManager(obj)
    adapter.delta(-1)
Exemple #13
0
def alpha_added(obj, event):
    adapter = ILetterManager(obj)
    adapter.delta(1)