quick & dirty viewlet to display related documents
This commit is contained in:
parent
4db3e282ab
commit
9967bf6d76
|
@ -1,10 +1,15 @@
|
|||
from zope.interface import implements
|
||||
from five import grok
|
||||
from zope import schema
|
||||
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 _
|
||||
|
@ -16,3 +21,25 @@ 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
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
<tal:block tal:define="documents viewlet/links">
|
||||
<fieldset tal:condition="documents">
|
||||
<legend>Documents rangés dans ce dossier</legend>
|
||||
<div class="table-container"
|
||||
tal:define="pas_member context/@@pas_member"
|
||||
>
|
||||
<table class="searchResults">
|
||||
<thead><tr><th><input type="checkbox"/></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th>Intitulé</th>
|
||||
<th>Auteur</th>
|
||||
<th>Dernière modification</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tal:results repeat="item documents">
|
||||
<tal:entry tal:define="author python:pas_member.info(item.Creator())">
|
||||
<tr>
|
||||
<td><input type="checkbox"/></td>
|
||||
<td><a class="trash" tal:attributes="href python:item.absolute_url() + '/delete_confirmation'" href="#" title="Supprimer">S</a></td>
|
||||
<td><img /></td>
|
||||
<td><a
|
||||
href="#"
|
||||
tal:attributes="href item/absolute_url;
|
||||
class string:plop"
|
||||
tal:content="item/Title" /></td>
|
||||
<td><span class="documentAuthor" tal:condition="author/fullname">
|
||||
<a href="#"
|
||||
tal:content="author/fullname"
|
||||
tal:omit-tag="not:item/Creator"
|
||||
tal:attributes="href string:${original_context/@@plone_portal_state/navigation_root_url}/author/${author/username}">
|
||||
Bob Dobalina
|
||||
</a>
|
||||
</span></td>
|
||||
<td>
|
||||
<span class="documentModified">
|
||||
<span tal:replace="python:toLocalizedTime(item.ModificationDate())"
|
||||
tal:on-error="string:?">
|
||||
August 16, 2001 at 23:35:59
|
||||
</span>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
</tal:entry>
|
||||
</tal:results>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</fieldset>
|
||||
</tal:block>
|
Reference in New Issue