def get_index_content(catalog, index, searchArgs={}, vocabulary=None): query = copy.deepcopy(searchArgs) try: del(query[index]) except KeyError: pass result = { SHOW_ALL: { 'value': SHOW_ALL, 'count': len(catalog(query)), 'label': _('All'), }, } try: index = catalog.Indexes.get(index, None)._index except AttributeError: return result else: index_values = (x for x in index.keys() if x is not None) for value in index_values: query[index] = value count = len(catalog(query)) label = value try: label = vocabulary.by_value[value].title except (KeyError, AttributeError): pass # label will be = value result[value] = { 'value': value, 'count': count, 'label': label, } return result
def get_basic_criteria(context): return { 'SearchableText': { 'label': _(u'Text Search'), }, 'rmMediaType': { 'label': _(u'Media Types'), 'vocabulary': mediaTypesVocabulary, 'groupable': True, }, RM_TAGS: { 'label': _(u'Tags'), 'vocabulary': tagVocabulary, 'groupable': True, }, 'Creator': { 'label': _(u'Creators'), 'vocabulary': creators_source, 'groupable': True, }, 'relatedPortalTypes': { 'label': _(u'Attached to'), 'vocabulary': portal_types_source, 'groupable': True, }, }
def get_index_content(catalog, name, searchArgs={}, vocabulary=None): query = copy.deepcopy(searchArgs) try: del(query[name]) except KeyError: pass (sum, b_untagged_is_set, b_unassigned_is_set) = calculate_counter_all(catalog, query) result = { SHOW_ALL: { 'value': SHOW_ALL, 'count': sum, 'label': _('All'), }, } try: index = catalog.Indexes.get(name, None)._index except AttributeError: return result else: index_values = (x for x in index.keys() if x is not None) docs = [] for value in index_values: query[name] = value brains = catalog(query) if b_untagged_is_set: brains = filter_brains_with_assigned_tag(brains) if b_unassigned_is_set: brains = filter_brains_with_assigned_uni(brains) count = len(brains) label = value try: label = vocabulary.by_value[value].title except (KeyError, AttributeError): pass # label will be = value result[value] = { 'value': value, 'count': count, 'label': label, } docs.append(brains) # update 'untagged' counter if name == RM_TAGS: result[SHOW_UNTAGGED] = { 'value': SHOW_UNTAGGED, 'count': sum - get_number_of_docs(docs), 'label': _(UNTAGGED), } # update 'unassigned' counter if name == UNIVERSITY_INT_IDS: result[SHOW_UNASSIGNED] = { 'value': SHOW_UNASSIGNED, 'count': sum - get_number_of_docs(docs), 'label': _(UNASSIGNED), } return result
def url(value): if not is_valid_url(value): raise Invalid(_(u"This does not seem to be a valid URL.")) return True
from plone.indexer import indexer from plone.memoize import view from zc.relation.interfaces import ICatalog from zope import component from zope import schema from zope.app.intid.interfaces import IIntIds from zope.component.interfaces import IObjectEvent, ObjectEvent from zope.event import notify from zope.interface import alsoProvides from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm import time DEFAULT_MEDIA_TYPE = 'other_type' mediaTypesVocabulary = SimpleVocabulary([ SimpleTerm(value='publication', title=_(u'Publication')), SimpleTerm(value='document', title=_(u'Document')), SimpleTerm(value='audio', title=_(u'Audio')), SimpleTerm(value='video', title=_(u'Video')), SimpleTerm(value='images', title=_(u'Images')), SimpleTerm(value=DEFAULT_MEDIA_TYPE, title=_(u'Other Type')), ]) media_type_mappings = { 'application/msword': 'document', 'application/pdf': 'document', 'application/rtf': 'document', 'application/vnd.ms-excel': 'document', 'application/vnd.ms-powerpoint': 'document', 'application/vnd.oasis.opendocument.presentation': 'document', 'application/vnd.oasis.opendocument.spreadsheet': 'document', 'application/vnd.oasis.opendocument.text': 'document',