[Mpuls-commits] r831 - in wasko/branches/2.0: . waskaweb/templates/casemanagement

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Jan 22 15:50:09 CET 2010


Author: bh
Date: 2010-01-22 15:50:07 +0100 (Fri, 22 Jan 2010)
New Revision: 831

Modified:
   wasko/branches/2.0/ChangeLog
   wasko/branches/2.0/waskaweb/templates/casemanagement/caselist.mako
Log:
* waskaweb/templates/casemanagement/caselist.mako: build table
header rows and data row using a list of column descriptions.


Modified: wasko/branches/2.0/ChangeLog
===================================================================
--- wasko/branches/2.0/ChangeLog	2010-01-22 11:52:32 UTC (rev 830)
+++ wasko/branches/2.0/ChangeLog	2010-01-22 14:50:07 UTC (rev 831)
@@ -1,5 +1,10 @@
 2010-01-22  Bernhard Herzog  <bh at intevation.de>
 
+	* waskaweb/templates/casemanagement/caselist.mako: build table
+	header rows and data row using a list of column descriptions.
+
+2010-01-22  Bernhard Herzog  <bh at intevation.de>
+
 	* waskaweb/templates/casemanagement/caselist.mako: Move status
 	icons and per-case actions into their own functions.
 

Modified: wasko/branches/2.0/waskaweb/templates/casemanagement/caselist.mako
===================================================================
--- wasko/branches/2.0/waskaweb/templates/casemanagement/caselist.mako	2010-01-22 11:52:32 UTC (rev 830)
+++ wasko/branches/2.0/waskaweb/templates/casemanagement/caselist.mako	2010-01-22 14:50:07 UTC (rev 831)
@@ -1,33 +1,59 @@
 ## -*- coding: utf-8 -*-
-<%! import waskaweb.lib.filters as F %>
+<%!
+from pylons.i18n import _
 
+import waskaweb.lib.filters as F
+import waskaweb.lib.helpers as h
+
+def hide_if_anonymized(case, value):
+    """
+    If the case is marked for anonymisation return empty string, value otherwise
+    """
+    if case.getState().getState() == 4 and h.hasRole(['cm_ka']):
+        return ""
+    return value
+
+all_roles = ['admin', 'cm']
+
+fields = [
+    (_('cm_overview_tbl_header_id'), "kundennummer", "table_id", all_roles,
+     lambda case: h.getCaseShort(hide_if_anonymized(case, case.knr), 15)),
+
+    (_('cm_overview_tbl_header_lastname'), "name_1", "table_name", all_roles,
+     lambda case: h.getCaseShort(hide_if_anonymized(case, case.last_name), 15)),
+
+    (_('cm_overview_tbl_header_firstname'), "vorname_1", "table_name",
+     all_roles,
+     lambda case: h.getCaseShort(hide_if_anonymized(case, case.first_name),15)),
+
+    (_('cm_overview_tbl_header_editor'), "bearbeiter_id", "table_name",
+     ["admin"],
+     lambda case: "%s, %s" % (case.getEditor().last_name,
+                              case.getEditor().first_name[0])),
+
+    (_('cm_overview_tbl_header_accesstime'), "zugriff", "table_name", ["cm"],
+     lambda case: case.state.getAccessTime('%d.%m.%Y')),
+  ]
+%>
+
 <%def name="build_list_headers()">
   <th class="table_header_h table_checkbox">&nbsp;</th>
-  <th class="table_id table_header_h">${_('cm_overview_tbl_header_id')}
-    <a href="/case_overview/overview/0/kundennummer/asc"><img class="sorticon" src="/images/icons/sort_asc.png"></a> 
-    <a href="/case_overview/overview/0/kundennummer/desc"><img class="sorticon" src="/images/icons/sort_desc.png"></a> 
+  % for title, urlpart, style, roles, get_value in fields:
+    % if h.hasRole(roles):
+      <th class="${style} table_header_h">${title}
+        <a href="/case_overview/overview/0/${urlpart}/asc">
+          <img class="sorticon" src="/images/icons/sort_asc.png"></a>
+        <a href="/case_overview/overview/0/${urlpart}/desc">
+          <img class="sorticon" src="/images/icons/sort_desc.png"></a>
+      </th>
+    % endif
+  % endfor
+  <th class="table_status table_header_h">
+    ${_('cm_overview_tbl_header_status')}
   </th>
