This repository has been archived on 2023-02-21. You can view files and clone it, but cannot push or open issues or pull requests.
pfwbged.folder/src/pfwbged/folder/folder.py

46 lines
1.1 KiB
Python

from zope.interface import implements
from five import grok
from zope import schema, component
from plone.directives import form
from zc.relation.interfaces import ICatalog
from zope.app.intid.interfaces import IIntIds
from plone.dexterity.content import Container
from Acquisition import aq_parent
from plone.supermodel import model
from . import _
class IFolder(model.Schema):
""" """
class Folder(Container):
""" """
implements(IFolder)
from plone.dexterity.interfaces import IDexterityContainer
grok.templatedir('templates')
grok.context(IDexterityContainer)
from plone.app.layout.viewlets.interfaces import IBelowContentBody
class FolderViewlet(grok.Viewlet):
grok.template('foldersviewlet')
grok.viewletmanager(IBelowContentBody)
grok.order(15)
def documents(self):
intids = component.getUtility(IIntIds)
catalog = component.getUtility(ICatalog)
intid = intids.getId(self.context)
documents = []
for item in catalog.findRelations({'to_id': intid}):
if item.isBroken():
continue
documents.append(aq_parent(item.from_object))
return documents