changeset 97:7b96a85552aa

fix bugs in project editing. only show images with captions in project description.
author casties
date Tue, 21 May 2013 15:51:32 +0200
parents 2dd8e3be4a8e
children d29425348cbd
files HashTree.py MPIWGProjects.py css/mpiwg.css zpt/project/edit_description.zpt zpt/project/edit_images.zpt zpt/project/edit_preview_frame.zpt zpt/project/project_index_html.zpt
diffstat 7 files changed, 38 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/HashTree.py	Thu May 16 15:58:28 2013 +0200
+++ b/HashTree.py	Tue May 21 15:51:32 2013 +0200
@@ -158,13 +158,13 @@
     def getChildrenOf(self, key):
         """Return the list of child (values) of the node under key."""
         node = self.getNode(key)
-        if node.children is None:
+        if getattr(node, 'children', None) is None:
             return []
         else:
             # sort children by key
             childlist = sorted(node.children.items(), key=lambda x:x[0])
             # and return the values
-            return [n.value for (k, n) in childlist if n.value is not None]
+            return [n.value for k, n in childlist if n.value is not None]
 
 
     def getAncestorsOf(self, key):
--- a/MPIWGProjects.py	Thu May 16 15:58:28 2013 +0200
+++ b/MPIWGProjects.py	Tue May 21 15:51:32 2013 +0200
@@ -371,12 +371,6 @@
         # {'label':'Edit Themes & Disciplines','action':'editMPIWGDisciplinesThemesForm'},
         # {'label':'Versionmanager','action':'versionManageForm'},
 
-    # list of responsible scientists. entries are dicts with name, key, and username.
-    responsibleScientistsList = []
-    
-    # thumbnail image
-    projectThumb = None
-
     #
     # templates
     #
@@ -421,6 +415,7 @@
         self.title = id
         self.isActiveFlag = True  # Flag is true is the project is still active, False if accomplished
         self.responsibleScientistsList = []  # enthaelt die Lister der verantwortlichen Wissenschaftler in der Form (NAME, KEY), key ist "" flass Wissenschaftler nicht an unserem Haus
+        self.projectThumb = None
         
         if argv:
             for arg in definedFields:
@@ -512,7 +507,7 @@
     
     def getResponsibleScientistsList(self):
         """returns a list with the responsible scientists as dicts with name, key, and shortname"""
-        return self.responsibleScientistsList
+        return getattr(self, 'responsibleScientistsList', [])
 
     
     def setResponsibleScientistsList(self, nameDict):
@@ -574,7 +569,7 @@
               
     def getThumbUrl(self, default=None):
         """returns the URL of the project thumbnail image"""
-        thumb = self.projectThumb
+        thumb = getattr(self, 'projectThumb', None)
         if thumb is None:
             # get thumb from list (thumb is last image)
             imgs = self.getImageList()
@@ -1254,18 +1249,21 @@
             return self.REQUEST['URL1'] + "/no_project"
                     
             
-    def saveFromPreview(self):
+    def saveFromPreview(self, RESPONSE=None):
         """save content aus preview"""
         self.WEB_project_description = self.previewTemplate.WEB_project_description[0:]
-        self.REQUEST.RESPONSE.redirect("./index.html")
+        #self.REQUEST.RESPONSE.redirect("./index.html")
+        if RESPONSE is not None:
+            return self.editDescription()
 
         
-    def saveEditedContent(self, kupu=None, preview=None):
+    def saveEditedContent(self, kupu=None, preview=None, RESPONSE=None):
         """save Edited content"""
         # logging.debug("saveEditedContent kupu=%s preview=%s"%(kupu,preview))
 
         if preview:
             kupu = preview
+            
         # find content of body tags
         start = kupu.find("<body>")
         end = kupu.find("</body>")
@@ -1277,10 +1275,11 @@
         self.copyObjectToArchive()
         self.WEB_project_description = newcontent[0:]
        
-        self.REQUEST.RESPONSE.redirect("./index.html")
+        #self.REQUEST.RESPONSE.redirect("./index.html")
         
