[Mpuls-commits] r5818 - in base/trunk/mpulsweb: model templates/search

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Thu Feb 16 15:45:21 CET 2012


Author: roland
Date: 2012-02-16 15:45:20 +0100 (Thu, 16 Feb 2012)
New Revision: 5818

Modified:
   base/trunk/mpulsweb/model/case.py
   base/trunk/mpulsweb/templates/search/search.mako
Log:
Added support for extended order_by

The elements in the case section in the JSON file accept now the option
"order_by" which causes a drop down box to appear in the extented search are.
With it, it is possible to sort the result list by an value not shown in the
table.


Modified: base/trunk/mpulsweb/model/case.py
===================================================================
--- base/trunk/mpulsweb/model/case.py	2012-02-15 09:43:58 UTC (rev 5817)
+++ base/trunk/mpulsweb/model/case.py	2012-02-16 14:45:20 UTC (rev 5818)
@@ -245,6 +245,9 @@
        session -- If true (default false) the field is available with
                the alias name from the SessionCase object too.
                This setting only has an affect if alias is not None.
+               
+       order_by -- if true (default false) will be shown as an option in a drop
+               down list in the extended search page for sorting
     """
 
     def __init__(self, name, digest=False,
@@ -254,7 +257,8 @@
                  alias=None, alias_force_string=True,
                  overview=False, overview_label=None,
                  overview_style="table_name",
-                 overview_length=15):
+                 overview_length=15,
+                 order_by=False):
 
         self.name = name
         self.digest = digest
@@ -262,6 +266,7 @@
         self.info_label = info_label or name
         self.search_retrieve = search_retrieve
         self.search_match = search_match
+        self.order_by = order_by
 
         self.session = session
         self.preload = preload

Modified: base/trunk/mpulsweb/templates/search/search.mako
===================================================================
--- base/trunk/mpulsweb/templates/search/search.mako	2012-02-15 09:43:58 UTC (rev 5817)
+++ base/trunk/mpulsweb/templates/search/search.mako	2012-02-16 14:45:20 UTC (rev 5818)
@@ -4,8 +4,12 @@
   <div class="widget container">
     <table>
       <%
+        order_by_fields = []
         search_field_set = False
         for i in g.mpuls_config.get('case', 'fields'):
+            if i.get('order_by', False):
+                order_by_fields.append(i)
+            
             if i.get('search_match', False):
                 search_field_set = True
       %>
@@ -229,6 +233,34 @@
         </tr>
       % endif
         <%include file="/casemanagement/search_extra.mako" />
+
+      % if c.extended_search and len(order_by_fields):
+      </table>
+        <span> </span>
+      <table>
+      %endif
+      
+      % if len(order_by_fields):
+      <tr style="${not c.extended_search and 'display:none' or ''}">
+          <td class="label">${_('Order by')}</td>
+          <td>
+          <select name="sort_field" id="sort_field">
+                <option value="">${_('Other')}</option>
+          % for field in order_by_fields:
+               <option value="m.${field['name']}">${field['info_label']}</option>
+          % endfor
+          </select>
+          <form:error name="sort_field">
+          </td>
+          <td>
+            <select name="sort_order" id="sort_order">
+            <option value="asc">${_('Sort in ascending order')}</option>
+            <option value="desc">${_('Sort in descending order')}</option>
+            </select>
+            <form:error name="sort_order">
+          </td>
+        </tr>
+      % endif
       <tr>
         <td class=""></td>
         <td></td>



More information about the Mpuls-commits mailing list