[Mpuls-commits] r256 - in wasko/trunk: . formed waskaweb/controllers waskaweb/lib waskaweb/model waskaweb/templates/casemanagement
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Wed Feb 11 15:48:44 CET 2009
Author: torsten
Date: 2009-02-11 15:48:41 +0100 (Wed, 11 Feb 2009)
New Revision: 256
Modified:
wasko/trunk/ChangeLog.txt
wasko/trunk/formed/privacy_statement.html
wasko/trunk/waskaweb/controllers/case.py
wasko/trunk/waskaweb/lib/validators.py
wasko/trunk/waskaweb/model/case.py
wasko/trunk/waskaweb/model/statement.py
wasko/trunk/waskaweb/templates/casemanagement/new.mako
Log:
Make creation of cases work
Modified: wasko/trunk/ChangeLog.txt
===================================================================
--- wasko/trunk/ChangeLog.txt 2009-02-11 11:46:29 UTC (rev 255)
+++ wasko/trunk/ChangeLog.txt 2009-02-11 14:48:41 UTC (rev 256)
@@ -1,5 +1,23 @@
2009-02-11 Sascha L. Teichmann <teichmann at intevation.de>
+ Make creation of cases work
+
+ * formed/privacy_statement.html,
+ waskaweb/model/statement.py: Added STRASSENR keyword for
+ substitution.
+
+ * waskaweb/model/case.py: Load strassenr additionally when loading
+ a case. Modified createNew Function. It now takes an additional
+ param with the values from the new case form. The case will then be
+ initialised on creation.
+ * waskaweb/controllers/case.py,
+ waskaweb/lib/validators.py: Cleanup. Removed old code where the case
+ data was set with the page data mechanism.
+ * waskaweb/templates/casemanagement/new.mako: Added new field for
+ strassenr.
+
+2009-02-11 Sascha L. Teichmann <teichmann at intevation.de>
+
* waskaweb/model/data.py: Little workaround to get after
case creation.
Modified: wasko/trunk/formed/privacy_statement.html
===================================================================
--- wasko/trunk/formed/privacy_statement.html 2009-02-11 11:46:29 UTC (rev 255)
+++ wasko/trunk/formed/privacy_statement.html 2009-02-11 14:48:41 UTC (rev 256)
@@ -37,7 +37,7 @@
<br>
wohnhaft in<br>
<br>
-<strong>Straße:</strong> $STRASSE <strong>PLZ/Ort:</strong>$PLZ / $ORT</p>
+<strong>Straße:</strong> $STRASSE $STRASSENR <strong>PLZ/Ort:</strong>$PLZ / $ORT</p>
<p>
ein, dass mich die Kompetenzagentur $KA_NAME im Rahmen ihrer Aufgabe bei meiner
beruflichen und sozialen Eingliederung unterstützt und hierzu die für diesen
Modified: wasko/trunk/waskaweb/controllers/case.py
===================================================================
--- wasko/trunk/waskaweb/controllers/case.py 2009-02-11 11:46:29 UTC (rev 255)
+++ wasko/trunk/waskaweb/controllers/case.py 2009-02-11 14:48:41 UTC (rev 256)
@@ -341,41 +341,14 @@
form_result = validator.to_python(request.params)
# 1. Create a new case
factory = CaseFactory()
- case = factory.createNew()
+ case = factory.createNew(data=form_result)
statement = case.getPrivacyStatement()
# 2. Do we want to sign the statement?
- if form_result.has_key('statement_signed'):
+ if form_result.get('statement_signed'):
statement.sign()
self.__init_case(case.id)
- # 3. Get Page from case and store the data
- # TODO: Enable this is the future
-
- # This filter fixes issue45. The proxy returns only elements
- # which are in the params. This way only those values get
- # modified and no other values will be set to NULL.
-
-
- # TODO: WASKO seems to crash here while loading the page_1.
- filter = FilteredNodeComponentProxy(request.params.dict_of_lists())
-
- document = g.formedTree
- page = document.getPageStore("page_1", proxy=filter)
- page.setId(case.id)
-
- new_errors = page.save(
- request.params.dict_of_lists(),
- {}, document)
-
- session_case.setFormErrors(new_errors)
- session.save()
-
- # Prepare params so that _save will eat them an gets all needed
- # values
- new_params = request.params.dict_of_lists()
- new_params['ds'] = [case.id]
-
load_case(case.id)
except formencode.Invalid, error:
@@ -383,14 +356,7 @@
c.form_errors = error.error_dict or {}
return render('/casemanagement/new.mako')
- if statement.isSigned():
- return self.edit(str(case.id), '0')
- else:
- # Render Nagscreen to inform the user that he is about to open a
- # case which does not have a signed statement
- c.ds_id = case.id
- c.targeturl = h.url_for(controller="/case", action="select", id=c.ds_id, confirmed=1)
- return render('statement/dialogs/missing_statement.mako')
+ return self.select(str(case.id))
@checkRole('cm_ka')
def edit(self, ds_id, page_id):
Modified: wasko/trunk/waskaweb/lib/validators.py
===================================================================
--- wasko/trunk/waskaweb/lib/validators.py 2009-02-11 11:46:29 UTC (rev 255)
+++ wasko/trunk/waskaweb/lib/validators.py 2009-02-11 14:48:41 UTC (rev 256)
@@ -257,7 +257,12 @@
form_section_17 = formencode.validators.Int(if_missing=0)
class NewCaseForm(BaseFormValidator):
- pass
+ name_1 = formencode.validators.String()
+ vorname_1 = formencode.validators.String()
+ strasse = formencode.validators.String()
+ strassenr = formencode.validators.String()
+ wohnort = formencode.validators.String()
+ statement_signed = formencode.validators.Bool(if_missing=False)
class EditSettingsForm(BaseFormValidator):
anon_transfer = formencode.validators.String(if_missing='off')
Modified: wasko/trunk/waskaweb/model/case.py
===================================================================
--- wasko/trunk/waskaweb/model/case.py 2009-02-11 11:46:29 UTC (rev 255)
+++ wasko/trunk/waskaweb/model/case.py 2009-02-11 14:48:41 UTC (rev 256)
@@ -97,6 +97,7 @@
date_part('year', age(geburtsdatum::timestamp)) AS alter,
addresse_plz_1 as plz,
addresse_strasse_1 as strasse,
+ addresse_strassenr_1 as strassenr,
addresse_ort_1 as wohnort,
addresse1_vorwahl_1 as vorwahl,
addresse1_telefonnummer_1 as telefon_1,
@@ -115,6 +116,7 @@
DELETE_CASE_SQL = """select delete_master_ds(%(id)s)"""
CREATE_CASE_SQL = """SELECT create_master_ds(%(uuid)s)"""
+UPDATE_CASE_ON_CREATE_SQL = """UPDATE master_tbl_view set name = %(name)s, vorname = %(vorname)s, einwilligung = %(einwilligung)s, addresse_strassenr_1 = %(strassenr)s, addresse_strasse_1 = %(strasse)s, addresse_plz_1 = %(plz)s, addresse_ort_1 = %(ort)s WHERE id = %(id)s"""
INIT_CASE_SQL= """UPDATE page_0_view SET ks = %(ka_name)s, fkz = %(fkz)s, mitarb_zv = %(vorname)s, mitarb_zn = %(nachname)s WHERE id = %(id)s"""
CREATE_RG_KOMPETENZ_DS = """SELECT create_rg_kompetenz_ds(%(id)s, %(uuid)s)"""
@@ -402,7 +404,7 @@
case.privacy_statement_signed = einverst in (1, -1) and True or False
return case
- def createNew(self, init=True, uuid=None):
+ def createNew(self, init=True, uuid=None, data=None):
'''This method creates a new case in the database and takes care about
creating the right dependencies for repeat groups. If 'init' is true
will get initiated. This method returns the case object'''
@@ -414,6 +416,8 @@
cur.execute(CREATE_CASE_SQL, {'uuid': uuid})
id = int(cur.fetchone()[0])
conn.commit()
+ if data:
+ self._updateMasterOnCreate(id, data)
finally:
db.recycleConnection(conn, cur)
# XXX: This a workaround the RGs
@@ -432,6 +436,30 @@
case.id = id
return case
+ def _updateMasterOnCreate(self, id, data):
+ conn, cur = None, None
+ try:
+ user = session['USER_AUTHORIZED']
+ agency = Agency()
+ statement = data.get('statement_signed') and 1 or -1
+
+ fields = {
+ 'strasse': data.get('strasse'),
+ 'strassenr': data.get('strassenr'),
+ 'plz': data.get('plz'),
+ 'ort': data.get('wohnort'),
+ 'name': data.get('name_1'),
+ 'vorname': data.get('vorname_1'),
+ 'einwilligung': statement,
+ 'id': id
+ }
+ conn = db.getConnection()
+ cur = conn.cursor()
+ cur.execute(UPDATE_CASE_ON_CREATE_SQL, fields)
+ conn.commit()
+ finally:
+ db.recycleConnection(conn, cur)
+
def _initNewCase(self, id):
conn, cur = None, None
try:
@@ -646,6 +674,7 @@
self.plz = ''
self.city = ''
self.street = ''
+ self.streetnr = ''
self.email = ''
self.telephone_1 = ''
self.telephone_2 = ''
@@ -683,6 +712,7 @@
self.knr = unicode(str(result.get('kundennummer')), 'utf-8')
self.plz = unicode(str(result.get('plz', '')), 'utf-8')
self.street = unicode(str(result.get('strasse', '')), 'utf-8')
+ self.streetnr = unicode(str(result.get('strassenr', '')), 'utf-8')
self.city = unicode(str(result.get('wohnort', '')), 'utf-8')
self.telephone_1 = unicode(str(result.get('vorwahl', '')), 'utf-8')
self.telephone_2 = unicode(str(result.get('telefon_1', '')), 'utf-8')
@@ -719,9 +749,10 @@
self.first_meeting = None
self.privacy_statement = False
- self.street = None
- self.plz = None
- self.city = None
+ self.street = None
+ self.streetnr = None
+ self.plz = None
+ self.city = None
def getState(self):
return self.state
@@ -754,6 +785,7 @@
self.last_name = save_getone(params, "name_1", "")
self.first_name = save_getone(params, "vorname_1", "")
self.street = save_getone(params, "strasse", "")
+ self.streetnr = save_getone(params, "strassenr", "")
self.plz = save_getone(params, "plz", "")
self.city = save_getone(params, "wohnort", "")
Modified: wasko/trunk/waskaweb/model/statement.py
===================================================================
--- wasko/trunk/waskaweb/model/statement.py 2009-02-11 11:46:29 UTC (rev 255)
+++ wasko/trunk/waskaweb/model/statement.py 2009-02-11 14:48:41 UTC (rev 256)
@@ -100,6 +100,7 @@
'NACHNAME': F.NA(client.last_name),
'PLZ': F.NA(client.plz),
'STRASSE': F.NA(client.street),
+ 'STRASSENR': F.NA(client.streetnr),
'ORT': F.NA(client.city),
'KA_NAME': F.NA(agency.getName()),
'KA_SPEICHERDAUER': F.NA(agency.getMaxSavetime())
Modified: wasko/trunk/waskaweb/templates/casemanagement/new.mako
===================================================================
--- wasko/trunk/waskaweb/templates/casemanagement/new.mako 2009-02-11 11:46:29 UTC (rev 255)
+++ wasko/trunk/waskaweb/templates/casemanagement/new.mako 2009-02-11 14:48:41 UTC (rev 256)
@@ -16,11 +16,15 @@
<label for="name_1">Name:</label>
<input class="field" type="text" size="50" maxlength="60" name="name_1" id="name_1" value="${c.case.last_name or ""}">
</div>
-<div class="waska_form_element w100">
+<div class="waska_form_element w75">
<label for="strasse">Strasse:</label>
<input class="field" type="text" size="50" maxlength="60" name="strasse" id="strasse" value="${c.case.street or ""}">
</div>
<div class="waska_form_element w25">
+<label for="strassenr">Strasse Nr.:</label>
+<input class="field" type="text" size="50" maxlength="60" name="strassenr" id="strassenr" value="${c.case.streetnr or ""}">
+</div>
+<div class="waska_form_element w25">
<label for="plz">PLZ:</label>
<input class="field" type="text" size="50" maxlength="60" name="plz" id="plz" value="${c.case.plz or ""}">
</div>
More information about the Mpuls-commits
mailing list