use z3c.table to render the table of associated documents
This commit is contained in:
parent
fb702529ee
commit
805b036b3d
|
@ -11,6 +11,13 @@ from plone.dexterity.content import Container
|
|||
from Acquisition import aq_parent
|
||||
|
||||
from plone.supermodel import model
|
||||
from plone import api
|
||||
from plone.uuid.interfaces import IUUID
|
||||
from plone.app.layout.viewlets.interfaces import IBelowContentBody
|
||||
import plone.app.contenttypes.interfaces
|
||||
from plone.dexterity.interfaces import IDexterityContainer
|
||||
|
||||
from pfwbged.collection.searchview import ResultsTable
|
||||
|
||||
from . import _
|
||||
|
||||
|
@ -22,12 +29,9 @@ 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
|
||||
import plone.app.contenttypes.interfaces
|
||||
|
||||
class FolderViewlet(grok.Viewlet):
|
||||
grok.context(plone.app.contenttypes.interfaces.IFolder)
|
||||
|
@ -35,16 +39,28 @@ class FolderViewlet(grok.Viewlet):
|
|||
grok.viewletmanager(IBelowContentBody)
|
||||
grok.order(15)
|
||||
|
||||
@property
|
||||
def table(self):
|
||||
table = ResultsTable(self.context, self.request)
|
||||
table.values = self.documents()
|
||||
table.update()
|
||||
return table
|
||||
|
||||
def documents(self):
|
||||
intids = component.getUtility(IIntIds)
|
||||
catalog = component.getUtility(ICatalog)
|
||||
intid_catalog = component.getUtility(ICatalog)
|
||||
portal_catalog = api.portal.get_tool('portal_catalog')
|
||||
try:
|
||||
intid = intids.getId(self.context)
|
||||
except KeyError:
|
||||
return []
|
||||
documents = []
|
||||
for item in catalog.findRelations({'to_id': intid}):
|
||||
for item in intid_catalog.findRelations({'to_id': intid}):
|
||||
if item.isBroken():
|
||||
continue
|
||||
documents.append(aq_parent(item.from_object))
|
||||
document = aq_parent(item.from_object)
|
||||
# this is stupid, getting back to the brain, but the rest of the
|
||||
# stuff expects a brain, not an actual object.
|
||||
uuid = IUUID(document, None)
|
||||
documents.extend(portal_catalog({'UID': uuid}))
|
||||
return documents
|
||||
|
|
|
@ -4,48 +4,9 @@
|
|||
<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>
|
||||
|
||||
<table tal:replace="structure viewlet/table/render"/>
|
||||
|
||||
</div>
|
||||
</fieldset>
|
||||
</tal:block>
|
||||
|
|
Reference in New Issue