[Mpuls-commits] r5685 - in base/trunk/mpulsweb: controllers templates/casemanagement templates/documents

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Dec 2 10:57:46 CET 2011


Author: ludwig
Date: 2011-12-02 10:57:45 +0100 (Fri, 02 Dec 2011)
New Revision: 5685

Modified:
   base/trunk/mpulsweb/controllers/casedocument.py
   base/trunk/mpulsweb/controllers/document.py
   base/trunk/mpulsweb/templates/casemanagement/rename_attachment.mako
   base/trunk/mpulsweb/templates/documents/global_rename.mako
Log:
Issue 2732 Part2: Preselect old name and description value in the document
rename pages.


Modified: base/trunk/mpulsweb/controllers/casedocument.py
===================================================================
--- base/trunk/mpulsweb/controllers/casedocument.py	2011-12-01 14:26:49 UTC (rev 5684)
+++ base/trunk/mpulsweb/controllers/casedocument.py	2011-12-02 09:57:45 UTC (rev 5685)
@@ -34,7 +34,17 @@
         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):
+        """Creates a list of the documents, containing (id,name, description).
+        So in renameDocument this data can be accessed. """
+        document_list = []
+        for doc in files:
+            document_list.append((doc.id, doc.name, doc.description))
+        return document_list
 
     @checkRole('cm')
     def new(self):
@@ -122,6 +132,16 @@
     @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]
+                break
+        if not c.name:
+            c.name = ""
+        if not c.description:
+            c.description = ""
+
         return render('/casemanagement/rename_attachment.mako')
 
     @checkRole('cm')

Modified: base/trunk/mpulsweb/controllers/document.py
===================================================================
--- base/trunk/mpulsweb/controllers/document.py	2011-12-01 14:26:49 UTC (rev 5684)
+++ base/trunk/mpulsweb/controllers/document.py	2011-12-02 09:57:45 UTC (rev 5685)
@@ -36,7 +36,7 @@
 import paste
 
 from mpulsweb.lib.base import BaseController, c, h, redirect_to, render, \
-                              request, g
+                              request, g, session
 from mpulsweb.lib.security import checkRole
 from mpulsweb.lib.validators import UploadGlobalDocumentForm, \
                                     UploadGlobalDocumentWDescForm, \
@@ -58,11 +58,21 @@
     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
         return render('/documents/global_overview.mako')
 
+    def create_document_list(self, files):
+        """Creates a list of the documents, containing (id,name, description).
+        So in renameDocument this data can be accessed. """
+        document_list = []
+        for doc in files:
+            document_list.append((doc.id, doc.name, doc.description))
+        return document_list
+
     @checkRole('admin')
     def globalUpload(self):
         return render('/documents/global_upload.mako')
@@ -140,8 +150,20 @@
             return render('/documents/dialogs/confirm.mako')
     
     @checkRole('admin')
-    def globalRename(self, id, confirmed='0'):
+    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]
+                break
+        
+        if not c.name:
+            c.name = ""
+        if not c.description:
+            c.description = ""   
+        
         return render('/documents/global_rename.mako')
 
     @checkRole('admin')

Modified: base/trunk/mpulsweb/templates/casemanagement/rename_attachment.mako
===================================================================
--- base/trunk/mpulsweb/templates/casemanagement/rename_attachment.mako	2011-12-01 14:26:49 UTC (rev 5684)
+++ base/trunk/mpulsweb/templates/casemanagement/rename_attachment.mako	2011-12-02 09:57:45 UTC (rev 5685)
@@ -36,7 +36,7 @@
       <td class="label">
         <label for="name">${_('Filename')}</label></td>
       <td class="">
-        <input type="text" name="name" id="name"><br>
+        <input type="text" name="name" id="name" value=${c.name}><br>
       </td>
       <td class=""><span class="error"><form:error name="name"></span></td>
     </tr>
@@ -45,7 +45,7 @@
 	<td class="label">
         <label for="description">${_('Description')}</label></td>
       <td class="">
-        <input type="text" name="description" id="description" style="width: auto;"><br>
+        <input type="text" name="description" id="description" style="width: auto;" value=${c.description}><br>
       </td>
       <td class=""><span class="error"><form:error name="description"></span></td>
     </tr>

Modified: base/trunk/mpulsweb/templates/documents/global_rename.mako
===================================================================
--- base/trunk/mpulsweb/templates/documents/global_rename.mako	2011-12-01 14:26:49 UTC (rev 5684)
+++ base/trunk/mpulsweb/templates/documents/global_rename.mako	2011-12-02 09:57:45 UTC (rev 5685)
@@ -37,7 +37,7 @@
       <td class="label">
         <label for="name">${_('Filename')}</label></td>
       <td class="">
-        <input type="text" name="name" id="name"><br>
+        <input type="text" name="name" id="name" value=${c.name}><br>
       </td>
       <td class=""><span class="error"><form:error name="name"></span></td>
     </tr>
@@ -46,7 +46,7 @@
 	<td class="label">
         <label for="description">${_('Description')}</label></td>
       <td class="">
-        <input type="text" name="description" id="description" style="width: auto;"><br>
+        <input type="text" name="description" id="description" style="width: auto;" value=${c.description}><br>
       </td>
       <td class=""><span class="error"><form:error name="description"></span></td>
     </tr>



More information about the Mpuls-commits mailing list