Esempio n. 1
0
def handle_institution_creation(obj, event):
    current_lang = api.portal.get_default_language()[:2]
    institution_title = obj.title

    # Configure manager group & local permissions
    group_id = format_institution_managers_group_id(obj)
    group_title = "{0} Institution Managers".format(institution_title)
    api.group.create(groupname=group_id, title=group_title)
    obj.manage_setLocalRoles(group_id, ["Institution Manager", "Contributor"])

    # Create meetings faceted folder
    meetings = create_faceted_folder(
        obj, translate(_(u"Meetings"), target_language=current_lang))
    alsoProvides(meetings, IMeetingsFolder)
    IFacetedLayout(meetings).update_layout("faceted-preview-meeting")

    # Create items faceted folder
    items = create_faceted_folder(
        obj, translate(_(u"Decisions"), target_language=current_lang))
    alsoProvides(items, IItemsFolder)
    IFacetedLayout(items).update_layout("faceted-preview-meeting-items")

    request = getRequest()
    if request:  # Request can be `None` during test setup
        request.response.redirect(obj.absolute_url())
Esempio n. 2
0
def set_faceted_list_items(context):
    portal_catalog = api.portal.get_tool('portal_catalog')
    brains = portal_catalog.unrestrictedSearchResults(
        object_provides=IFacetedNavigable.__identifier__)
    for brain in brains:
        obj = brain.getObject()
        if IFacetedLayout(obj).layout == 'faceted-preview-items':
            IFacetedLayout(obj).update_layout('faceted-list-items')
            logger.info('{0} faceted layout update'.format('/'.join(
                obj.getPhysicalPath())))
Esempio n. 3
0
def upgrade_to_1004_daterange_widget(context):
    from eea.facetednavigation.subtypes.interfaces import IFacetedNavigable
    from eea.facetednavigation.layout.interfaces import IFacetedLayout
    from eea.facetednavigation.interfaces import ICriteria
    from eea.facetednavigation.widgets.storage import Criterion

    brains = api.content.find(object_provides=IFacetedNavigable.__identifier__)
    layouts = ("faceted-agenda-ungrouped-view-items",
               "faceted-agenda-view-items")
    for brain in brains:
        obj = brain.getObject()
        if IFacetedLayout(obj).layout not in layouts:
            continue
        criterion = ICriteria(obj)
        for key, criteria in criterion.items():
            if criteria.get("widget") != "daterange":
                continue
            if criteria.get("usePloneDateFormat") is True:
                continue
            logger.info("Upgrade daterange widget for faceted {0}".format(obj))
            position = criterion.criteria.index(criteria)
            values = criteria.__dict__
            values["usePloneDateFormat"] = True
            criterion.criteria[position] = Criterion(**values)
            criterion.criteria._p_changed = 1
Esempio n. 4
0
def on_create(obj, event):
    faceted_subtyper = obj.unrestrictedTraverse("@@faceted_subtyper")
    faceted_subtyper.enable()

    faceted_exportimport = obj.unrestrictedTraverse("@@faceted_exportimport")
    xml = obj.unrestrictedTraverse("classification-folders-faceted.xml")()
    faceted_exportimport._import_xml(import_file=xml)

    IFacetedLayout(obj).update_layout("faceted-table-items")
Esempio n. 5
0
def setFacetedNavigation(folder, request, force=False):
    subtyper = getMultiAdapter((folder, request), name=u'faceted_subtyper')
    if (subtyper.is_faceted or not subtyper.can_enable) and not force: return
    subtyper.enable()
    urlTool = plone.api.portal.get_tool(name='portal_url')

    IFacetedLayout(folder).update_layout('faceted_sciencedata_view')
    noLongerProvides(folder, IHidePloneLeftColumn)
    noLongerProvides(folder, IHidePloneRightColumn)
Esempio n. 6
0
def activate_faceted_tasks_listing(task_container, event):
    """
    Set the listing tasks faceted view on the faceted tasks container.
    """
    if hasattr(aq_base(task_container), 'checkCreationFlag'):
        if task_container.checkCreationFlag():
            return

    if IFacetedNavigable.providedBy(task_container):
        return
    elif IPossibleFacetedNavigable.providedBy(task_container):
        subtyper = task_container.unrestrictedTraverse('@@faceted_subtyper')
        subtyper.enable()
        IFacetedLayout(task_container).update_layout('list_tasks')
        task_container.manage_delProperties(['layout'])
