[Mpuls-commits] r5690 - base/trunk/mpulsweb/controllers
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri Dec 2 12:47:00 CET 2011
Author: ludwig
Date: 2011-12-02 12:47:00 +0100 (Fri, 02 Dec 2011)
New Revision: 5690
Modified:
base/trunk/mpulsweb/controllers/casedocument.py
base/trunk/mpulsweb/controllers/document.py
Log:
Issue 2732: remove the _check_filename method and use a db lookup to get the
list of documents.
Modified: base/trunk/mpulsweb/controllers/casedocument.py
===================================================================
--- base/trunk/mpulsweb/controllers/casedocument.py 2011-12-02 11:21:08 UTC (rev 5689)
+++ base/trunk/mpulsweb/controllers/casedocument.py 2011-12-02 11:47:00 UTC (rev 5690)
@@ -18,7 +18,8 @@
from mpulsweb.lib.security import checkRole
import mpulsweb.lib.helpers as h
-from mpulsweb.model.document import Document, deleteDocument, renameDocument
+from mpulsweb.model.document import Document, deleteDocument, renameDocument, \
+ listDocuments
log = logging.getLogger(__name__)
@@ -34,8 +35,6 @@
id = self._checkInt(id)
case = self._loadCase(id, read_only=True)
c.files = case.getDocuments()
- session['document_files'] = self.create_document_list(c.files)
- session.save()
return render('/documents/case_overview.mako')
def create_document_list(self, files):
@@ -132,10 +131,11 @@
@checkRole('cm')
def rename(self, id, confirmed='0'):
c.id = self._checkInt(id)
- for doc in session['document_files']:
- if int(doc[0]) == c.id:
- c.name = doc[1]
- c.description = doc[2]
+ docs = listDocuments(session['case'].id)
+ for doc in docs:
+ if int(doc.id) == c.id:
+ c.name = doc.getName()
+ c.description = doc.description
break
if not c.name:
c.name = ""
@@ -160,8 +160,6 @@
desc = result['description']
else:
desc = ""
- while not self._check_filename(filename, id):
- filename += "X"
renameDocument(id, filename, desc, True)
except formencode.Invalid, error:
c.form_result = error.value
@@ -173,10 +171,3 @@
auto_insert_errors=False,
errors=c.form_errors)
return self.overview(session['case'].id)
-
- def _check_filename(self, name, id):
- found_other = False
- for doc in session['document_files']:
- if int(doc[0]) != int(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 11:21:08 UTC (rev 5689)
+++ base/trunk/mpulsweb/controllers/document.py 2011-12-02 11:47:00 UTC (rev 5690)
@@ -58,8 +58,6 @@
def globalOverview(self):
try:
c.files = listDocuments()
- session['document_files'] = self.create_document_list(c.files)
- session.save()
except Exception, e:
log.exception(e)
raise
@@ -153,10 +151,12 @@
def globalRename(self, id):
c.id = self._checkInt(id)
- for doc in session['document_files']:
- if int(doc[0]) == c.id:
- c.name = doc[1]
- c.description = doc[2]
+ docs = listDocuments()
+
+ for doc in docs:
+ if int(doc.id) == c.id:
+ c.name = doc.getName()
+ c.description = doc.description
break
if not c.name:
@@ -182,8 +182,6 @@
desc = result['description']
else:
desc = ""
- while not self._check_filename(filename, id):
- filename += "X"
renameDocument(id, filename, desc)
except formencode.Invalid, error:
c.form_result = error.value
@@ -196,11 +194,4 @@
errors=c.form_errors)
return self.globalOverview()
- def _check_filename(self, name, id):
- found_other = False
- for doc in session['document_files']:
- if int(doc[0]) != int(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