[Mpuls-commits] r4292 - jmd/trunk/jmdstrukturweb/templates/casemanagement
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Wed Dec 1 11:05:45 CET 2010
Author: torsten
Date: 2010-12-01 11:05:45 +0100 (Wed, 01 Dec 2010)
New Revision: 4292
Added:
jmd/trunk/jmdstrukturweb/templates/casemanagement/caselist.mako
Log:
Added new template for caselisting. Disables "editor"-column in caselist when logged in as admin
Added: jmd/trunk/jmdstrukturweb/templates/casemanagement/caselist.mako
===================================================================
--- jmd/trunk/jmdstrukturweb/templates/casemanagement/caselist.mako 2010-12-01 10:02:59 UTC (rev 4291)
+++ jmd/trunk/jmdstrukturweb/templates/casemanagement/caselist.mako 2010-12-01 10:05:45 UTC (rev 4292)
@@ -0,0 +1,274 @@
+## -*- coding: utf-8 -*-
+<%!
+
+from pylons import app_globals as g
+import mpulsweb.lib.helper.filters as F
+import mpulsweb.lib.helpers as h
+from mpulsweb.lib.translation import _
+
+all_roles = ['admin', 'cm']
+
+## Fields to show in the case list. Each entry is a tuple of the form
+## (TITLE, FIELDNAME, STYLE, ROLES, FORMATTER)
+## Here, TITLE is the title of the field, FIELDNAME is the field name
+## used in the search URL that's built for each column, STYLE is a CSS
+## class name to use in the style attribute of the HTML TH-element,
+## ROLES is a list with the names of the roles for which the field
+## should be shown. Finally, FORMATTER is a python callable that is
+## called with the case object as argument and which should return the
+## formatted value for the column.
+
+fields = []
+for d in g.case.get_overview_fields():
+ f = d.name
+ fn = d.overview_label
+ fs = d.overview_style
+ field = (fn,f,fs, all_roles,
+ lambda case, d=d: h.shorten(h.format_object(case.get_value(d.name)), d.overview_length))
+ fields.append(field)
+
+# Extend fields with default fields in overview
+fields.extend([(_('cm_overview_tbl_header_accesstime'), "zugriff", "table_name", ["cm", "admin"],
+ lambda case: h.format_date(case.state.getAccessTime())),
+ ])
+%>
+
+<%def name="build_list_headers()">
+ % if g.mpuls_config.is_enabled('case-module', 'casebundle'):
+ <th class="table_header_h table_checkbox"> </th>
+ % endif
+ % for title, urlpart, style, roles, get_value in fields:
+ % if h.hasRole(roles):
+ <th class="${style} table_header_h">${title}
+ <a href="${h.url_for(controller='case_overview', action='overview',
+ sort_field=urlpart, sort_order='asc')}">
+ <img class = "sorticon"
+ %if c.sort_field == urlpart and c.sort_order == 'asc':
+ src = "${h.url_for('/images/icons/sort_asc_active.png')}"
+ alt = "${_("Sorted by %s in ascending order") % title}"
+ title = "${_("Sorted by %s in ascending order") % title}"
+ %else:
+ src = "${h.url_for('/images/icons/sort_asc.png')}"
+ alt = "${_("Sort in ascending order")}"
+ title = "${_("Sort in ascending order")}"
+ %endif
+ width = "10"
+ height = "9"></a>
+ <a href="${h.url_for(controller='case_overview', action='overview',
+ sort_field=urlpart, sort_order='desc')}">
+ <img class = "sorticon"
+ %if c.sort_field == urlpart and c.sort_order == 'desc':
+ src = "${h.url_for('/images/icons/sort_desc_active.png')}"
+ alt = "${_("Sorted by %s in descending order") % title}"
+ title = "${_("Sorted by %s in descending order") % title}"
+ %else:
+ src = "${h.url_for('/images/icons/sort_desc.png')}"
+ alt = "${_("Sort in descending order")}"
+ title = "${_("Sort in descending order")}"
+ %endif
+ width = "10"
+ height = "9"></a>
+ </th>
+ % endif
+ % endfor
+ <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="build_list_row(case)">
+ % if g.mpuls_config.is_enabled('case-module', 'casebundle'):
+ <td><input type="checkbox" name="case_id" value="${case.id}"></td>
+ % endif
+ % for title, urlpart, style, roles, get_value in fields:
+ % if h.hasRole(roles):
+ % if case.getState().getState() != 5:
+ <td><a href="${h.url_for(controller='/case', action='select',
+ id=case.id, confirmed=0)}">${get_value(case) | F.NA}</a></td>
+ % else:
+ <td>${get_value(case) | F.NA}</td>
+ % endif
+ % endif
+ % endfor
+ <td>
+ ${get_phase_icon(case)}
+ % if g.mpuls_config.is_enabled('case-module', 'tags'):
+ ${get_validity_icon(case)}
+ % endif
+ ${get_state_icon(case)}
+ </td>
+ <td>
+ ${get_actions(case)}
+ </td>
+</%def>
+
+<%def name="get_validity_icon(case)">
+ % for validity in g.mpuls_config.get('validities', 'enabled'):
+ % if validity['id'] == case.getValidity():
+ <img src="${h.url_for('/images/icons/%s' % validity['icon'])}" alt="${validity['name']}" title="${validity['name']}" width="22" height="22">
+ % endif
+ % endfor
+</%def>
+
+<%def name="get_phase_icon(case)">
+ <% phase = case.getState().getPhase() %>
+ <% running = not phase%2 and 'running' or 'finished' %>
+ <% description = h.literal(c.phases.get_phase(str(phase)).getDescription())%>
+ <img src="${h.url_for(str('/images/icons/case_status/%s_%s.png' % (description[0].lower(), running)) )}" alt="${description}" title="${description}" width="22" height="22">
+</%def>
+
+<%def name="render_phase_legend()">
+<% legend = [] %>
+<div class="container widget info">
+ <strong>${_('Legend')}: </strong>
+ % for p in c.phases:
+ ${legend.append("%s: %s" % (g.mpuls_config.get('phases', 'shortdescription')[0][p.id], p.getDescription()))}
+ % endfor
+ ${h.literal(", ".join(legend))}
+ | <span style="background-image:url('${h.url_for("/images/icons/phase-running-22.png")}'); background-repeat:no-repeat; background-position:1px -2px">
+ ( )
+ </span>: ${_("Running")},
+ <span style="background-image:url('${h.url_for("/images/icons/phase-stop-22.png")}'); background-repeat:no-repeat; background-position:1px -2px">
+ ( )
+ </span>: ${_("Finished")}
+</div>
+<br>
+</%def>
+
+<%def name="get_state_icon(case)">
+ % if h.hasRole(['cm_ka']) and g.mpuls_config.is_enabled('case-module', 'organisation'):
+ % if str(case.getEditor().id) == str(session.get('USER_AUTHORIZED').id):
+ <img src = "${h.url_for('/images/icons/edit_editor.png')}"
+ border = "0"
+ alt = "${_('cm_overview_img_editor')}"
+ title = "${_('cm_overview_img_editor')}"
+ width = "22"
+ height = "22">
+ % else:
+ <img src = "${h.url_for('/images/icons/edit_editors_22.png')}"
+ border = "0"
+ alt = "${_('cm_overview_img_standin')}"
+ title = "${_('cm_overview_img_standin')}"
+ width = "22"
+ height = "22">
+ % endif
+ % endif
+ % if case.getState().getState() in (1,2):
+ <img src = "${h.url_for('/images/icons/edit_22.png')}"
+ border = "0"
+ alt = "${_('case_state_label_open')}"
+ title = "${_('case_state_label_open')}"
+ width = "22"
+ height = "22">
+ % elif case.getState().getState() == 3:
+ <img src = "${h.url_for('/images/icons/delete_inactive_22.png')}"
+ border = "0"
+ alt = "${_('case_state_label_markdelete')}"
+ title = "${_('case_state_label_markdelete')}"
+ width = "22"
+ height = "22">
+ % elif case.getState().getState() == 4:
+ <img src = "${h.url_for('/images/icons/anonymise_inactive_22.png')}"
+ border = "0"
+ alt = "${_('case_state_label_markanonym')}"
+ title = "${_('case_state_label_markanonym')}"
+ width = "22"
+ height = "22">
+ % elif case.getState().getState() == 5:
+ <img src = "${h.url_for('/images/icons/anonymise_inactive_22.png')}"
+ border = "0"
+ alt = "${_('case_state_label_anonym')}"
+ title = "${_('case_state_label_anonym')}"
+ width = "22"
+ height = "22">
+ % endif
+</%def>
+
+<%def name="get_actions(case)">
+ % if case.getState().getState() != 5:
+ <a href="${h.url_for(controller='case', action='select', id=case.id,
+ confirmed=0)}">
+ <img src = "${h.url_for('/images/icons/open_active_22.png')}"
+ border = "0"
+ alt = "${_('cm_overview_a_show')}"
+ title = "${_('cm_overview_a_show')}"
+ width = "22"
+ height = "22"></a>
+ % endif
+ % if h.hasRole(['admin_ka']):
+ % if case.getState().getState() in (3, 5):
+ <a href="${h.url_for(controller='case', action='delete', id=case.id,
+ confirmed=0)}">
+ <img src = "${h.url_for('/images/icons/delete_active_22.png')}"
+ border = "0"
+ alt = "${_('Delete case')}"
+ title = "${_('Delete case')}"
+ width = "22"
+ height = "22"></a>
+ % endif
+ % if case.getState().getState() == 4:
+ % if g.mpuls_config.is_enabled('case-module', 'anonymize'):
+ <a href="${h.url_for(controller='case', action='anonymize', id=case.id,
+ confirmed=0)}">
+ <img src = "${h.url_for('/images/icons/anonymise_active_22.png')}"
+ border = "0"
+ alt = "${_('cm_overview_a_anonymize')}"
+ title = "${_('cm_overview_a_anonymize')}"
+ width = "22"
+ height = "22"></a>
+ % endif
+ % endif
+ % if case.getState().getState() in (3, 4):
+ <a href="${h.url_for(controller='case', action='restore', id=case.id,
+ confirmed=0)}">
+ <img src = "${h.url_for('/images/icons/refresh_active_22.png')}"
+ border = "0"
+ alt = "${_('cm_overview_a_restore')}"
+ title = "${_('cm_overview_a_restore')}"
+ width = "22"
+ height = "22"></a>
+ % endif
+ % elif h.hasRole(['cm_ka']) and case.getState().getState() in (1, 2):
+ % if g.mpuls_config.is_enabled('case-module', 'anonymize'):
+ <a href="${h.url_for(controller='case',
+ action='markForAnonymizeFromOverview', id=case.id,
+ confirmed=0)}">
+ <img src = "${h.url_for('/images/icons/anonymise_active_22.png')}"
+ border = "0"
+ alt = "${_('cm_overview_a_anonymize')}"
+ title = "${_('cm_overview_a_anonymize')}"
+ width = "22"
+ height = "22"></a>
+ % endif
+ <a href="${h.url_for(controller='case', action='markForDelete', id=case.id,
+ confirmed=0)}">
+ <img src = "${h.url_for('/images/icons/delete_active_22.png')}"
+ border = "0"
+ alt = "${_('cm_overview_a_delete')}"
+ title = "${_('cm_overview_a_delete')}"
+ width = "22"
+ height = "22"></a>
+ % endif
+</%def>
+
+<table id="table_caseoverview" class="hovertable">
+ <tr>
+ ${build_list_headers()}
+ </tr>
+ % for num, case in enumerate(c.cases.getDatasets()):
+ <tr class="${num % 2 and 'table_row_h' or ''}">
+ ${build_list_row(case)}
+ </tr>
+ % endfor
+ % if len(c.cases.getDatasets()) <= 0:
+ <tr>
+ <td colspan="6">
+ ${_('cm_overview_tbl_no_data_found')}
+ </td>
+ </tr>
+ % endif
+</table>
+${render_phase_legend()}
More information about the Mpuls-commits
mailing list