Mercurial > hg > MPIWGWeb
changeset 96:2dd8e3be4a8e
add project image link. fix edit image template bug.
author | casties |
---|---|
date | Thu, 16 May 2013 15:58:28 +0200 |
parents | 1b8be917a167 |
children | 7b96a85552aa |
files | MPIWGProjects.py zpt/project/edit_images.zpt zpt/project/edit_template.zpt zpt/project/image/edit_basic.zpt zpt/project/project_index_html.zpt |
diffstat | 5 files changed, 53 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/MPIWGProjects.py Thu May 16 15:05:57 2013 +0200 +++ b/MPIWGProjects.py Thu May 16 15:58:28 2013 +0200 @@ -221,22 +221,39 @@ meta_type = "MPIWGProject_image" # templates - showImage = PageTemplateFile('zpt/project/image/projectImageView', globals()) + oldShowImage = PageTemplateFile('zpt/project/image/projectImageView', globals()) editForm = PageTemplateFile('zpt/project/image/edit_basic', globals()) getUrl = MPIWGHelper.getUrl - def editImage(self, file=None, caption=None, RESPONSE=None): + + def getCaption(self): + """Return the image caption.""" + return getattr(self, 'caption', None) + + + def getLink(self): + """Return the image link.""" + return getattr(self, 'link', None) + + + def editImage(self, file=None, caption=None, link=None, RESPONSE=None): """edit the Image""" if (not file) and (not caption): pt = self.editForm return pt() - if file and (not file.filename.lstrip().rstrip() == ""): + if file and (not file.filename.strip() == ""): self.manage_upload(file) if caption: - self.caption = caption[0:] + if isinstance(caption, list): + caption = caption[0] + + self.caption = caption + + if link: + self.link = link if RESPONSE: self.redirect(RESPONSE, "../manageImages") @@ -542,6 +559,11 @@ return t + def getMPIWGProject(self): + """Return this project for acquisition.""" + return self + + def getMPIWGProjectUrl(self): """Return this project for acquisition.""" return self.absolute_url()
--- a/zpt/project/edit_images.zpt Thu May 16 15:05:57 2013 +0200 +++ b/zpt/project/edit_images.zpt Thu May 16 15:58:28 2013 +0200 @@ -11,6 +11,7 @@ <th /> <th>Image</th> <th>Caption</th> + <th>Link</th> <th /> </tr> <tal:block tal:repeat="image images"> @@ -23,14 +24,15 @@ <img tal:attributes="src image/absolute_url" /><br/> <span tal:content="string:(${image/width}x${image/height}px)"/> </td> - <td tal:content="structure python:getattr(image,'caption','')" /> + <td tal:content="structure image/getCaption" /> + <td tal:content="structure image/getLink" /> <td><a tal:attributes="href string:$root/$imgid/editImage">Edit</a><br /> <a tal:attributes="href string:$root/deleteImage?id=$imgid">Delete</a></td> </tr> </tal:block> </table> <p> - The image for the project description should have a width of 220px. + The image for the project description should have a width of 230px. </p> <p> The last image in the list is used as the project thumbnail image (140x87px): <img align="middle" width="140" height="87"
--- a/zpt/project/edit_template.zpt Thu May 16 15:05:57 2013 +0200 +++ b/zpt/project/edit_template.zpt Thu May 16 15:58:28 2013 +0200 @@ -27,7 +27,7 @@ <span tal:attributes="class python:test('themes'==menusel, 'mainmenusel', 'mainmenu')"><a tal:attributes="href string:$root/tagTheProject">Tags</a></span> <span class="mainmenu"><a target="_blank" - tal:attributes="href python:here.getUrl(baseUrl=here.en.MPIWGrootURL()+'/research/projects')">View</a></span> + tal:attributes="href python:here.getMPIWGProject().getUrl(baseUrl=here.en.MPIWGrootURL()+'/research/projects')">View</a></span> </div> <div class="content"> <tal:block metal:define-slot="body"/>
--- a/zpt/project/image/edit_basic.zpt Thu May 16 15:05:57 2013 +0200 +++ b/zpt/project/image/edit_basic.zpt Thu May 16 15:58:28 2013 +0200 @@ -1,23 +1,32 @@ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html metal:use-macro="here/edit_MPIWGProject_main/macros/page"> +<html metal:use-macro="here/edit_template/macros/page"> <head> </head> <body> <tal:block metal:fill-slot="navsel" tal:define="global menusel string:images" /> <tal:block metal:fill-slot="body"> - <h3>Edit Image</h3> + <h2>Edit Image</h2> <form action="editImage" method="post" enctype="multipart/form-data"> - <table> - <tr><th>Image</th><th>Caption</th></tr> - <tr> - <td><div tal:content="structure python:here.tag(scale=250.0 / here.height)"/></td> - <td><textarea tal:content="structure python:getattr(here,'caption','')" name="caption" rows="3" cols="60"></textarea></td> - </tr> - <tr> - <td><p>Upload new image:<input type="file" name="file" len="50"/></p></td> - </tr> - </table> + + <h3>Image</h3> + <div> + <img tal:attributes="src here/absolute_url"/> + </div> + <p>Upload new image:<input type="file" name="file" len="50"/></p> + + <h3>Caption</h3> + <p>(shown below image)</p> + <div> + <textarea tal:content="structure python:getattr(here,'caption','')" name="caption" rows="3" cols="60"></textarea> + </div> + + <h3>Link</h3> + <p>(optional, URL of larger image)</p> + <div> + <input type="text" size="60" name="link" tal:attributes="value here/getLink"/> + </div> + <p> <input type="submit" value="submit"/> </p>
--- a/zpt/project/project_index_html.zpt Thu May 16 15:05:57 2013 +0200 +++ b/zpt/project/project_index_html.zpt Thu May 16 15:58:28 2013 +0200 @@ -53,9 +53,8 @@ <!-- inline image --> <div class="figure" tal:condition="images" tal:repeat="image python:images"> <div class="image"> - <a tal:condition="image/width" tal:attributes="href python:image.getUrl()+'/showImage'" target="_blank"><img + <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> - <pre tal:condition="not:image/width">empty image</pre> </div> <div class="figcaption" tal:content="structure image/caption">J.-A.-D. Ingres: Mme Moitessier, 1856. Oel/Lw. 120 x 92,1 cm. London, National Gallery.</div>