properly sort broader terms (#2977)
This commit is contained in:
parent
75e3a22a4e
commit
dc4586e3ca
|
@ -17,13 +17,26 @@
|
|||
<table id="dmskeywords-navigation"
|
||||
i18n:domain="collective.dms.thesaurus">
|
||||
<tr id="dmskeywords-navigation-row">
|
||||
<td id="dmskeywords-navigation-left-column">
|
||||
<div id="dmskeywords-navigation-broader-field"
|
||||
class="field"
|
||||
tal:define="widget python:view.widgets.get('broader')">
|
||||
<label tal:content="widget/label" /> <br />
|
||||
<div tal:content="structure widget/render" />
|
||||
<td id="dmskeywords-navigation-left-column"
|
||||
class="field">
|
||||
<div class="field" id="dmskeywords-navigation-broader-field">
|
||||
|
||||
<label i18n:translate="">BT (Broader Terms)</label>
|
||||
<br />
|
||||
<tal:list condition="view/broader">
|
||||
<ul id="" class=""
|
||||
tal:attributes="id string:form-widgets-broader;
|
||||
class string:contenttree-widget broaderthesauruskeywords-field;
|
||||
"><li tal:repeat="value view/broader"
|
||||
><a href="#"
|
||||
tal:content="value/label"
|
||||
tal:attributes="href value/url"
|
||||
/></li
|
||||
></ul></tal:list>
|
||||
<em tal:condition="not:view/broader"
|
||||
i18n:translate="">nothing</em>
|
||||
</div>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
|
@ -25,7 +25,7 @@ class DmsKeywordView(DefaultView):
|
|||
if ref.id != self.context.id:
|
||||
refs.append({'url':ref.getPath(), 'label':ref.Title})
|
||||
def cmp_ref(x, y):
|
||||
return cmp(x['label'], y['label'])
|
||||
return cmp(x['label'].lower(), y['label'].lower())
|
||||
refs.sort(cmp_ref)
|
||||
return refs
|
||||
|
||||
|
@ -55,6 +55,22 @@ class DmsKeywordView(DefaultView):
|
|||
if brain.id != self.context.id and ref not in refs:
|
||||
refs.append(ref)
|
||||
def cmp_ref(x, y):
|
||||
return cmp(x['label'], y['label'])
|
||||
return cmp(x['label'].lower(), y['label'].lower())
|
||||
refs.sort(cmp_ref)
|
||||
return refs
|
||||
|
||||
@property
|
||||
def broader(self):
|
||||
"""Return sorted list of borader terms"""
|
||||
refs = []
|
||||
broader = self.context.broader
|
||||
thesaurus = utils.get_thesaurus_object(self.context)
|
||||
thesaurus_path = '/'.join(thesaurus.getPhysicalPath())
|
||||
for ref in broader:
|
||||
kw = getattr(thesaurus, ref)
|
||||
refs.append({'url': '/'.join(kw.getPhysicalPath()),
|
||||
'label': kw.Title()})
|
||||
def cmp_ref(x, y):
|
||||
return cmp(x['label'].lower(), y['label'].lower())
|
||||
refs.sort(cmp_ref)
|
||||
return refs
|
||||
|
|
Reference in New Issue