Esempio n. 7
0
    def setUp(self):
        """ """
        self.portal = self.layer['portal']
        self.request = self.layer['request']

        # create a folder and enable faceted navigation on it
        eea_folder = api.content.create(
            type='Folder',
            id='eea_folder',
            title='EEA Folder',
            container=self.portal
        )
        alsoProvides(eea_folder, IBatchActionsMarker)
        eea_folder.reindexObject()
        eea_folder.restrictedTraverse('@@faceted_subtyper').enable()
        IFacetedLayout(eea_folder).update_layout('faceted-table-items')
        self.eea_folder = eea_folder
Esempio n. 8
0
def _set_faceted_view(folder, faceted_config_path, schedule_configs, default_collection=None):
    """
    """
    annotations = IAnnotations(folder)
    key = 'imio.schedule.schedule_configs'
    annotations[key] = [cfg.UID() for cfg in schedule_configs]

    subtyper = folder.restrictedTraverse('@@faceted_subtyper')
    if not subtyper.is_faceted:
        subtyper.enable()
        folder.restrictedTraverse('@@faceted_settings').toggle_left_column()
        IFacetedLayout(folder).update_layout('faceted-table-items')
        folder.unrestrictedTraverse('@@faceted_exportimport').import_xml(
            import_file=open(faceted_config_path)
        )

    default_collection = default_collection or schedule_configs[0].dashboard_collection
    _updateDefaultCollectionFor(folder, default_collection.UID())
Esempio n. 9
0
def on_create(obj, event):
    notify(FacetedWillBeEnabledEvent(obj))
    alsoProvides(obj, IClassificationFacetedNavigable)
    if not IDisableSmartFacets.providedBy(obj):
        alsoProvides(obj, IDisableSmartFacets)
    if not IHidePloneRightColumn.providedBy(obj):
        alsoProvides(obj, IHidePloneRightColumn)
    notify(FacetedEnabledEvent(obj))

    if HAS_QUERYNEXTPREV:
        from collective.querynextprev.interfaces import INextPrevNotNavigable

        alsoProvides(obj, INextPrevNotNavigable)

    IFacetedLayout(obj).update_layout("folder-listing-view")

    # We use a method to allow override by subfolder
    obj._increment_internal_reference()
Esempio n. 10
0
    def migrate(self, old, new):
        new_path = "/".join(new.getPhysicalPath())
        for iface in interfaces:
            if iface.providedBy(old):
                alsoProvides(new, iface)
                logger.warn("{0} also provides {1}".format(new_path, str(iface)))

        if old.getConstrainTypesMode() != 0:
            behaviour = ISelectableConstrainTypes(new)
            behaviour.setConstrainTypesMode(1)
            if old.getConstrainTypesMode() == 1:
                behaviour.setLocallyAllowedTypes(old.getLocallyAllowedTypes())
                behaviour.setImmediatelyAddableTypes(old.getImmediatelyAddableTypes())

        if IFacetedNavigable.providedBy(old):
            criteria = Criteria(new)
            criteria._update(ICriteria(old).criteria)
            IFacetedLayout(new).update_layout('faceted-table-items')
            logger.warn("Added faceted criteria and layout to {0}".format(new_path))
Esempio n. 11
0
def setFacetedNavigation(folder, request, force=False):
    subtyper = getMultiAdapter((folder, request), name=u'faceted_subtyper')
    if (subtyper.is_faceted or not subtyper.can_enable) and not force: return
    subtyper.enable()
    urlTool = plone.api.portal.get_tool(name='portal_url')
    path = '/' + '/'.join(urlTool.getRelativeContentPath(folder))
    criteria = ICriteria(folder)
    for cid in criteria.keys():
        criteria.delete(cid)
    criteria.add(
        'checkbox', 'left', 'default',
        title=u'Organ',
        hidden=False,
        index='indicatedBodySystems',
        operator='or',
        vocabulary=u'eke.biomarker.IndicatedOrgansVocabulary',
        count=False,
        maxitems=0,
        sortreversed=False,
        hidezerocount=False,
    )
    criteria.add('resultsperpage', 'bottom', 'default', title='Results per page', hidden=True, start=0, end=50, step=5, default=20)
    criteria.add('sorting', 'bottom', 'default', title='Sort on', hidden=True, default='sortable_title')
    criteria.add(
        'checkbox', 'bottom', 'default',
        title='Obj provides',
        hidden=True,
        index='object_provides',
        operator='or',
        vocabulary=u'eea.faceted.vocabularies.ObjectProvides',
        default=[IBiomarker.__identifier__],
        count=False,
        maxitems=0,
        sortreversed=False,
        hidezerocount=False
    )
    criteria.add('path', 'bottom', 'default', title='Path Search', hidden=True, index='path', default=path)
    criteria.add('text', 'top', 'default', title=u'Search', hidden=False, index='SearchableText', count=False,
        onlyallelements=True)
    IFacetedLayout(folder).update_layout('faceted_biomarkers_view')
    noLongerProvides(folder, IHidePloneLeftColumn)
    noLongerProvides(folder, IHidePloneRightColumn)
