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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Dec 2 11:31:26 CET 2011


Author: ludwig
Date: 2011-12-02 11:31:26 +0100 (Fri, 02 Dec 2011)
New Revision: 5686

Modified:
   base/trunk/mpulsweb/controllers/casedocument.py
   base/trunk/mpulsweb/controllers/document.py
Log:
Issue 2732: The name of a document stays unique in the db.
If in the rename dialog a collision name is choosen an X is added to the name.


Modified: base/trunk/mpulsweb/controllers/casedocument.py
===================================================================
--- base/trunk/mpulsweb/controllers/casedocument.py	2011-12-02 09:57:45 UTC (rev 5685)
+++ base/trunk/mpulsweb/controllers/casedocument.py	2011-12-02 10:31:26 UTC (rev 5686)
@@ -160,6 +160,8 @@
                 desc  = result['description'] 
             else:
                 desc = ""
+            while not self._check_filename(filename):
+                filename += "X"
             renameDocument(id, filename, desc, True)
         except formencode.Invalid, error:
             c.form_result = error.value
@@ -171,3 +173,10 @@
                                               auto_insert_errors=False,
                                               errors=c.form_errors)
         return self.overview(session['case'].id)
+
+    def _check_filename(self, name):
+        found_other = False
+        for doc in session['document_files']:
+            if int(doc[0]) != id and doc[1] == name:
+                found_other = True
+        return not found_other

Modified: base/trunk/mpulsweb/controllers/document.py
===================================================================
--- base/trunk/mpulsweb/controllers/document.py	2011-12-02 09:57:45 UTC (rev 5685)
+++ base/trunk/mpulsweb/controllers/document.py	2011-12-02 10:31:26 UTC (rev 5686)
@@ -182,6 +182,8 @@
                 desc  = result['description'] 
             else:
                 desc = ""
+            while not self._check_filename(filename):
+                filename += "X"
             renameDocument(id, filename, desc)
         except formencode.Invalid, error:
             c.form_result = error.value
@@ -193,4 +195,12 @@
                                               auto_insert_errors=False,
                                               errors=c.form_errors)
         return self.globalOverview()
+    
+    def _check_filename(self, name):
+        found_other = False
+        for doc in session['document_files']:
+            if int(doc[0]) != id and doc[1] == name:
+                found_other = True
+        return not found_other
+
 # vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:



More information about the Mpuls-commits mailing list