## -*- 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([ (_('Editor'), "bearbeiter_id", "table_name", ["admin"], lambda case: "%s, %s" % (F.NA(case.getEditor().last_name), F.NA(case.getEditor().first_name[:1]))), (_('Updated'), "zugriff", "table_name", ["cm"], lambda case: h.format_date(case.state.getAccessTime())), ]) %> <%def name="build_list_headers()"> <% # Normally CASE_OVERVIEW_SEARCHOPTIONS should contain at least the default # ordering fields when showing the case-overview (Set in # case_overview-controller). But as this template is included in other # use-cases too this is not always true. In theses cases be more error # tolerant and fallback to no (system default = id) sorting, # which should be ok in theses cases. s = session.get('CASE_OVERVIEW_SEARCHOPTIONS', {}) sort_field = s.get('sort_field') sort_order = s.get('sort_order') %> % if g.mpuls_config.is_enabled('case-module', 'casebundle'):   % endif % for title, urlpart, style, roles, get_value in fields: % if h.hasRole(roles): ${title} ${_( ${_( % endif % endfor ${_('Status')} ${_('Actions')} <%def name="build_list_row(case)"> % if g.mpuls_config.is_enabled('case-module', 'casebundle'): % endif % for title, urlpart, style, roles, get_value in fields: % if h.hasRole(roles): % if case.getState().getState() != 5 and case.getState().getState() != 3: ${get_value(case) | F.NA} % else: ${get_value(case) | F.NA} % endif % endif % endfor ${get_phase_icon(case)} % if g.mpuls_config.is_enabled('case-module', 'tags'): ${get_validity_icon(case)} % endif ${get_state_icon(case)} ${get_sync_icon(case)} ${get_actions(case)} <%def name="get_validity_icon(case)"> % for validity in g.mpuls_config.get('validities', 'enabled'): % if validity['id'] == case.getValidity(): ## ${validity['name']} ## % endif % endfor <%def name="get_phase_icon(case)"> <% phase = case.getState().getPhase() %> <% running = not phase%2 and 'running' or 'finished' %> <% phasepart = c.phases.get_phase(str(phase)) %> <% phasepart = c.phases.get_phase(str(phase)) %> %if not phasepart: ## use unknown phase instead of causing traceback <% phasepart = c.phases.get_phase("-1") %> %endif <% description = h.literal(phasepart.getDescription()) %> <% icon = phasepart.getIcon() %> ${description} <%def name="render_phase_legend()"> <% legend = [] %>
${_('Legend')}: % 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))} | (   ) : ${_("Running")}, (   ) : ${_("Finished")}

<%def name="get_sync_icon(case)"> % if g.mpuls_config.is_enabled('case-module', 'meta-server'): % if case.getMeta().is_linked(): ${_('Case is linked with AiR-Server')} % else: ${_('Case is not linked with AiR-Server')} % endif % endif <%def name="get_state_icon(case)"> % if h.hasRole(['cm']) and g.mpuls_config.is_enabled('case-module', 'organisation'): % if case.user_is_editor(session.get('USER_AUTHORIZED').id): ${_('Editor')} % else: ${_('Standin')} % endif % endif % if case.getState().getState() in (1,2): ${_('Editable')} % elif case.getState().getState() == 3: ${_('Mark delete')} % elif case.getState().getState() == 4: ${_('Mark anonym')} % elif case.getState().getState() == 5: ${_('Make anonymousym')} % endif <%def name="get_actions(case)"> % if h.hasRole(['admin']): % if case.getState().getState() != 5: ${_('Show')} % endif % if case.getState().getState() in (3, 5): ${_('Delete case')} % endif % if case.getState().getState() == 4: % if g.mpuls_config.is_enabled('case-module', 'anonymize'): ${_('Anonymize case document')} % endif % endif % if case.getState().getState() in (3, 4): ${_('Restore case document')} % endif % elif h.hasRole(['cm']) and case.getState().getState() in (1, 2): % if case.getState().getState() != 5 and case.getState().getState() != 4: ${_('Show')} % endif % if g.mpuls_config.is_enabled('case-module', 'anonymize'): ${_('Anonymize case document')} % endif ${_('Delete')} % endif ${build_list_headers()} % for num, case in enumerate(c.cases.getDatasets()): ${build_list_row(case)} % endfor % if len(c.cases.getDatasets()) <= 0: % endif
${_('No data found.')}
${render_phase_legend()}