Пример #1
0
 def getList(self, brains, component=''):
     """
     Returns a list of dicts holding the specific links for viewing, editing, sorting and
     deleting and the obj.
     """
     items = []
     i = 0
     l = len(brains)
     pos = [getObjPositionInParent(brain.getObject())() for brain in brains]
     for brain in brains:
         obj = brain.getObject()
         try:
             components = obj.Schema()['components'].get(obj)
         except:
             components = []
         modify = self.mship.checkPermission(permissions.ModifyPortalContent, obj)
         item = {'obj': obj,
                 'brain': brain,
                 'id': brain.id,
                 'anchor': '%s%s' % (component, brain.id),
                 'up': self.sort and i > 0 and self.sort_url % ('%s%s' % (component, brain.id), pos[(i-1)] - pos[i], brain.id) or None,
                 'down': self.sort and i < l - 1 and self.sort_url % ('%s%s' % (component, brain.id), pos[(i+1)] - pos[i], brain.id) or None,
                 'view': '%s/view' % brain.getURL(),
                 'edit': modify and '%s/edit' % brain.getURL() or None,
                 'delete': self.delete and self.mship.checkPermission(permissions.DeleteObjects, obj) and '%s/delete_confirmation' % brain.getURL() or None,
                 'show': modify and component and not component in components and self.show_hide_url % ('%s%s' % (component, brain.id), 'show', brain.UID, component) or None,
                 'hide': modify and component and component in components and self.show_hide_url % ('%s%s' % (component, brain.id), 'hide', brain.UID, component) or None}
         items.append(item)
         i += 1
     return items
 def getClassificationNames(self):
     """ Returns a list of the titles of the classifications attached to this person.
         Mainly used for pretty-looking metadata in SmartFolder tables.
     """
     cList = [(getObjPositionInParent(c)() + 1, c.Title()) for c in self.getClassifications()]
     cList.sort()
     return [c[-1] for c in cList]
 def getList(self, brains, component=''):
     """
     Returns a list of dicts holding the specific links for viewing, editing, sorting and
     deleting and the obj.
     """
     items = []
     i = 0
     l = len(brains)
     pos = [getObjPositionInParent(brain.getObject())() for brain in brains]
     for brain in brains:
         obj = brain.getObject()
         try:
             components = obj.Schema()['components'].get(obj)
         except:
             components = []
         modify = self.mship.checkPermission(permissions.ModifyPortalContent, obj)
         item = {'obj': obj,
                 'brain': brain,
                 'id': brain.id,
                 'anchor': '%s%s' % (component, brain.id),
                 'up': self.sort and i > 0 and self.sort_url % ('%s%s' % (component, brain.id), pos[(i-1)] - pos[i], brain.id) or None,
                 'down': self.sort and i < l - 1 and self.sort_url % ('%s%s' % (component, brain.id), pos[(i+1)] - pos[i], brain.id) or None,
                 'view': '%s/view' % brain.getURL(),
                 'edit': modify and '%s/edit' % brain.getURL() or None,
                 'delete': self.delete and self.mship.checkPermission(permissions.DeleteObjects, obj) and '%s/delete_confirmation' % brain.getURL() or None,
                 'show': modify and component and not component in components and self.show_hide_url % ('%s%s' % (component, brain.id), 'show', brain.UID, component) or None,
                 'hide': modify and component and component in components and self.show_hide_url % ('%s%s' % (component, brain.id), 'hide', brain.UID, component) or None}
         items.append(item)
         i += 1
     return items
 def getClassificationNames(self):
     """ Returns a list of the titles of the classifications attached to this person.
         Mainly used for pretty-looking metadata in SmartFolder tables.
     """
     cList = [(getObjPositionInParent(c)() + 1, c.Title()) for c in self.getClassifications()]
     cList.sort()
     return [c[-1] for c in cList]
Пример #5
0
    def get_position_in_parent(self):
        """ Get position in parent
            :keys: _gopip
        """
        from Products.CMFPlone.CatalogTool import getObjPositionInParent
        pos = getObjPositionInParent(self.context)

        # After plone 3.3 the above method returns a 'DelegatingIndexer' rather than an int
        try:
            from plone.indexer.interfaces import IIndexer
            if IIndexer.providedBy(pos):
                self['_gopip'] = pos()
                return
        except ImportError:
            pass

        self['_gopip'] = pos
Пример #6
0
    def get_position_in_parent(self):
        """ Get position in parent
            :keys: _gopip
        """
        from Products.CMFPlone.CatalogTool import getObjPositionInParent
        pos = getObjPositionInParent(self.context)

        # After plone 3.3 the above method returns a 'DelegatingIndexer' rather than an int
        try:
            from plone.indexer.interfaces import IIndexer
            if IIndexer.providedBy(pos):
                self['_gopip'] = pos()
                return
        except ImportError:
            pass

        self['_gopip'] = pos
Пример #7
0
 def getList(self, brains, component=''):
     items = []
     i = 0
     l = len(brains)
     pos = [getObjPositionInParent(brain.alias.getObject())() if getattr(brain, 'alias', None) is not None else getObjPositionInParent(brain.getObject())() for brain in brains]
     for brain in brains:
         obj = brain.getObject()
         if getattr(brain, 'alias', None) is not None:
             alias = brain.alias.__of__(brain.aq_parent)
             url = alias.getURL()
             uid = alias.UID
             id = alias.id
             aobj = alias.getObject()
         else:
             url = brain.getURL()
             uid = brain.UID
             id = brain.id
             aobj = obj
         try:
             components = aobj.Schema()['components'].get(aobj)
         except:
             components = []
         modify = self.mship.checkPermission(permissions.ModifyPortalContent, aobj)
         item = {'obj': obj,
                 'brain': brain,
                 'id': id,
                 'anchor': '%s%s' % (component, id),
                 'up': self.sort and i > 0 and self.sort_url % ('%s%s' % (component, id), pos[(i-1)] - pos[i], id) or None,
                 'down': self.sort and i < l - 1 and self.sort_url % ('%s%s' % (component, id), pos[(i+1)] - pos[i], id) or None,
                 'view': '%s/view' % url,
                 'edit': modify and '%s/edit' % url or None,
                 'delete': self.delete and self.mship.checkPermission(permissions.DeleteObjects, aobj) and '%s/delete_confirmation' % url or None,
                 'show': modify and component and not component in components and self.show_hide_url % ('%s%s' % (component, id), 'show', uid, component) or None,
                 'hide': modify and component and component in components and self.show_hide_url % ('%s%s' % (component, id), 'hide', uid, component) or None}
         items.append(item)
         i += 1
     return items
Пример #8
0
 def get_positions(self, objects):
     """Returns a list of objPositionInParent values for passed objects."""
     return [getObjPositionInParent(obj)() for obj in objects]