[Mpuls-commits] r725 - in waska/trunk: . waskaweb/controllers waskaweb/lib waskaweb/model waskaweb/public/styles waskaweb/templates waskaweb/templates/casemanagement/dialogs waskaweb/templates/evaluation

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Dec 7 09:21:33 CET 2009


Author: torsten
Date: 2009-12-07 09:21:31 +0100 (Mon, 07 Dec 2009)
New Revision: 725

Added:
   waska/trunk/waskaweb/templates/casemanagement/dialogs/success_bundle_markevaluate.mako
   waska/trunk/waskaweb/templates/evaluation/
   waska/trunk/waskaweb/templates/evaluation/evaluate.mako
   waska/trunk/waskaweb/templates/evaluation/evaluate_adele.mako
Modified:
   waska/trunk/ChangeLog.txt
   waska/trunk/waskaweb/controllers/case_overview.py
   waska/trunk/waskaweb/controllers/evaluate.py
   waska/trunk/waskaweb/lib/search.py
   waska/trunk/waskaweb/model/case.py
   waska/trunk/waskaweb/public/styles/screen.css
Log:
Enabled marking of cases for evaluation


Modified: waska/trunk/ChangeLog.txt
===================================================================
--- waska/trunk/ChangeLog.txt	2009-12-04 13:45:48 UTC (rev 724)
+++ waska/trunk/ChangeLog.txt	2009-12-07 08:21:31 UTC (rev 725)
@@ -1,3 +1,28 @@
+2009-12-07 	Torsten Irlaender  <torsten.irlaender at intevation.de>
+
+	Issue883
+
+	* templates/evaluation/evaluate_adele.mako
+	  templates/evaluation/evaluate.mako: Fixed label of "Art der
+	  Beendigung"
+
+	Issue884
+
+	* public/styles/screen.css: Fixed layout on evalressult-page
+
+2009-12-05 	Torsten Irlaender  <torsten.irlaender at intevation.de>
+
+	Cases can be marked for evaluation in the caseoverview.
+
+	* waskaweb/model/case.py
+	  waskaweb/controllers/case_overview.py
+	  waskaweb/controllers/evaluate.py
+	  waskaweb/lib/search.py
+	  waskaweb/templates/evaluation
+	  waskaweb/templates/evaluation/evaluate.mako
+	  waskaweb/templates/casemanagement/dialogs/success_bundle_markevaluate.mako:
+	  Enabled marking of cases in caseoverview
+
 2009-12-02 	Torsten Irlaender  <torsten.irlaender at intevation.de>
 
 	* waskaweb/lib/xmlimport.py: Re-generated type checking dictionaries

Modified: waska/trunk/waskaweb/controllers/case_overview.py
===================================================================
--- waska/trunk/waskaweb/controllers/case_overview.py	2009-12-04 13:45:48 UTC (rev 724)
+++ waska/trunk/waskaweb/controllers/case_overview.py	2009-12-07 08:21:31 UTC (rev 725)
@@ -108,6 +108,9 @@
 RESTORE_NOTIFICATION_ERROR = u"""Bei dem Wiederherstellen der Fallakten ist ein Fehler aufgetreten. Bitte klicken Sie auf "OK", um fortzufahren."""
 SELECT_PARTS_FOR_EXPORT = u"Welche Bereiche der Fallakte(n) sollen exportiert werden?"
 
