Related Term field now displays back refs
This commit is contained in:
parent
875f2db29c
commit
2b10d47ab0
|
@ -78,3 +78,23 @@ Puis un widget de la forme:
|
|||
+--------+--------------+--------+
|
||||
| [cancel] [choose] |
|
||||
+--------+--------------+--------+
|
||||
|
||||
|
||||
TODO
|
||||
-----
|
||||
|
||||
- revoir le widget des équivalences
|
||||
|
||||
- terminer la vue pour les kws
|
||||
- equivalences sous forme de liste
|
||||
- virer les doublons dans les RT
|
||||
- afficher les enfants
|
||||
- affiner la feuille de style
|
||||
|
||||
- vocabulaire pour autocomplete
|
||||
cf vocab pour les contacts
|
||||
+ exploiter ce vocab dans une vue pour le thesaurus
|
||||
|
||||
- fichier d'import : perso.entrouvert.org/~fred/thesaurus.json
|
||||
page d'import : <thesaurus_url>/import_json
|
||||
Le fichier doit se trouver sur /tmp/thesaurus.json
|
|
@ -22,7 +22,7 @@
|
|||
<browser:page
|
||||
for="collective.dms.thesaurus.dmskeyword.IDmsKeyword"
|
||||
name="dmskeyword.view"
|
||||
class="plone.dexterity.browser.view.DefaultView"
|
||||
class="plone.dexterity.browser.view.DefaultView"
|
||||
template="dmskeyword_view.pt"
|
||||
permission="zope2.View"
|
||||
/>
|
||||
|
|
|
@ -10,43 +10,42 @@
|
|||
<metal:main fill-slot="content-core">
|
||||
<metal:content-core define-macro="content-core">
|
||||
|
||||
<table id="dmskeywords-navigation">
|
||||
<tr>
|
||||
<td>
|
||||
<tal:parents define="widget python:view.widgets.get('broader')">
|
||||
<div class="field" tal:condition="python:widget.__name__ not in ('IBasic.title', 'IBasic.description', 'title', 'description',)">
|
||||
<label tal:content="widget/label" />
|
||||
<br />
|
||||
<div tal:content="structure widget/render" />
|
||||
</div>
|
||||
</tal:parents>
|
||||
</td>
|
||||
<td>
|
||||
<tal:equivs define="widget python:view.widgets.get('equivs')">
|
||||
<div class="field" tal:condition="python:widget.__name__ not in ('IBasic.title', 'IBasic.description', 'title', 'description',)">
|
||||
<label tal:content="widget/label" />
|
||||
<br />
|
||||
<div tal:content="structure widget/render" />
|
||||
</div>
|
||||
</tal:equivs>
|
||||
|
||||
<tal:parents define="widget python:view.widgets.get('related')">
|
||||
<div class="field" tal:condition="python:widget.__name__ not in ('IBasic.title', 'IBasic.description', 'title', 'description',)">
|
||||
<label tal:content="widget/label" />
|
||||
<br />
|
||||
<div tal:content="structure widget/render" />
|
||||
</div>
|
||||
</tal:parents>
|
||||
</td>
|
||||
<td>
|
||||
<div class="field">
|
||||
<label tal:content="string:NT (Narrower Term)" />
|
||||
<div id="dmskeywords-navigation">
|
||||
<div id="dmskeywords-navigation-left">
|
||||
<tal:parents define="widget python:view.widgets.get('broader')">
|
||||
<div class="field" tal:condition="python:widget.__name__ not in ('IBasic.title', 'IBasic.description', 'title', 'description',)">
|
||||
<label tal:content="widget/label" />
|
||||
<br />
|
||||
<div tal:content="string:content here" />
|
||||
<div tal:content="structure widget/render" />
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</tal:parents>
|
||||
</div>
|
||||
<div id="dmskeywords-navigation-center">
|
||||
<tal:equivs define="widget python:view.widgets.get('equivs')">
|
||||
<div class="field" tal:condition="python:widget.__name__ not in ('IBasic.title', 'IBasic.description', 'title', 'description',)">
|
||||
<label tal:content="widget/label" />
|
||||
<br />
|
||||
<div tal:content="structure widget/render" />
|
||||
</div>
|
||||
</tal:equivs>
|
||||
|
||||
<tal:parents define="widget python:view.widgets.get('related')">
|
||||
<div class="field" tal:condition="python:widget.__name__ not in ('IBasic.title', 'IBasic.description', 'title', 'description',)">
|
||||
<label tal:content="widget/label" />
|
||||
<br />
|
||||
<div tal:content="structure widget/render" />
|
||||
</div>
|
||||
</tal:parents>
|
||||
</div>
|
||||
|
||||
<div id="dmskeywords-navigation-right">
|
||||
<div class="field">
|
||||
<label tal:content="string:NT (Narrower Term)" />
|
||||
<br />
|
||||
<div tal:content="string:content here" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</metal:content-core>
|
||||
</metal:main>
|
||||
|
|
|
@ -1,3 +1,21 @@
|
|||
#dmskeywords-navigation {
|
||||
margin-top: 8em;
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
#dmskeywords-navigation-left {
|
||||
float: left;
|
||||
padding-right: 1em;
|
||||
}
|
||||
|
||||
#dmskeywords-navigation-center {
|
||||
float: left;
|
||||
padding-left: 1em;
|
||||
padding-right: 1em;
|
||||
border-left: 1px solid black;
|
||||
border-right: 1px solid black;
|
||||
}
|
||||
|
||||
#dmskeywords-navigation-right {
|
||||
padding-left: 1em;
|
||||
float: left;
|
||||
}
|
|
@ -18,6 +18,8 @@
|
|||
<include package="." />
|
||||
<include package=".browser" />
|
||||
|
||||
<adapter factory=".relatedkeywords.RelatedThesaurusKeywordsFieldWidget" />
|
||||
|
||||
<genericsetup:registerProfile
|
||||
name="default"
|
||||
title="collective.dms.thesaurus"
|
||||
|
|
|
@ -21,8 +21,7 @@ class IRelatedThesaurusKeywords(IRelationList):
|
|||
class RelatedThesaurusKeywordsWidget(MultiContentTreeWidget):
|
||||
display_template = ViewPageTemplateFile('related-thesaurus-keywords-display.pt')
|
||||
|
||||
def __init__(self, display_backrefs, request):
|
||||
self.display_backrefs = display_backrefs
|
||||
def __init__(self, request):
|
||||
super(RelatedThesaurusKeywordsWidget, self).__init__(request)
|
||||
|
||||
def get_url(self, v):
|
||||
|
@ -34,12 +33,25 @@ class RelatedThesaurusKeywordsWidget(MultiContentTreeWidget):
|
|||
|
||||
def tuples(self):
|
||||
refs = [(self.get_url(x), self.get_label(x)) for x in self.value]
|
||||
intids = getUtility(IIntIds)
|
||||
catalog = getUtility(ICatalog)
|
||||
try:
|
||||
doc_intid = intids.getId(self.context)
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
for ref in catalog.findRelations(
|
||||
{'to_id': doc_intid, 'from_attribute': 'related'}):
|
||||
tp = (ref.from_path, ref.from_object.Title())
|
||||
if tp not in refs:
|
||||
refs.append(tp)
|
||||
return refs
|
||||
|
||||
|
||||
@adapter(IRelatedThesaurusKeywords, IFormLayer)
|
||||
@implementer(IFieldWidget)
|
||||
def RelatedThesaurusKeywordsFieldWidget(field, request):
|
||||
return FieldWidget(field, RelatedThesaurusKeywordsWidget(field.display_backrefs, request))
|
||||
return FieldWidget(field, RelatedThesaurusKeywordsWidget(request))
|
||||
|
||||
class ThesaurusPathSourceBinder(ObjPathSourceBinder):
|
||||
|
||||
|
|
Reference in New Issue