[Mpuls-commits] r5376 - base/trunk/mpulsweb/controllers

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Sep 20 13:52:40 CEST 2011


Author: torsten
Date: 2011-09-20 13:52:40 +0200 (Tue, 20 Sep 2011)
New Revision: 5376

Modified:
   base/trunk/mpulsweb/controllers/meta.py
Log:
Changed the way how the hash value ist generated. Now use additionally the
first two letters of the firstname of mother and father, to raise the possible
values for the hash.


Modified: base/trunk/mpulsweb/controllers/meta.py
===================================================================
--- base/trunk/mpulsweb/controllers/meta.py	2011-09-20 11:49:37 UTC (rev 5375)
+++ base/trunk/mpulsweb/controllers/meta.py	2011-09-20 11:52:40 UTC (rev 5376)
@@ -22,10 +22,13 @@
 
 log = logging.getLogger(__name__)
 
-def generate_hash(birthname, firstname, birthdate, gender):
+def generate_hash(birthname, firstname, birthdate, gender, mother, father):
     '''Return hash build from birthname, firstname, birthdate and gender'''
+    mother = mother[0:1].lower()
+    father = father[0:1].lower()
     hashsrc = ":".join([str(len(birthname)), str(len(firstname)),
-                        birthdate.strftime('%Y-%m-%d'), str(gender)])
+                        birthdate.strftime('%Y-%m-%d'), str(gender),
+                        mother,father])
     return hashlib.sha256(hashsrc.encode('utf-8')).hexdigest()
 
 
@@ -35,12 +38,16 @@
               "Firstname: %(firstname)s<br>\n"
               "Birthdate: %(birthdate)s<br>\n"
               "Gender: %(gender)s<br>\n"
+              "Firstname Mother: %(firstname_mother)s<br>\n"
+              "Firstname Father: %(firstname_father)s<br>\n"
               "<br>")
             % dict(birthname=escape(session['meta_birthname']),
                    firstname=escape(session['meta_firstname']),
                    birthdate=escape(format_date(session['meta_birthdate'])),
                    gender=escape(_("male") if session['meta_gender'] == "1"
-                                 else _("female"))))
+                                 else _("female")),
+                   firstname_mother=escape(session['meta_firstname_mother']),
+                   firstname_father=escape(session['meta_firstname_father'])))
 
 
 uuid_characters = set("0123456789abcdefABCDEF-")
@@ -228,7 +235,10 @@
             firstname = form_result.get('firstname')
             birthdate = form_result.get('birthdate')
             gender = form_result.get('gender')
-            hash = generate_hash(birthname, firstname, birthdate, gender)
+            mother = form_result.get('firstname_mother')
+            father = form_result.get('firstname_father')
+            hash = generate_hash(birthname, firstname, birthdate, 
+                                 gender, mother, father)
 
             # Save values in session because the values may be used to create a
             # new meta-case
@@ -236,6 +246,8 @@
             session['meta_firstname'] = form_result.get('firstname')
             session['meta_birthdate'] = form_result.get('birthdate')
             session['meta_gender'] = form_result.get('gender')
+            session['meta_firstname_mother'] = form_result.get('firstname_mother')
+            session['meta_firstname_father'] = form_result.get('firstname_father')
             session.save()
 
             form_defaults = validator.from_python(form_result)
@@ -282,7 +294,10 @@
         hash = generate_hash(session.get('meta_birthname'),
                              session.get('meta_firstname'),
                              session.get('meta_birthdate'),
-                             session.get('meta_gender'))
+                             session.get('meta_gender'),
+                             session.get('meta_firstname_mother'),
+                             session.get('meta_firstname_father'),
+                             )
 
         try:
             meta.create(hash)
@@ -290,6 +305,8 @@
             del session['meta_firstname']
             del session['meta_birthdate']
             del session['meta_gender']
+            del session['meta_firstname_mother']
+            del session['meta_firstname_father']
             session.save()
             return success(header=_('Meta case created.'),
                            text=_('The meta case was sucessfully created and'



More information about the Mpuls-commits mailing list