[Mpuls-commits] r3049 - in base/trunk: . mpulsweb/controllers mpulsweb/lib mpulsweb/templates/casemanagement

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Jun 21 15:30:03 CEST 2010


Author: torsten
Date: 2010-06-21 15:30:01 +0200 (Mon, 21 Jun 2010)
New Revision: 3049

Modified:
   base/trunk/ChangeLog
   base/trunk/mpulsweb/controllers/case.py
   base/trunk/mpulsweb/lib/validators.py
   base/trunk/mpulsweb/templates/casemanagement/new.mako
Log:
Implemented basic creation of cases in base.


Modified: base/trunk/ChangeLog
===================================================================
--- base/trunk/ChangeLog	2010-06-21 13:19:30 UTC (rev 3048)
+++ base/trunk/ChangeLog	2010-06-21 13:30:01 UTC (rev 3049)
@@ -1,5 +1,13 @@
 2010-06-21  Torsten Irländer <torsten.irlaender at intevation.de>
 
+	* mpulsweb/controllers/case.py,
+	  mpulsweb/lib/validators.py,
+	  mpulsweb/templates/casemanagement/new.mako: Implemented basic
+	  creation of cases. No addional data is set beside, bearbeiter_id and
+	  einverstaendnis.
+
+2010-06-21  Torsten Irländer <torsten.irlaender at intevation.de>
+
 	* mpulsweb/model/case.py (MpulsCaseFactory._initNewCase): Added pass
 	statement
 

Modified: base/trunk/mpulsweb/controllers/case.py
===================================================================
--- base/trunk/mpulsweb/controllers/case.py	2010-06-21 13:19:30 UTC (rev 3048)
+++ base/trunk/mpulsweb/controllers/case.py	2010-06-21 13:30:01 UTC (rev 3049)
@@ -11,11 +11,12 @@
 from mpulsweb.lib.base import BaseController, render, h
 from mpulsweb.lib.security import checkRole
 from mpulsweb.lib.dialogs import checkPrivacyStatement
-from mpulsweb.lib.validators import SetStandinForm, SetEditorForm
+from mpulsweb.lib.validators import SetStandinForm, SetEditorForm, NewCaseForm
 from mpulsweb.lib.anonymize import determineAnonymizedCaseEndPhaseName
 from mpulsweb.model.case import ConsistenceCheckException, SessionCase
 from mpulsweb.model.user import UserGroupList, UserListObject
 from mpulsweb.model.logbook import LogbookEntry
+from mpulsweb.controllers.formularpage import convert2dic
 
 from mpulsweb.controllers.formularpage import get_rendered_page
 
@@ -293,6 +294,57 @@
         c.case = session.get('case')
         return render('/casemanagement/new.mako')
 
+    @checkRole('cm_ka')
+    def newAction(self):
+        # TODO: Use htmlfill here!
+        session_case = SessionCase()
+        session_case.setData(request.params)
+
+        session['case'] = session_case
+        session.save()
+
+        # Do we want to print the statement?
+        if request.params.has_key('print'):
+            c.print_version = 1
+            statement = PrivacyStatement(session_case, Agency())
+            c.content = statement.fillout()
+            return render('privacy/default_statement.mako')
+
+        # Or do we want to store the new case?
+        elif request.params.has_key('save'):
+            validator = NewCaseForm()
+            try:
+                form_result = validator.to_python(request.params)
+                # 1. Create a new case
+                case = g.case_factory.createNew(data=convert2dic({}))
+                case._load_formed_instance_tree()
+                # Set data
+                data = {}
+                for k in convert2dic(form_result).keys():
+                    try:
+                        item = case.formed_instance.getAllItemsForName(k)[0]
+                        id = ":".join(item.getIdentifier().split(':')[1:])
+                        data["%s:%s" % (k,id)] = form_result.get(k) 
+                    except:
+                        # some values within the formresult can not be found in
+                        # instance tree. e.g "statement_signed"
+                        pass
+                case.formed_instance.setData(data)
+                case.formed_instance.commit()
+
+                statement = case.getPrivacyStatement()
+                # 3. Do we want to sign the statement?
+                if form_result.get('statement_signed'):
+                    statement.sign()
+
+            except formencode.Invalid, error:
+                log.debug("Invalid form data: %r", error)
+                c.form_result = error.value
+                c.form_errors = error.error_dict or {}
+                return render('/casemanagement/new.mako')
+
+        return self.select(str(case.id))
+
     @checkRole('cm')
     def copy(self, id, confirmed=0):
         id = self._checkInt(id)

Modified: base/trunk/mpulsweb/lib/validators.py
===================================================================
--- base/trunk/mpulsweb/lib/validators.py	2010-06-21 13:19:30 UTC (rev 3048)
+++ base/trunk/mpulsweb/lib/validators.py	2010-06-21 13:30:01 UTC (rev 3049)
@@ -641,4 +641,7 @@
     user_id = Int()
     case_id = ForEach(Int())
 