+MARKEVALUATE_SUCCESS_HEADER = u"""Fallakten wurden zur Auswertung vorgemerkt!"""
+MARKEVALUATE_SUCCESS_TEXT = u"""Es wurden %s Fallakten zur Auswertung vorgemerkt. Sie bilden die Grundlage für durchzuführende Auswertungen. Bitte klicken Sie auf "Ok", um fortzufahren."""
+
 FORM_DEFAULTS_ADMIN = {'show_own': '1', \
                       'search_str': '', \
                       'show_open': '0', \
@@ -323,6 +326,7 @@
         validator = BundleActionForm()
         c.context           = "../main.mako" 
         c.url_ok            = "/case_overview"
+        caseoverview        = []
         try:
             data        = formencode.variabledecode.variable_decode(request.params)
             session['CASE_OVERVIEW_SELECTION'] = data
@@ -330,20 +334,23 @@
             form_result = validator.to_python(data)
             action      = form_result.get('action') 
             c.current_user = session['USER_AUTHORIZED']
-            if form_result.get('all_cases') > 0:
-                # Narf! Load ids of all cases with the last search option again
-                # as they are not included in the submitted data.
 
-                # If the user is admin then he should see only cases which are marked for
-                # deletion or anonymisation
-                if c.current_user.isAdmin():
-                    FORM_DEFAULTS = FORM_DEFAULTS_ADMIN
-                else:
-                    FORM_DEFAULTS = FORM_DEFAULTS_CM
-                search_options = session.get('CASE_OVERVIEW_SEARCHOPTIONS') or FORM_DEFAULTS
-                search_str = ";".join(parseSearchOptions(search_options))
-                case_bundle = CaseBundle([case.id for case in CaseOverview().search(search_str)])
+            # If the user is admin then he should see only cases which are marked for
+            # deletion or anonymisation
+            if c.current_user.isAdmin():
+                FORM_DEFAULTS = FORM_DEFAULTS_ADMIN
             else:
+                FORM_DEFAULTS = FORM_DEFAULTS_CM
+
+            # Narf! Load ids of all cases with the last search option again
+            # as they are not included in the submitted data.
+            search_options = session.get('CASE_OVERVIEW_SEARCHOPTIONS') or FORM_DEFAULTS
+            search_str = ";".join(parseSearchOptions(search_options))
+            caseoverview = CaseOverview()
+            caselist     = caseoverview.search(search_str)
+            if form_result.get('all_cases') > 0:
+                case_bundle = CaseBundle([case.id for case in caselist])
+            else:
                 case_bundle = CaseBundle(form_result.get('case_id', []))
 
             if case_bundle.isEmpty():
@@ -457,7 +464,16 @@
                 session['casebundle_for_eval'] = case_bundle
                 session['hide_search_option_on_eval'] = True
                 session.save()
-                redirect_to(controller='evaluate', action="evaluate", id=1);
+                sql = caseoverview.get_sql()
+                if form_result.get('all_cases') > 0:
+                    session['caseoverview_search'] = self._preqpare_sql_for_eval(sql) 
+                else:
+                    session['caseoverview_search'] = self._preqpare_sql_for_eval(sql, case_bundle.case_list) 
+                session.save()
+                c.url_ok            = "/case_overview"
+                c.success_for       = MARKEVALUATE_SUCCESS_HEADER  
+                c.success_text      = MARKEVALUATE_SUCCESS_TEXT % (str(len(case_bundle.case_list)))
+                return render('/casemanagement/dialogs/success_bundle_markevaluate.mako')
             else:
                 raise HTTPNotFound()
 
@@ -468,6 +484,14 @@
             return htmlfill.render(unicode(form, 'utf-8'), c.form_result, c.form_errors, auto_insert_errors=False)
         return self.overview()
 
+    def _preqpare_sql_for_eval(self, sql, ids=None):
+        part = sql.split('FROM')[1].split('ORDER')[0]
+        if ids:
+            new_sql = "( m.id IN ( SELECT m.id FROM %s AND m.id in (%s) ) )" % (part, ','.join([str(id) for id in ids]))
+        else:
+            new_sql = "( m.id IN ( SELECT m.id FROM %s ) )" % (part)
+        return new_sql
+
     def _filterBundle(self, case_bundle, allowedstates, filtered_cases=None, filter_inconsistent=False):
         '''Returns a filtered CaseBundle. Filtering can be done on states and on inconsistent cases (not all required fields are filled for current phase)'''
         filtered = []

Modified: waska/trunk/waskaweb/controllers/evaluate.py
===================================================================
--- waska/trunk/waskaweb/controllers/evaluate.py	2009-12-04 13:45:48 UTC (rev 724)
+++ waska/trunk/waskaweb/controllers/evaluate.py	2009-12-07 08:21:31 UTC (rev 725)
@@ -43,7 +43,6 @@
             options['end_date_field'] = g.mpuls_config.get('agency-fields-mapping', 'date_phase%s_end' % max(phase))
 
         options['phase'] = max(phase)
-        options['sqlwhere'] = soptions.get('sqlwhere') or None 
         options['sql'] =  soptions.get('sql') or None
     else:
         # set default evaluation options.
@@ -68,6 +67,9 @@
     options['start_date'] = format_date(options['start_date']) 
     options['end_date']   = format_date(options['end_date']) 
 
+    # add (overwirte) sqlsearch from caseoverview
+    options['sqlwhere'] = session.get('caseoverview_search') 
+
     return options
 
 class EvaluateController(BaseController):
@@ -156,8 +158,14 @@
             endingdate = "( '%s'::date <= %s AND %s <= '%s'::date )" % (params['start_date'], enddatefield, enddatefield, params['end_date'])
             ending = "%s in ( %s )" % (typeendfield ,", ".join(['%s' % e for e in params['ending']]))
 
-        params['sql'] = "SELECT %%(fields)s from master_tbl_eval_total_view m WHERE %s AND %s AND %s" % ("".join(dates), ending, endingdate)
 
+        # Add search criteria from case_overview
+        search_overview = session.get('caseoverview_search')
+        if not search_overview:
+            search_overview = "TRUE"
+
+        params['sql'] = "SELECT %%(fields)s from master_tbl_eval_total_view m WHERE %s AND %s AND %s AND %s" % ("".join(dates), ending, endingdate, search_overview)
+
         #Datefields
         if all_phases:
             params['start_date_field'] = g.mpuls_config.get('agency-fields-mapping', 'date_phase%s_start' % min(all_phases))
@@ -215,7 +223,8 @@
                                     eval_params['end_date_field'], 
                                     None,
                                     eval_params['sql'], 
-                                    eval_params['typelist'])
+                                    eval_params['typelist'],
+                                    )
                     evalset      = EvaluationSet(evalconfig, True)
                     evalset.evaluate()
                     c.result = evalset.export(EvaluationExportHTML(show_percent=form_result['show_percent']))