Esempio n. 12
0
def _enableFacetedDashboardFor(obj,
                               xmlpath=None,
                               show_left_column=True,
                               default_UID=None,
                               enable_faceted=True,
                               update_layout=True):
    """Enable a faceted view on obj and import a
       specific xml if given p_xmlpath."""
    # already a faceted?
    if enable_faceted and IFacetedNavigable.providedBy(obj):
        logger.error("Faceted navigation is already enabled for '%s'" %
                     '/'.join(obj.getPhysicalPath()))
        return

    # do not go further if xmlpath does not exist
    if xmlpath and not path.exists(xmlpath):
        raise Exception("Specified xml file '%s' doesn't exist" % xmlpath)
    # .enable() here under will redirect to enabled faceted
    # we cancel this, safe previous RESPONSE status and location
    response_status = obj.REQUEST.RESPONSE.getStatus()
    response_location = obj.REQUEST.RESPONSE.getHeader('location')
    if enable_faceted:
        obj.unrestrictedTraverse('@@faceted_subtyper').enable()

    if update_layout:
        # use correct layout in the faceted
        IFacetedLayout(obj).update_layout('faceted-table-items')
    # show the left portlets
    if show_left_column and IHidePloneLeftColumn.providedBy(obj):
        noLongerProvides(obj, IHidePloneLeftColumn)
    # import configuration
    if xmlpath:
        obj.unrestrictedTraverse('@@faceted_exportimport').import_xml(
            import_file=open(xmlpath))
    # define default collection UID
    if default_UID:
        _updateDefaultCollectionFor(obj, default_UID)
    obj.reindexObject()
    obj.REQUEST.RESPONSE.status = response_status
    obj.REQUEST.RESPONSE.setHeader('location', response_location or '')
Esempio n. 13
0
 def __call__(self):
     layout = self.request.get('layout', None)
     err = IFacetedLayout(self.context).update_layout(layout)
     if not err:
         return self._redirect('Layout changed')
     return self._redirect(err)