-  <th class="table_name table_header_h">${_('cm_overview_tbl_header_lastname')}
-    <a href="/case_overview/overview/0/name_1/asc"><img class="sorticon" src="/images/icons/sort_asc.png"></a> 
-    <a href="/case_overview/overview/0/name_1/desc"><img class="sorticon" src="/images/icons/sort_desc.png"></a> 
+  <th class="table_action table_header_h">
+    ${_('cm_overview_tbl_header_actions')}
   </th>
-  <th class="table_name table_header_h">${_('cm_overview_tbl_header_firstname')}
-    <a href="/case_overview/overview/0/vorname_1/asc"><img class="sorticon" src="/images/icons/sort_asc.png"></a> 
-    <a href="/case_overview/overview/0/vorname_1/desc"><img class="sorticon" src="/images/icons/sort_desc.png"></a> 
-  </th>
-  % if h.hasRole(['admin_ka']):
-    <th class="table_name table_header_h">${_('cm_overview_tbl_header_editor')}
-      <a href="/case_overview/overview/0/bearbeiter_id/asc"><img class="sorticon" src="/images/icons/sort_asc.png"></a> 
-      <a href="/case_overview/overview/0/bearbeiter_id/desc"><img class="sorticon" src="/images/icons/sort_desc.png"></a> 
-    </th>
-  % else:
-    <th class="table_name table_header_h">${_('cm_overview_tbl_header_accesstime')}
-      <a href="/case_overview/overview/0/zugriff/asc"><img class="sorticon" src="/images/icons/sort_asc.png"></a> 
-      <a href="/case_overview/overview/0/zugriff/desc"><img class="sorticon" src="/images/icons/sort_desc.png"></a> 
-    </th>
-  % endif
-  <th class="table_status table_header_h">${_('cm_overview_tbl_header_status')}</th>
-  <th class="table_action table_header_h">${_('cm_overview_tbl_header_actions')}</th>
 </%def>
 
 <%def name="get_state_icon(case)">
@@ -106,24 +132,11 @@
   % for num, case in enumerate(c.cases.getDatasets()):
       <tr class="${num % 2 and 'table_row_h' or ''}">
         <td><input type="checkbox" name="case_id" value="${case.id}"></td>
-        ## If the case is marked for anonymisation do not show the
-        ## first and lastname and the customer number.
-        % if case.getState().getState() == 4 and h.hasRole(['cm_ka']):
-          <td>${h.getCaseShort('', 15) | F.NA, h}</td>
-          <td>${h.getCaseShort('', 15) | F.NA, h}</td>
-          <td>${h.getCaseShort('', 15) | F.NA, h}</td>
-        % else:
-          <td>${case.knr       | F.NA, h}</td>
-          <td>${h.getCaseShort(case.last_name, 15) | F.NA, h}</td>
-          <td>${h.getCaseShort(case.first_name, 15) | F.NA, h}</td>
-        % endif
-        % if h.hasRole(['admin_ka']):
-          <td>
-            ${case.getEditor().last_name | F.NA, h}, ${case.getEditor().first_name[0] | F.NA, h}.
-          </td>
-        % else:
-          <td>${case.state.getAccessTime('%d.%m.%Y') | F.NA, h}</td>
-        % endif
+        % for title, urlpart, style, roles, get_value in fields:
+          % if h.hasRole(roles):
+            <td>${get_value(case) | F.NA, h}</td>
+          % endif
+        % endfor
         <td>
           ${get_state_icon(case)}
         </td>



More information about the Mpuls-commits mailing list