Modified: waska/trunk/waskaweb/lib/search.py
===================================================================
--- waska/trunk/waskaweb/lib/search.py	2009-12-04 13:45:48 UTC (rev 724)
+++ waska/trunk/waskaweb/lib/search.py	2009-12-07 08:21:31 UTC (rev 725)
@@ -121,7 +121,7 @@
 
 class Search:
     def __init__(self):
-        pass
+        self.sql = None
 
     def _parse_search_str(self, s):
         # TODO This is a very very simple approach. We should defentiley
@@ -158,6 +158,9 @@
                     search.append(option)
         return search, options, allowed_states, bad_types, phases, fields
 
+    def get_sql(self):
+        return self.sql
+
     def _build_sql(self, search, options, allowed_states, bad_types, phases, fieldsdic):
         pass
 
@@ -170,12 +173,14 @@
                 con = db.getConnection()
                 cur = con.cursor(cursor_factory=psycopg2.extras.DictCursor)
                 cur.execute(sql, fields)
+                # save sql 
+                self.sql = cur.query
                 rows = cur.fetchall()
             except:
                 return {}
         finally:
             db.recycleConnection(con, cur)
-        return rows 
+        return rows
 
     def perform(self, search_str):
         '''Returns the result set of a search based on the search string'''

Modified: waska/trunk/waskaweb/model/case.py
===================================================================
--- waska/trunk/waskaweb/model/case.py	2009-12-04 13:45:48 UTC (rev 724)
+++ waska/trunk/waskaweb/model/case.py	2009-12-07 08:21:31 UTC (rev 725)
@@ -335,6 +335,7 @@
 class CaseOverview:
     def __init__(self, search_str=None):
         self.ds_list = []
