Alessandro Molina avatar Alessandro Molina committed 6ecf494

Solve issue with empty photos

Comments (0)

Files changed (2)

photos/controllers/root.py

     __table_options__ = {
         '__omit_fields__' : ['uid', 'author_id', 'gallery_id', 'gallery'],
         '__xml_fields__' : ['image'],
-        'image': lambda filler,row: html.literal('<img src="%s"/>' % row.image.thumb_url)
+        'image': lambda filler,row: html.literal(row.image and '<img src="%s"/>' % row.image.thumb_url or '<span>no image</span>')
     }
 
     @property

photos/templates/gallery_partial.html

 <div xmlns:py="http://genshi.edgewall.org/">
     <a class="photos_photo" py:for="photo in gallery.photos"
-       href="${photo.image.url}">
+       py:if="photo.image" href="${photo.image.url}">
         <div>
             <div class="photos_image_frame">
                 <img src="${photo.image.thumb_url}"/>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.