[Mpuls-commits] r3187 - in wasko/trunk: . waskoweb/controllers waskoweb/model waskoweb/templates

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Jul 14 15:52:00 CEST 2010


Author: roland
Date: 2010-07-14 15:51:57 +0200 (Wed, 14 Jul 2010)
New Revision: 3187

Added:
   wasko/trunk/waskoweb/controllers/formularpage.py
   wasko/trunk/waskoweb/model/agencysettings.py
Removed:
   wasko/trunk/waskoweb/templates/settings
Modified:
   wasko/trunk/ChangeLog
Log:
ported logic for evaluation id from wasko 1.7

Modified: wasko/trunk/ChangeLog
===================================================================
--- wasko/trunk/ChangeLog	2010-07-14 12:17:10 UTC (rev 3186)
+++ wasko/trunk/ChangeLog	2010-07-14 13:51:57 UTC (rev 3187)
@@ -1,3 +1,20 @@
+
+
+2010-07-14 Roland Geider <roland.geider at intevation.de>
+
+        * waskoweb/model/agencysettings.py,
+          waskoweb/controllers/settings.py,
+          waskoweb/controllers/formularpage.py,
+          waskoweb/templates/settings/edit.mako,
+          waskoweb/templates/settings/show.mako: ported logic for the evaluation
+          ID from wasko 1.7
+    
+2010-07-14 Roland Geider <roland.geider at intevation.de>
+
+        * waskoweb/model/agencysettings.py,
+          waskoweb/controllers/formularpage.py: overwrite methods to generate the
+          evaluation ID
+
 2010-07-12  Torsten Irländer <torsten.irlaender at intevation.de>
 
 	* waskoweb/controllers/caselifetime.py,

