management interface: show clients also for concepts

git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@1714 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2007-05-05 07:26:19 +00:00
parent 5369eb78ad
commit b1f9088cae
6 changed files with 61 additions and 43 deletions

View file

@ -158,6 +158,11 @@ class ConceptView(BaseView):
#elif type provides view: use this #elif type provides view: use this
return self return self
def clients(self):
from loops.browser.node import NodeView # avoid circular import
for node in self.context.getClients():
yield NodeView(node, self.request)
class ConceptConfigureView(ConceptView): class ConceptConfigureView(ConceptView):

View file

@ -13,9 +13,12 @@
summary string:Currently assigned objects; summary string:Currently assigned objects;
legend string:Parent Concepts; legend string:Parent Concepts;
showPredicate string:yes; showPredicate string:yes;
buttonText string:Remove Parents;"> buttonText string:Remove Parents;"
style="float:left; padding-right:20px">
<metal:parents use-macro="views/relation_macros/listing" /> <metal:parents use-macro="views/relation_macros/listing" />
</div> </div>
<div metal:use-macro="views/relation_macros/clients" />
<div tal:define="items view/children; <div tal:define="items view/children;
action string:remove; action string:remove;
qualifier string:children; qualifier string:children;

View file

@ -158,4 +158,31 @@
</metal:search> </metal:search>
<metal:clients define-macro="clients">
<div tal:define="items view/clients">
<fieldset>
<legend i18n:translate=""
style="padding: 0 4px 0 4px">Clients</legend>
<table class="listing" summary="Clients" i18n:attributes="summary">
<thead>
<tr>
<th i18n:translate="label_title">Title</th>
<th i18n:translate="label_type">Type</th>
</tr>
</thead>
<tbody>
<tr tal:repeat="item items">
<td><a tal:content="item/title" href="#"
tal:attributes="href
string:${item/url}/@@configure.html">
Title</a></td>
<td tal:content="item/nodeType">Type</td>
</tr>
</tbody>
</table>
</fieldset>
</div>
</metal:clients>
</html> </html>

View file

@ -22,34 +22,11 @@
style="float:left; padding-right:20px"> style="float:left; padding-right:20px">
<metal:parents use-macro="views/relation_macros/listing" /> <metal:parents use-macro="views/relation_macros/listing" />
</div> </div>
<div metal:use-macro="views/relation_macros/clients" />
<div tal:define="items view/clients"
style="padding-right:20px">
<fieldset>
<legend i18n:translate="">Clients</legend>
<table class="listing" summary="Clients" i18n:attributes="summary">
<thead>
<tr>
<th i18n:translate="label_title">Title</th>
<th i18n:translate="label_type">Type</th>
</tr>
</thead>
<tbody>
<tr tal:repeat="item items">
<td><a tal:content="item/title" href="#"
tal:attributes="href
string:${item/url}/@@configure.html">
Title</a></td>
<td tal:content="item/nodeType">Type</td>
</tr>
</tbody>
</table>
</fieldset>
</div>
<div tal:define="legend string:Create Concept; <div tal:define="legend string:Create Concept;
buttonText string:Create Concept" buttonText string:Create Concept"
style="padding-right:20px; clear:left"> style="clear:left">
<metal:create use-macro="views/relation_macros/create"> <metal:create use-macro="views/relation_macros/create">
<metal:control fill-slot="control"> <metal:control fill-slot="control">
<input class="context" type="submit" name="form.button.submit" <input class="context" type="submit" name="form.button.submit"
@ -69,8 +46,7 @@
summary string:Assignment candidates; summary string:Assignment candidates;
legend string:Search; legend string:Search;
showPredicate nothing; showPredicate nothing;
buttonText string:Assign;" buttonText string:Assign;">
style="padding-right:20px">
<metal:assign use-macro="views/relation_macros/listing"> <metal:assign use-macro="views/relation_macros/listing">
<metal:search fill-slot="topActions"> <metal:search fill-slot="topActions">
<metal:block use-macro="views/relation_macros/search" /> <metal:block use-macro="views/relation_macros/search" />

View file

@ -40,10 +40,11 @@ from cybertools.relation.registry import getRelationSingle, setRelationSingle
from cybertools.relation.interfaces import IRelationRegistry, IRelatable from cybertools.relation.interfaces import IRelationRegistry, IRelatable
from cybertools.typology.interfaces import IType, ITypeManager from cybertools.typology.interfaces import IType, ITypeManager
from interfaces import IConcept, IConceptRelation, IConceptView from loops.interfaces import IConcept, IConceptRelation, IConceptView
from interfaces import IConceptManager, IConceptManagerContained from loops.interfaces import IConceptManager, IConceptManagerContained
from interfaces import ILoopsContained from loops.interfaces import ILoopsContained
from interfaces import IIndexAttributes from loops.interfaces import IIndexAttributes
from loops.view import TargetRelation
# relation classes # relation classes
@ -133,6 +134,12 @@ class Concept(Contained, Persistent):
# concept relations # concept relations
def getClients(self, relationships=None):
if relationships is None:
relationships = [TargetRelation]
rels = getRelations(second=self, relationships=relationships)
return [r.first for r in rels]
def getChildRelations(self, predicates=None, child=None): def getChildRelations(self, predicates=None, child=None):
predicates = predicates is None and ['*'] or predicates predicates = predicates is None and ['*'] or predicates
relationships = [ConceptRelation(self, None, p) for p in predicates] relationships = [ConceptRelation(self, None, p) for p in predicates]

View file

@ -159,6 +159,9 @@ class Resource(Image, Contained):
def getLoopsRoot(self): def getLoopsRoot(self):
return zapi.getParent(self).getLoopsRoot() return zapi.getParent(self).getLoopsRoot()
# concept relations
# note: we always use the master version for relations, see getMaster()
def getClients(self, relationships=None): def getClients(self, relationships=None):
if relationships is None: if relationships is None:
relationships = [TargetRelation] relationships = [TargetRelation]
@ -166,9 +169,6 @@ class Resource(Image, Contained):
rels = getRelations(second=obj, relationships=relationships) rels = getRelations(second=obj, relationships=relationships)
return [r.first for r in rels] return [r.first for r in rels]
# concept relations
# note: we always use the master version for relations, see getMaster()
def getConceptRelations (self, predicates=None, concept=None): def getConceptRelations (self, predicates=None, concept=None):
predicates = predicates is None and ['*'] or predicates predicates = predicates is None and ['*'] or predicates
obj = getMaster(self) obj = getMaster(self)