Esempio n. 14
0
def createMembersListSearchPage(portal):
    '''Create the members list page'''
    # New in profile version 1 (software version 1.0.2):
    request = portal.REQUEST
    if 'members-list' in portal.objectIds():
        portal.manage_delObjects('members-list')
    membersList = portal[portal.invokeFactory('Folder', 'members-list')]
    membersList.setTitle('Members List')
    membersList.setDescription('A directory of the people that comprise EDRN.')
    membersList.setExcludeFromNav(True)
    _doPublish(membersList, getToolByName(portal, 'portal_workflow'))
    subtyper = getMultiAdapter((membersList, request), name=u'faceted_subtyper')
    subtyper.enable()
    layout = IFacetedLayout(membersList)
    layout.update_layout('folder_listing')
    criteria = ICriteria(membersList)
    for cid in criteria.keys():
        criteria.delete(cid)
    criteria.add('resultsperpage', 'bottom', 'default', title='Results per page', hidden=True, start=0, end=50, step=5, default=20)
    criteria.add('sorting', 'bottom', 'default', title='Sort on', hidden=True, default='sortable_title')
    criteria.add(
        'checkbox', 'bottom', 'default',
        title='Obj provides',
        hidden=True,
        index='object_provides',
        operator='or',
        vocabulary=u'eea.faceted.vocabularies.ObjectProvides',
        default=[IPerson.__identifier__],
        count=False,
        maxitems=0,
        sortreversed=False,
        hidezerocount=False
    )
    criteria.add(
        'checkbox', 'left', 'default',
        title='Investigator',
        hidden=False,
        index='piUID',
        operator='or',
        vocabulary=u'eke.site.PrincipalInvestigators',
        count=False,
        maxitems=4,
        sortreversed=False,
        hidezerocount=False
    )
    criteria.add(
        'checkbox', 'left', 'default',
        title='Type',
        index='investigatorStatus',
        operator='or',
        vocabulary=u'eke.site.NotPeons',
        count=True,
        maxitems=0,
        sortreversed=False,
        hidezerocount=False
    )
    criteria.add(
        'checkbox', 'left', 'default',
        title='Institution',
        hidden=False,
        index='siteName',
        operator='or',
        vocabulary=u'eke.site.SitesNames',
        count=True,
        maxitems=4,
        sortreversed=False,
        hidezerocount=False
    )
    criteria.add(
        'checkbox', 'left', 'default',
        title='Member Type',
        hidden=False,
        index='memberType',
        operator='or',
        vocabulary=u'eke.site.MemberType',
        count=True,
        maxitems=20,
        sortreversed=False,
        hidezerocount=False
    )
    criteria.add('criteria', 'top', 'default', title='Current Search')
    membersList.reindexObject()
Esempio n. 15
0
def createMembersListSearchPage(portal):
    '''Create the members list page'''
    # New in profile version 1 (software version 1.0.2):
    request = portal.REQUEST
    if 'members-list' in portal.objectIds():
        portal.manage_delObjects('members-list')
    membersList = portal[portal.invokeFactory('Folder', 'members-list')]
    membersList.setTitle('Members List')
    membersList.setDescription('A directory of the people that comprise EDRN.')
    membersList.setExcludeFromNav(True)
    _doPublish(membersList, getToolByName(portal, 'portal_workflow'))
    subtyper = getMultiAdapter((membersList, request),
                               name=u'faceted_subtyper')
    subtyper.enable()
    layout = IFacetedLayout(membersList)
    layout.update_layout('folder_listing')
    criteria = ICriteria(membersList)
    for cid in criteria.keys():
        criteria.delete(cid)
    criteria.add('resultsperpage',
                 'bottom',
                 'default',
                 title='Results per page',
                 hidden=True,
                 start=0,
                 end=50,
                 step=5,
                 default=20)
    criteria.add('sorting',
                 'bottom',
                 'default',
                 title='Sort on',
                 hidden=True,
                 default='sortable_title')
    criteria.add('checkbox',
                 'bottom',
                 'default',
                 title='Obj provides',
                 hidden=True,
                 index='object_provides',
                 operator='or',
                 vocabulary=u'eea.faceted.vocabularies.ObjectProvides',
                 default=[IPerson.__identifier__],
                 count=False,
                 maxitems=0,
                 sortreversed=False,
                 hidezerocount=False)
    criteria.add('checkbox',
                 'left',
                 'default',
                 title='Investigator',
                 hidden=False,
                 index='piUID',
                 operator='or',
                 vocabulary=u'eke.site.PrincipalInvestigators',
                 count=False,
                 maxitems=4,
                 sortreversed=False,
                 hidezerocount=False)
    criteria.add('checkbox',
                 'left',
                 'default',
                 title='Type',
                 index='investigatorStatus',
                 operator='or',
                 vocabulary=u'eke.site.NotPeons',
                 count=True,
                 maxitems=0,
                 sortreversed=False,
                 hidezerocount=False)
    criteria.add('checkbox',
                 'left',
                 'default',
                 title='Institution',
                 hidden=False,
                 index='siteName',
                 operator='or',
                 vocabulary=u'eke.site.SitesNames',
                 count=True,
                 maxitems=4,
                 sortreversed=False,
                 hidezerocount=False)
    criteria.add('checkbox',
                 'left',
                 'default',
                 title='Member Type',
                 hidden=False,
                 index='memberType',
                 operator='or',
                 vocabulary=u'eke.site.MemberType',
                 count=True,
                 maxitems=20,
                 sortreversed=False,
                 hidezerocount=False)
    criteria.add('criteria', 'top', 'default', title='Current Search')
    membersList.reindexObject()