src/pyams_content/component/association/container.py
changeset 841 d50743e69693
parent 633 7ebe8a011c16
child 1240 921ff38f1aae
equal deleted inserted replaced
840:3dcf565c711e 841:d50743e69693
    17 
    17 
    18 # import interfaces
    18 # import interfaces
    19 from pyams_content.component.association.interfaces import IAssociationContainer, IAssociationContainerTarget, \
    19 from pyams_content.component.association.interfaces import IAssociationContainer, IAssociationContainerTarget, \
    20     ASSOCIATION_CONTAINER_KEY, IAssociationItem, IAssociationInfo
    20     ASSOCIATION_CONTAINER_KEY, IAssociationItem, IAssociationInfo
    21 from pyams_content.features.checker.interfaces import IContentChecker
    21 from pyams_content.features.checker.interfaces import IContentChecker
       
    22 from pyams_zmi.layer import IAdminLayer
    22 from zope.location.interfaces import ISublocations
    23 from zope.location.interfaces import ISublocations
    23 from zope.traversing.interfaces import ITraversable
    24 from zope.traversing.interfaces import ITraversable
    24 
    25 
    25 # import packages
    26 # import packages
    26 from pyams_catalog.utils import index_object
    27 from pyams_catalog.utils import index_object
    52         self.last_id += 1
    53         self.last_id += 1
    53         if not notify:
    54         if not notify:
    54             # make sure that association item is correctly indexed
    55             # make sure that association item is correctly indexed
    55             index_object(value)
    56             index_object(value)
    56 
    57 
    57     def get_visible_items(self):
    58     def get_visible_items(self, request=None):
    58         return filter(lambda x: IAssociationItem(x).visible, self.values())
    59         for item in filter(lambda x: IAssociationItem(x).visible, self.values()):
       
    60             if IAdminLayer.providedBy(request) or item.is_visible(request):
       
    61                 yield item
    59 
    62 
    60 
    63 
    61 @adapter_config(context=IAssociationContainerTarget, provides=IAssociationContainer)
    64 @adapter_config(context=IAssociationContainerTarget, provides=IAssociationContainer)
    62 def association_container_factory(target):
    65 def association_container_factory(target):
    63     """Associations container factory"""
    66     """Associations container factory"""