Show More
@@ -196,13 +196,14 b' class Post(models.Model, Viewable):' | |||||
196 |
|
196 | |||
197 | return render_to_string('boards/post.html', params) |
|
197 | return render_to_string('boards/post.html', params) | |
198 |
|
198 | |||
|
199 | def get_images(self) -> Attachment: | |||
|
200 | return self.attachments.filter(mimetype__in=FILE_TYPES_IMAGE) | |||
|
201 | ||||
199 | def get_first_image(self) -> Attachment: |
|
202 | def get_first_image(self) -> Attachment: | |
200 | image = None |
|
|||
201 | try: |
|
203 | try: | |
202 | image = self.attachments.filter(mimetype__in=FILE_TYPES_IMAGE).earliest('id') |
|
204 | return self.get_images().earliest('-id') | |
203 | except Attachment.DoesNotExist: |
|
205 | except Attachment.DoesNotExist: | |
204 |
|
|
206 | return None | |
205 | return image |
|
|||
206 |
|
207 | |||
207 | def set_global_id(self, key_pair=None): |
|
208 | def set_global_id(self, key_pair=None): | |
208 | """ |
|
209 | """ |
@@ -18,19 +18,19 b'' | |||||
18 | <div id="posts-table"> |
|
18 | <div id="posts-table"> | |
19 | {% if posts %} |
|
19 | {% if posts %} | |
20 | {% for post in posts %} |
|
20 | {% for post in posts %} | |
21 | <div class="gallery_image"> |
|
21 | {% for image in post.get_images %} | |
22 | {% with post.get_first_image as image %} |
|
22 | <div class="gallery_image"> | |
23 | {% autoescape off %} |
|
23 | {% autoescape off %} | |
24 | {{ image.get_view }} |
|
24 | {{ image.get_view }} | |
25 | <div class="gallery_image_metadata"> |
|
25 | <div class="gallery_image_metadata"> | |
26 | {{ image.get_size.0 }}x{{ image.get_size.1 }} |
|
26 | {{ image.get_size.0 }}x{{ image.get_size.1 }} | |
27 | {% image_actions image.file.url request.get_host %} |
|
27 | {% image_actions image.file.url request.get_host %} | |
28 | <br /> |
|
28 | <br /> | |
29 | <a href="{{ post.get_absolute_url }}">>>{{ post.id }}</a> |
|
29 | <a href="{{ post.get_absolute_url }}">>>{{ post.id }}</a> | |
30 | </div> |
|
30 | </div> | |
31 | {% endautoescape %} |
|
31 | {% endautoescape %} | |
32 |
|
|
32 | </div> | |
33 |
|
|
33 | {% endfor %} | |
34 | {% endfor %} |
|
34 | {% endfor %} | |
35 | {% else %} |
|
35 | {% else %} | |
36 | {% trans 'No images.' %} |
|
36 | {% trans 'No images.' %} |
General Comments 0
You need to be logged in to leave comments.
Login now