+        self.sql = None
 
     def sortByLastname(self):
         def _cmp(a, b):
@@ -348,6 +349,7 @@
         self.ds_list = []
         search = CaseSearch()
         result = search.perform(search_str)
+        self.sql = search.get_sql()
         factory = CaseFactory()
         for row in result:
             case = factory.loadByName( \
@@ -372,6 +374,9 @@
     def getDatasets(self):
         return self.ds_list
 
+    def get_sql(self):
+        return self.sql
+
 class CaseFactory:
     '''Factory for case object. This factory provides methods to either load
     existing cases from db or create new cases'''

Modified: waska/trunk/waskaweb/public/styles/screen.css
===================================================================
--- waska/trunk/waskaweb/public/styles/screen.css	2009-12-04 13:45:48 UTC (rev 724)
+++ waska/trunk/waskaweb/public/styles/screen.css	2009-12-07 08:21:31 UTC (rev 725)
@@ -439,15 +439,14 @@
 	font-size: 0.8em;
 }
 
-
-#content_header #modusfield ul, #content_header #modusfield li, #content_header_small #modusfield ul, #content_header_small #modusfield li{
+#content_header #modusfield ul, #content_header #modusfield li, #content_header_small #modusfield ul, #content_header_small #modusfield li, #content_header_large #modusfield ul, #content_header_large #modusfield li{
 	display:inline;
 	list-style-type:none;
 	margin:0;
 	padding:0;
 }
 
-#content_header #modusfield a, #content_header_small #modusfield a {
+#content_header #modusfield a, #content_header_small #modusfield a, #content_header_large #modusfield a {
 	text-decoration:none;
 	padding:0 0.4em 0em 1.4em;
 	background-image:url(../images/arrow.gif);

Added: waska/trunk/waskaweb/templates/casemanagement/dialogs/success_bundle_markevaluate.mako
===================================================================
--- waska/trunk/waskaweb/templates/casemanagement/dialogs/success_bundle_markevaluate.mako	2009-12-04 13:45:48 UTC (rev 724)
+++ waska/trunk/waskaweb/templates/casemanagement/dialogs/success_bundle_markevaluate.mako	2009-12-07 08:21:31 UTC (rev 725)
@@ -0,0 +1,8 @@
+## -*- coding: utf-8 -*- 
+<%inherit file="/main.mako" />
+<%def name="buildNavipath()">
+  ${parent.buildNavipath()}
+  <li><a href="/case/">${_('cm_np_root')}</a></li>
+  <li><a href="#">${_('Fallakten f&uuml;r Auswertung markieren')}</a></li>
+</%def>
+<%include file="../../dialogs/success.mako" />