Added: wasko/trunk/waskoweb/controllers/formularpage.py
===================================================================
--- wasko/trunk/waskoweb/controllers/formularpage.py	2010-07-14 12:17:10 UTC (rev 3186)
+++ wasko/trunk/waskoweb/controllers/formularpage.py	2010-07-14 13:51:57 UTC (rev 3187)
@@ -0,0 +1,134 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright 2007, 2008 Intevation GmbH, Germany, <info at intevation.de>
+#
+# This file is part of mpuls WASKA (CoMPUter-based case fiLeS -
+# Web-Anwendungs-Server fuer Kompetenzagenturen).
+#
+# mpuls WASKA is free software: you can redistribute it and/or modify it under
+# the terms of the GNU Affero General Public License as published by the
+# Free Software Foundation, either version 3 of the License, or (at your
+# option) any later version.
+#
+# mpuls WASKA is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
+# License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with mpuls WASKA. If not, see <http://www.gnu.org/licenses/>.
+#
+# mpuls WASKA has been developed on behalf of the
+# Projekttraeger im Deutschen Zentrum fuer Luft- und Raumfahrt e.V. (PT-DLR)
+# within the programme Kompetenzagenturen (Durchfuehrungsphase) funded by
+# the Bundesministerium fuer Familie, Senioren, Frauen und Jugend and
+# European Social Fund resources.
+#
+# Authors:
+# Roland Geider <roland.geider at intevation.de>
+#
+
+import logging
+import traceback
+from cgi import escape
+import datetime
+
+import formencode
+
+from pylons import request, session, c
+from pylons import g
+from mpulsweb.lib.translation import _
+from pylons.controllers.util import abort, redirect_to
+
+from mpulsweb.controllers.formularpage import *
+
+from mpulsweb.lib.security import checkRole
+
+from formed.instance.backends.postgres import DBFactory as InstanceFactory
+from formed.instance.tree import SetDataException, RepeatInstanceContainerNode
+
+
+from mpulsweb.lib.security import checkRole
+from mpulsweb.lib.db import  PostgresDBInterface
+from mpulsweb.lib.navigation import  mark_folderopen
+
+from mpulsweb.lib.base import BaseController, render
+from mpulsweb.lib.renderer import ViewRenderer, RepeatGroupRenderer, \
+     ErrorRenderer, apply_hidden_booleans
+from mpulsweb.lib.helpers import url_for, dd_mm_YYYY as format_date
+
+from waskoweb.model.agencysettings import Agency
+
+class FormularpageController(FormularpageController):
+    @checkRole(('cm_ka'))
+    def save(self):
+        """
+        Overwrite the save method to allow for the automatic generation of the
+        evaluation ID
+        """
+        factory = InstanceFactory(g.formedTree, PostgresDBInterface())
+        instance_tree = factory.loadInstanceTreeByIdentifier(
+            session['case'].id,
+            session.get('uncommited_fields'))
+        page_id = request.params['page']
+        try:
+            form_result = convert2dic(request.params)
+            apply_hidden_booleans(form_result)
+
+            # Special logic for the Evaluation-ID
+            if request.params['page'].split(':')[0] == 'page-2':
+                case_id = request.params['page'].split(':')[1]
+                
+                # Reset the evaluation number is the young adult does not want
+                # to participate in the survey or does not want his personal
+                # data to be used
+                if form_result['teilnahme_evaluation:%s' % case_id] in \
+                [u'-1', u'1', u'3', u'4', u'5']:
+                    form_result['evaluation_nummer:%s' % case_id] = u''
+                
+                # The evaluation_nummer field might be grayed out, so it won't
+                # be in the sent fields dictionary
+                elif 'evaluation_nummer:%s' % case_id not in form_result:
+                    agency = Agency()
+                    # Generate the ID (we do not check for uniqueness). It is
+                    # created from the evaluation abbreviation (agency wide) and
+                    # a manually entered number or sequence
+                    form_result['evaluation_nummer:%s' % case_id] = \
+                        u"%s-(bitte ergaenzen)" % (agency.getEvaluationId()
+            
+            instance_tree.setData(form_result)
+            session['uncommited_fields'] = instance_tree.commit()
+            session.save()
+            
+            # How to proceed after saving the data?
+            for param in request.params:
+                if param.startswith('add_rg') and not param.endswith(('x','y')):
+                    if param == 'add_rg':
+                        redirect_to(controller='/repeatgroup', action="new",
+                                    id=request.params.get('add_rg'))
+                    else:
+                        redirect_to(controller='/repeatgroup', action="new",
+                                    id=param.split('|')[1])
+                elif param.startswith('del_rg') and not param.endswith(('x','y')):
+                    redirect_to(controller='/repeatgroup', action="delete",
+                                id=param.split('|')[1])
+            
+            if request.params.has_key('savenext'):
+                page_id = session['navigation.tree'].getTreeItem(page_id).nextKey().key
+
+            # Check consistence of case and retag
+            if g.mpuls_config.is_enabled ('case-module', 'checktags'):
+                # TODO: Implement application based tagging
+                pass
+                #log.debug('Tagging case: %s' % session['case'].id)
+
+        except SetDataException, err:
+            # Do nothing other than setting the status message. In the future the
+            # exception can be used to fill out the form again with htmlfill,
+            # which will clean up the renderer code a lot! But this is for the
+            # future
+            #error_status(_('Error while saving data'))
+            session['uncommited_fields'] = instance_tree.commit()
+            session.save()
+
+        return self.select(page_id)
\ No newline at end of file

Added: wasko/trunk/waskoweb/model/agencysettings.py
===================================================================
--- wasko/trunk/waskoweb/model/agencysettings.py	2010-07-14 12:17:10 UTC (rev 3186)
+++ wasko/trunk/waskoweb/model/agencysettings.py	2010-07-14 13:51:57 UTC (rev 3187)
@@ -0,0 +1,51 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright 2007, 2008 Intevation GmbH, Germany, <info at intevation.de>
+#
+# This file is part of mpuls WASKA (CoMPUter-based case fiLeS -
+# Web-Anwendungs-Server fuer Kompetenzagenturen).
+#
+# mpuls WASKA is free software: you can redistribute it and/or modify it under
+# the terms of the GNU Affero General Public License as published by the
+# Free Software Foundation, either version 3 of the License, or (at your
+# option) any later version.
+#
+# mpuls WASKA is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
+# License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with mpuls WASKA. If not, see <http://www.gnu.org/licenses/>.
+#
+# mpuls WASKA has been developed on behalf of the
+# Projekttraeger im Deutschen Zentrum fuer Luft- und Raumfahrt e.V. (PT-DLR)
+# within the programme Kompetenzagenturen (Durchfuehrungsphase) funded by
+# the Bundesministerium fuer Familie, Senioren, Frauen und Jugend and
+# European Social Fund resources.
+#
+# Authors:
+# Roland Geider <roland.geider at intevation.de>
+#
+
+import sys
+import logging
+import traceback
+
+import psycopg2.extras
+
+from mpulsweb.lib.base import render
+from mpulsweb.lib.db import db
+from mpulsweb.lib.helpers import ensure_unicode
+
+from mpulsweb.model.agencysettings import Agency
+
+FETCH_SETTINGS_SQL = """SELECT bez, wert from ka_konfiguration_tbl_view"""
+STORE_SETTINGS_SQL = """\
+UPDATE ka_konfiguration_tbl_view SET wert = %(wert)s WHERE bez = %(bez)s"""
+
+log = logging.getLogger(__name__)
+
+class Agency(Agency):
+    def getEvaluationId(self):
+       return unicode(str(self.conf.get('evaluation_id', '')), 'utf-8')
\ No newline at end of file

Deleted: wasko/trunk/waskoweb/templates/settings
===================================================================
--- wasko/trunk/waskoweb/templates/settings	2010-07-14 12:17:10 UTC (rev 3186)
+++ wasko/trunk/waskoweb/templates/settings	2010-07-14 13:51:57 UTC (rev 3187)
@@ -1,135 +0,0 @@
-## -*- coding: utf-8 -*-
-<%inherit file="../main.mako" />
-<%
-  formular_labels = {'ka_name': _('adm_form_settings_kaname'),
-                     'fkz': _('adm_form_settings_fkz'),
-                     'max_speicherdauer': _('adm_form_settings_max_savetime')
-                    }
-%>
-<%def name="buildNavipath()">
-  ${parent.buildNavipath()}
-  <li>
-    <a href="${h.url_for(controller='/settings')}">${_('adm_np_root')}</a>
-  </li>
-  <li>
-    <a href="${h.url_for(controller='/settings', action='show')}">${_('adm_np_showsettings')}</a>
-  </li>
-  <li>
-    <a href="${h.url_for(controller='/settings', action='edit')}">${_('adm_np_editsettings')}</a>
-  </li>
-</%def>
-
-<div id="content_header_small">
-  <div id="content_ueberschrift">
-    ${_('adm_header_editsettings')}
-  </div>
-  <div id="modusfield">
-    <div class="actions">
-      <ul>
-        <li>
-          <a href="${h.url_for(controller='settings',
-                               action='show')}">
-            ${_('adm_actions_link_showsettings')}
-          </a>
-        </li>
-      </ul>
-    </div>
-  </div>
-</div>
-
-${self.buildFormErrors(formular_labels)}
-<div id="admin_edit_settings">
-  <p>${_('adm_con_es_editsettings')}</p>
-  <div class="waska_form">
-    <form action="${h.url_for(controller='/settings', action='editAction')}" method="POST">
-      <fieldset>
-        <legend>Angaben zur Einrichtung</legend>
-        <div class="waska_form_element w30">
-          <label for="ka_name">${_('adm_form_settings_kaname')}</label>
-          % if c.form_errors.get('ka_name'):
-            <input type="text" class="field error_box" id="ka_name"
-                   value="${c.form_result.get('ka_name', c.agency.getName())}"
-                   name="ka_name" maxlength="60">
-          % else:
-            <input type="text" class="field" id="ka_name" name="ka_name"
-                   value="${c.form_result.get('ka_name', c.agency.getName())}"
-                   maxlength="60">
-          % endif
-        </div>
-        <div class="waska_form_element w30">
-          <label for="ka_adresse">${_('adm_form_settings_kaadress')}</label>
-          % if c.form_errors.get('ka_adresse'):
-            <input type="text" class="field error_box" id="ka_adresse"
-                   value="${c.form_result.get('ka_adresse', c.agency.getAddress())}"
-                   name="ka_adresse" maxlength="120">
-          % else:
-            <input type="text" class="field" id="ka_adresse" name="ka_adresse"
-                   value="${c.form_result.get('ka_adresse', c.agency.getAddress())}"
-                   maxlength="120">
-          % endif
-        </div>
-        <div class="waska_form_element w30">
-          <label for="fkz">${_('adm_form_settings_fkz')}</label>
-          % if c.form_errors.get('fkz'):
-            <input type="text" class="error_box" id="fkz" name="fkz"
-                   value="${c.form_result.get('fkz', c.agency.getFKZ())}"
-                   maxlength="60">
-          % else:
-            <input type="text" id="fkz" name="fkz"
-                   value="${c.form_result.get('fkz', c.agency.getFKZ())}"
-                   maxlength="60">
-          % endif
-        </div>
-      </fieldset>
-      <fieldset>
-        <legend>Angaben zu den Fallakten</legend>
-        <div class="waska_form_element w100">
-          <label for="max_speicherdauer">
-            ${_('adm_form_settings_max_savetime')}
-          </label>
-          % if c.form_errors.get('max_speicherdauer'):
-            <input type="text" class="error_box" id="max_speicherdauer"
-                   name="max_speicherdauer"
-                   value="${c.form_result.get('max_speicherdauer',
-                                              c.agency.getMaxSavetime())}"
-                   maxlength="4">
-          % else:
-            <input type="text" id="max_speicherdauer" name="max_speicherdauer"
-                   value="${c.form_result.get('max_speicherdauer',
-                                              c.agency.getMaxSavetime())}"
-                   maxlength="4">
-          % endif
-          <p class="info">
-            Automatische Wiedervorlagen dienen zum Auffinden von Fallakten, die länger als der angegebene Wert nicht bearbeitet wurden. Neben diesem Kriterium kann es weitere Bedingungen geben ab wann eine Wiedervorlage erstellt wird. Weitere Bedingungen: ${g.mpuls_config.get('case', 'reminderconditiondesc')}
-          </p>
-        </div>
-        <div class="waska_form_element w100">
-          % if c.form_errors.get('anon_transfer'):
-            <a href="#error_list">
-              <img class="smallicon" alt="" src="${h.url_for('/images/icons/info/failure_22.png')}">
-            </a>
-          % endif
-          % if c.agency.isAnonTransfer():
-            <input id="anon_transfer" name="anon_transfer" type="checkbox"
-                   checked />
-          % else:
-            <input id="anon_transfer" name="anon_transfer" type="checkbox"/>
-          % endif
-          <label for="anon_transfer">
-            ${_('adm_form_settings_anontransfer')}
-          </label>
-          <p>
-            Ist die Option aktiviert, werden anonymisierte Fallakten zu
-            Auswertungszwecken an eine zentrale Einrichtung
-            übermittelt. Anonymisierte Fallakten enthalten keine
-            persönlichen Daten wie Namen oder Adressen.
-          </p>
-        </div>
-      </fieldset>
-      <div id="admin_edit_settings_submit" class="waska_form_element w100">
-        <input type="submit" value="${_('adm_form_settings_save')}">
-      </div>
-    </form>
-  </div>
-</div>
-



More information about the Mpuls-commits mailing list