-        return True
-
+        if RESPONSE is not None:
+            return self.editDescription()
+            
 
     def getBreadcrumbs(self):
         """return list of breadcrumbs from here to the root"""
@@ -1322,7 +1321,7 @@
             setattr(tmpPro, field, getattr(self, field))
         tmpPro.WEB_project_description = description[0:]
         tmpPro.invisible = True
-        pt = PageTemplateFile('zpt/previewFrame.zpt', globals()).__of__(self)
+        pt = PageTemplateFile('zpt/project/edit_preview_frame', globals()).__of__(self)
         return pt()
         
 
--- a/css/mpiwg.css	Thu May 16 15:58:28 2013 +0200
+++ b/css/mpiwg.css	Tue May 21 15:51:32 2013 +0200
@@ -89,6 +89,11 @@
     margin: 0;
 }
 
+h3 + h3 {
+    /* h3 directly after h3 has a margin */
+    margin-top: 0.5em; 
+}
+
 h1 a {
     /* a header with a link looks like a header */
     color: inherit;
--- a/zpt/project/edit_description.zpt	Thu May 16 15:58:28 2013 +0200
+++ b/zpt/project/edit_description.zpt	Tue May 21 15:51:32 2013 +0200
@@ -15,7 +15,7 @@
 <body>
 <tal:block metal:fill-slot="navsel" tal:define="global menusel string:description" />
 <tal:block metal:fill-slot="body">
-  <form action="saveEditedContent" method="POST">
+  <form action="saveEditedContent" method="post">
     <div>
       <span class="kupu-tb-buttongroup">
         <button type="button" id="kupu-preview-button" title="preview: alt-p" accesskey="p">Preview</button>
--- a/zpt/project/edit_images.zpt	Thu May 16 15:58:28 2013 +0200
+++ b/zpt/project/edit_images.zpt	Tue May 21 15:51:32 2013 +0200
@@ -32,7 +32,8 @@
       </tal:block>
     </table>
     <p>
-      The image for the project description should have a width of 230px.
+      The image for the project description should have a width of 230px. 
+      Images without a caption will not be shown in the project description.
     </p>
     <p>
       The last image in the list is used as the project thumbnail image (140x87px): <img align="middle" width="140" height="87"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zpt/project/edit_preview_frame.zpt	Tue May 21 15:51:32 2013 +0200
@@ -0,0 +1,11 @@
+<html>
+<body tal:define="root here/getMPIWGProjectUrl; 
+                  viewUrl python:here.getMPIWGProject().getUrl(baseUrl=here.en.MPIWGrootURL()+'/research/projects')">
+  <h2>Preview</h2>
+  <p>
+    <a tal:attributes="href string:$root/edit?fromPreview=True">Edit</a> <a tal:attributes="href string:$root/saveFromPreview">Save
+      and Publish</a>
+  </p>
+  <iframe tal:attributes="src string:$viewUrl/previewTemplate" width="100%" height="100%"></iframe>
+</body>
+</html>
--- a/zpt/project/project_index_html.zpt	Thu May 16 15:58:28 2013 +0200
+++ b/zpt/project/project_index_html.zpt	Tue May 21 15:51:32 2013 +0200
@@ -52,14 +52,14 @@
     <div class="description">
       <!-- inline image -->
       <div class="figure" tal:condition="images" tal:repeat="image python:images">
-        <div class="image">
+        <div class="image" tal:condition="image/caption">
           <a tal:define="url image/getLink" tal:attributes="href url" tal:omit-tag="not:url" target="_blank"><img
             tal:attributes="src image/getUrl" alt="" /></a>
         </div>
-        <div class="figcaption" tal:content="structure image/caption">J.-A.-D. Ingres: Mme Moitessier, 1856. Oel/Lw. 120 x 92,1
+        <div class="figcaption" tal:condition="image/caption" tal:content="structure image/caption">J.-A.-D. Ingres: Mme Moitessier, 1856. Oel/Lw. 120 x 92,1
           cm. London, National Gallery.</div>
       </div>
-      <!-- inline image -->
+      <!-- project description -->
       <div tal:content="structure python:here.getDescription(filter=True)">Project description</div>
     </div>