add rst formatting for ranked items values

This commit is contained in:
Frédéric Péters 2012-07-24 10:06:26 +02:00
parent f7d0368e2f
commit 633196d8e4
1 changed files with 14 additions and 0 deletions

View File

@ -1184,6 +1184,20 @@ class RankedItemsField(WidgetField):
r += htmltext('</ul>')
return r.getvalue()
def get_rst_view_value(self, value, indent=''):
items = value.items()
items.sort(lambda x,y: cmp(x[1], y[1]))
counter = 0
last_it = None
values = []
for it in items:
if it[1] is not None:
if last_it != it[1]:
counter += 1
last_it = it[1]
values.append('%s: %s' % (counter, it[0]))
return indent + ' / '.join(values)
def get_csv_heading(self):
return [self.label] + ['']*(len(self.items)-1)