[Mpuls-commits] r2297 - in wasko/branches/2.0: . mpulsweb/lib
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri Apr 9 15:10:48 CEST 2010
Author: torsten
Date: 2010-04-09 15:10:46 +0200 (Fri, 09 Apr 2010)
New Revision: 2297
Modified:
wasko/branches/2.0/ChangeLog
wasko/branches/2.0/jmd.json
wasko/branches/2.0/mpulsweb/lib/renderer.py
Log:
Implemented first version of rg-sorting
Modified: wasko/branches/2.0/ChangeLog
===================================================================
--- wasko/branches/2.0/ChangeLog 2010-04-09 10:59:02 UTC (rev 2296)
+++ wasko/branches/2.0/ChangeLog 2010-04-09 13:10:46 UTC (rev 2297)
@@ -3,7 +3,14 @@
* jmd.json: Disabled Logbook for jmd in pilot.
* mpulsweb/lib/renderer.py (RepeatGroupRenderer.render_digest): Render
description of the corresponding value in choicenode in rg-digests.
+
+ Implemented sorting of RG
+ * jmd.json: New configuration
+ * mpulsweb/lib/renderer.py: First basic version of sorting rg based on
+ string comparison. You can now define a field with in a RG with will
+ be used as comparator.
+
2010-04-09 Bernhard Herzog <bh at intevation.de>
* mpulsweb/lib/renderer.py (ChoiceContainer.render)
Modified: wasko/branches/2.0/jmd.json
===================================================================
--- wasko/branches/2.0/jmd.json 2010-04-09 10:59:02 UTC (rev 2296)
+++ wasko/branches/2.0/jmd.json 2010-04-09 13:10:46 UTC (rev 2297)
@@ -195,9 +195,14 @@
"renderer": {
"rg_digests": {
- "rg_unterstuetzungsangebote": ["ua_art",
+ "rg_unterstuetzungsangebote": {"fields": ["ua_art",
"ua_datum_start",
- "ua_datum_ende"]
+ "ua_datum_ende"]},
+ "rg_biographie2": {"fields": ["biographie_art",
+ "biographie_datum_von",
+ "biographie_datum_bis"],
+ "sort_field": "biographie_datum_von",
+ "sort_order": "desc"}
}
},
"evaluations": {
Modified: wasko/branches/2.0/mpulsweb/lib/renderer.py
===================================================================
--- wasko/branches/2.0/mpulsweb/lib/renderer.py 2010-04-09 10:59:02 UTC (rev 2296)
+++ wasko/branches/2.0/mpulsweb/lib/renderer.py 2010-04-09 13:10:46 UTC (rev 2297)
@@ -858,7 +858,8 @@
out = []
case_id = rg.getIdentifier().split(':')[-1]
- fields = self.rg_digests.get(self._getMeta(rg).getName(), [])
+ fields = self.rg_digests.get(self._getMeta(rg).getName(), []).get('fields')
+ log.debug(fields)
out.append('<table class="rgdigest">')
if not fields:
@@ -898,13 +899,36 @@
return "".join(out)
def render(self, showNext=False):
+
out = []
out.append('<div class="widget">')
out.append('<table class="list">')
out.append('<tr><th>%s</th><th class="actions">%s</th>'
% (escape(_('Description')),
escape(_('Actions'))))
- for num, rg in enumerate(self.page.getChildren()):
+ items = self.page.getChildren()
+
+ # Sorting of RG.
+ class SortDummy:
+ def __init__(self, rg, it, case_id, field):
+ self.rg = rg
+ self.value = str(it.getItem('%s:%s:%s' % (field, rg.getInternalIdentifier(), case_id)).getValue())
+
+ unsorted_items = []
+ reverse_order = False
+ if len(items) > 0:
+ rg = items[0]
+ case_id = rg.getIdentifier().split(':')[-1]
+ fields = self.rg_digests.get(self._getMeta(rg).getName(), []).get('fields')
+ sort_field = self.rg_digests.get(self._getMeta(rg).getName(), []).get('sort_field', fields[0])
+ sort_order = self.rg_digests.get(self._getMeta(rg).getName(), []).get('sort_order')
+ for rg in items:
+ unsorted_items.append(SortDummy(rg, self.it, case_id, sort_field))
+ if sort_order == "desc":
+ reverse_order = True
+ sorted_items = sorted(unsorted_items, key=lambda rg: rg.value, reverse=reverse_order)
+
+ for num, rg in enumerate([sd.rg for sd in sorted_items]):
out.append('<tr>')
out.append('<td>')
out.append(self.render_digest(rg))
More information about the Mpuls-commits
mailing list