Added: waska/trunk/waskaweb/templates/evaluation/evaluate.mako
===================================================================
--- waska/trunk/waskaweb/templates/evaluation/evaluate.mako	2009-12-04 13:45:48 UTC (rev 724)
+++ waska/trunk/waskaweb/templates/evaluation/evaluate.mako	2009-12-07 08:21:31 UTC (rev 725)
@@ -0,0 +1,96 @@
+## -*- coding: utf-8 -*-
+<%inherit file="/main.mako"/>
+<%!  import waskaweb.lib.filters as F %>
+<div>
+  ##<div class="widget modusfield actions">
+  ##  <ul>
+  ##    <li><a href="/administration/resetPassword/${c.user.id}">${_('Reset password')}</a></li>
+  ##    <li><a href="/administration/listUsers">${_('Back to userlist')}</a></li>
+  ##  </ul>
+  ##</div>
+  <div class="header">
+    <h1>${_('Evaluation configuration')}</h1>
+  </div>
+</div>
+<div>
+<form action="/evaluate/evaluateAction" method="POST" target="_blank">
+<input type="hidden" name="id">
+<table>
+  <tr>
+    <td class="label">${_('Name')}</td>
+    <td>${c.evalconfig.get_setname()}</td>
+  </tr>
+  <tr>
+    <td class="label">${_('Description')}</td>
+    <td>${c.evalconfig.get_setdesc()}</td>
+  </tr>
+  <tr>
+  <tr>
+    <td class="label">Phase</td>
+    <td>
+      <input type="checkbox" value="-1" name="phase"/> Unbekannt<br/>
+      <input type="checkbox" value="0" name="phase"/> Eingangsanamnese<br/>
+      <input type="checkbox" value="2" name="phase"/> Case Management<br/>
+      <input type="checkbox" value="4" name="phase"/> Nachbetreuung<br/>
+      <input type="checkbox" value="6" name="phase"/> Beratung<br/>
+    </td>
+  </tr>
+  <tr>
+    <td class="label">Start</td>
+    <td>
+      <input type="text" name="start_date" class="datefield"><form:error name="start_date" format="">
+    </td>
+  </tr>
+  <tr>
+    <td class="label">Ende</td>
+    <td>
+      <input type="text" name="end_date" class="datefield"><form:error name="end_date" format="">
+    </td>
+  </tr>
+  <tr>
+    <td class="label">Art der Beendigung</td>
+    <td>
+      <input type="checkbox" value="0" name="type_ending"/> reguläre Beendigung<br/>
+      <input type="checkbox" value="2" name="type_ending"/> vorzeitige Beendigung<br/> 
+      <input type="checkbox" value="1" name="type_ending"/> Abbruch<br/>
+    </td>
+  </tr>
+  % if session.has_key('caseoverview_search'):
+  <tr>
+    <td class="label">${_('Filter')}</td>
+    <td>
+      Yes (<a href="/evaluate/resetFilter/${c.evalconfig.get_setid()}">Reset</a>)<br>
+      <input type="hidden" name="sqlwhere">
+      ${session['caseoverview_search']}
+    </td>
+  </tr>
+  % endif
+</table>
+<h2>${_('Available evaluations')}</h2>
+<p>${_('Please select one or more evaluations')}</p>
+<table style="table-layout:auto">
+  <tr>
+    <th colspan="2">${_('Evaluations')}</th>
+  </tr>
+  % for num, id in enumerate(c.evalconfig.get_evaluations()):
+  <tr>
+    <td class="${num%2 and 'hl' or ''}">
+      <input type="checkbox" name="typelist" value="${id}" id="${id}">
+    </td>
+    <td class="${num%2 and 'hl' or ''}">
+      <h3><label for="${id}">${c.evalconfig.get_name(id)}</label></h3>
+      <p><label for="${id}">${c.evalconfig.get_desc(id)}</label></p>
+    </td>
+  </tr>
+  % endfor
+</table>
+<table>
+  <tr>
+    <td colspan="3"><input type="checkbox" name="show_percent" id="show_percent"> <label for="show_percent">${_('Show percent')}</label></td> 
+  </tr>
+  <tr>
+    <td colspan="3"><input type="submit" name="setup_evaluation" value="${_('evaluate')}"></td> 
+  </tr>
+</table>
+</form>
+</div>