+class NewCaseForm(BaseFormValidator):
+    statement_signed = Bool(if_missing=False)
+
 # vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8

Modified: base/trunk/mpulsweb/templates/casemanagement/new.mako
===================================================================
--- base/trunk/mpulsweb/templates/casemanagement/new.mako	2010-06-21 13:19:30 UTC (rev 3048)
+++ base/trunk/mpulsweb/templates/casemanagement/new.mako	2010-06-21 13:30:01 UTC (rev 3049)
@@ -13,99 +13,13 @@
     <h1>Neue Fallakte anlegen</h1>
     <fieldset>
       <legend>Basisdaten</legend>
-      <table>
-        <tr>
-          <td class="label">
-            <label for="name">Name:</label>
-          </td>
-          <td>
-            <input class="field" type="text" size="50" maxlength="60"
-                   name="name" id="name" value="${c.case.last_name or ""}">
-          </td>
-        </tr>
-        <tr>
-          <td class="label">
-            <label for="vorname">Vorname:</label>
-          </td>
-          <td>
-            <input class="field" type="text" size="50" maxlength="60"
-                   name="vorname" id="vorname"
-                   value="${c.case.first_name or ""}">
-          </td>
-        </tr>
-        ##<tr>
-        ##  <td class="label">
-        ##    <label for="addresse_strasse">Strasse:</label>
-        ##  </td>
-        ##  <td>
-        ##    <input class="field" type="text" size="50" maxlength="60" 
-        ##           name="addresse_strasse" id="addresse_strasse" 
-        ##           value="${c.case.street or ""}">
-        ##  </td>
-        ##</tr>
-        ##<tr>
-        ##  <td class="label">
-        ##    <label for="addresse_strassenr">Strasse Nr.:</label>
-        ##  </td>
-        ##  <td>
-        ##    <input class="field" type="text" size="50" maxlength="60" 
-        ##           name="addresse_strassenr" id="addresse_strassenr" 
-        ##           value="${c.case.streetnr or ""}">
-        ##  </td>
-        ##</tr>
-        ##<tr>
-        ##  <td class="label">
-        ##    <label for="addresse_plz">PLZ:</label>
-        ##  </td>
-        ##  <td>
-        ##    <input class="field" type="text" size="50" maxlength="60"
-        ##           name="addresse_plz" id="addresse_plz" 
-        ##           value="${c.case.plz or ""}">
-        ##  </td>
-        ##</tr>
-        ##<tr>
-        ##  <td class="label">
-        ##    <label for="addresse_ort">Ort:</label>
-        ##  </td>
-        ##  <td>
-        ##    <input class="field" type="text" size="50" maxlength="60" 
-        ##           name="addresse_ort" id="addresse_ort" 
-        ##           value="${c.case.city or ""}">
-        ##  </td>
-        ##</tr>
-      </table>
+      <p><font color="red">Bitte beachten Sie, dass das Vorgabe Template zum Anlegen von neuen
+      Datensätzen keine Eingabe von Daten ermöglicht. Bitte erstellen Sie ein
+      projektspezifisches Template und passende Controller-Funktion</font></p>
     </fieldset>
     <div style="padding: 1em 0;">
       <p>${_('cm_new_p_please_consider_statement')}</p>
     </div>
-    ##<div class="waska_form_element w100">
-    ##  Als PDF-Version verfügbare Einverständniserklärungen zum
-    ##  handschriftlichen Ausfüllen:
-    ##  <table>
-    ##    <tr>
-    ##      <td class="table_row_h">
-    ##        Arabisch <a href="${h.url_for('/documents/ee_ar.pdf')}">download</a>
-    ##      </td>
-    ##      <td class="table_row_h">
-    ##        Englisch <a href="${h.url_for('/documents/ee_en.pdf')}">download</a>
-    ##      </td>
-    ##    </tr>
-    ##    <tr>
-    ##      <td>Polnisch <a href="${h.url_for('/documents/ee_pl.pdf')}">download</a></td>
-    ##      <td>Russisch <a href="${h.url_for('/documents/ee_ru.pdf')}">download</a></td>
-    ##    </tr>
-    ##    <tr>
-    ##      <td class="table_row_h">
-    ##        Türkisch <a href="${h.url_for('/documents/ee_tr.pdf')}">download</a>
-    ##      </td>
-    ##      <td class="table_row_h">
-    ##        Deutsch
-    ##        (Einwilligungserklärung ohne Hinweise zu Teilnehmernachweisen)
-    ##        <a href="${h.url_for('/documents/ee_de_ohnetn.pdf')}">download</a>
-    ##      </td>
-    ##    </tr>
-    ##  </table>
-    ##</div>
     <div class="waska_form_element w100">
       <input type="checkbox" id="statement_signed" name="statement_signed"><label for="statement_signed">${_('cm_new_con_acceptance_statement_true')}</label>
     </div>



More information about the Mpuls-commits mailing list