Added: waska/trunk/waskaweb/templates/evaluation/evaluate_adele.mako
===================================================================
--- waska/trunk/waskaweb/templates/evaluation/evaluate_adele.mako	2009-12-04 13:45:48 UTC (rev 724)
+++ waska/trunk/waskaweb/templates/evaluation/evaluate_adele.mako	2009-12-07 08:21:31 UTC (rev 725)
@@ -0,0 +1,97 @@
+## -*- coding: utf-8 -*-
+<%inherit file="/main.mako"/>
+<%!  import waskaweb.lib.filters as F %>
+<div>
+  ##<div class="widget modusfield actions">
+  ##  <ul>
+  ##    <li><a href="/administration/resetPassword/${c.user.id}">${_('Reset password')}</a></li>
+  ##    <li><a href="/administration/listUsers">${_('Back to userlist')}</a></li>
+  ##  </ul>
+  ##</div>
+  <div class="header">
+    <h1>${_('Evaluation configuration')}</h1>
+  </div>
+</div>
+<div>
+<form action="/evaluate/evaluateAction" method="POST" target="_blank">
+<input type="hidden" name="id">
+<table>
+  <tr>
+    <td class="label">${_('Name')}</td>
+    <td>${c.evalconfig.get_setname()}</td>
+  </tr>
+  <tr>
+    <td class="label">${_('Description')}</td>
+    <td>${c.evalconfig.get_setdesc()}</td>
+  </tr>
+  <tr>
+    <td class="label">Phase</td>
+    <td>
+      <input type="hidden" name="phase" value="2">
+      <input type="checkbox" value="-1" name="phase" disabled="disabled"/> Unbekannt<br/>
+      <input type="checkbox" value="0"  name="phase" disabled="disabled"/> Eingangsanamnese<br/>
+      <input type="checkbox" value="2"  name="phase" disabled="disabled"/> Case Management<br/>
+      <input type="checkbox" value="4"  name="phase" disabled="disabled"/> Nachbetreuung<br/>
+      <input type="checkbox" value="6"  name="phase" disabled="disabled"/> Beratung<br/>
+    </td>
+  </tr>
+  <tr>
+    <td class="label">Start</td>
+    <td>
+      <input type="hidden" name="start_date">
+      <input type="text" name="start_date" class="datefield" disabled="disabled"><form:error name="start_date" format="">
+    </td>
+  </tr>
+  <tr>
+    <td class="label">Ende</td>
+    <td>
+      <input type="hidden" name="end_date">
+      <input type="text" name="end_date" class="datefield" disabled="disabled"><form:error name="end_date" format="">
+    </td>
+  </tr>
+  <tr>
+    <td class="label">Art der Beendigung</td>
+    <td>
+      <input type="checkbox" value="0" name="type_ending" disabled="disabled"/> reguläre Beendigung<br/>
+      <input type="checkbox" value="2" name="type_ending" disabled="disabled"/> vorzeitige Beendigung<br/> 
+      <input type="checkbox" value="1" name="type_ending" disabled="disabled"/> Abbruch<br/>
+    </td>
+  </tr>
+  % if session.has_key('evaluation.options'):
+  <tr>
+    <td class="label">${_('Filter')}</td>
+    <td>
+      Yes (<a href="/evaluate/resetFilter/${c.evalconfig.get_setid()}">Reset</a>)<br>
+      ${session['evaluation.options'].get('sql')}
+    </td>
+  </tr>
+  % endif
+</table>
+<h2>${_('Available evaluations')}</h2>
+<p>${_('Please select one or more evaluations')}</p>
+<table style="table-layout:auto">
+  <tr>
+    <th colspan="2">${_('Evaluations')}</th>
+  </tr>
+  % for num, id in enumerate(c.evalconfig.get_evaluations()):
+  <tr>
+    <td class="${num%2 and 'hl' or ''}">
+      <input type="checkbox" name="typelist" value="${id}" id="${id}">
+    </td>
+    <td class="${num%2 and 'hl' or ''}">
+      <h3><label for="${id}">${c.evalconfig.get_name(id)}</label></h3>
+      <p><label for="${id}">${c.evalconfig.get_desc(id)}</label></p>
+    </td>
+  </tr>
+  % endfor
+</table>
+<table>
+  <tr>
+    <td colspan="3"><input type="checkbox" name="show_percent" id="show_percent"> <label for="show_percent">${_('Show percent')}</label></td> 
+  </tr>
+  <tr>
+    <td colspan="3"><input type="submit" name="setup_evaluation" value="${_('evaluate')}"></td> 
+  </tr>
+</table>
+</form>
+</div>



More information about the Mpuls-commits mailing list