diff --git a/boards/models/image.py b/boards/models/image.py --- a/boards/models/image.py +++ b/boards/models/image.py @@ -4,6 +4,7 @@ from random import random import time from django.db import models from boards import thumbs +from boards.models.base import Viewable __author__ = 'neko259' @@ -11,9 +12,13 @@ from boards import thumbs IMAGE_THUMB_SIZE = (200, 150) IMAGES_DIRECTORY = 'images/' FILE_EXTENSION_DELIMITER = '.' +HASH_LENGTH = 36 + +CSS_CLASS_IMAGE = 'image' +CSS_CLASS_THUMB = 'thumb' -class PostImage(models.Model): +class PostImage(models.Model, Viewable): class Meta: app_label = 'boards' ordering = ('id',) @@ -43,7 +48,7 @@ class PostImage(models.Model): height_field='height', preview_width_field='pre_width', preview_height_field='pre_height') - hash = models.CharField(max_length=36) + hash = models.CharField(max_length=HASH_LENGTH) def save(self, *args, **kwargs): """ @@ -60,3 +65,19 @@ class PostImage(models.Model): def __str__(self): return self.image.url + def get_view(self): + return '
' \ + '' \ + '' \ + '' \ + '
'\ + .format(CSS_CLASS_IMAGE, CSS_CLASS_THUMB, self.image.url, + self.image.url_200x150, + str(self.hash), str(self.pre_width), + str(self.pre_height), str(self.width), str(self.height)) diff --git a/boards/templates/boards/post.html b/boards/templates/boards/post.html --- a/boards/templates/boards/post.html +++ b/boards/templates/boards/post.html @@ -46,22 +46,20 @@ {% endif %} +{% comment %} + Post images. Currently only 1 image can be posted and shown, but post model + supports multiple. +{% endcomment %} {% if post.images.exists %} {% with post.images.all.0 as image %} -
- {{ post.id }} - -
+ {% autoescape off %} + {{ image.get_view }} + {% endautoescape %} {% endwith %} {% endif %} +{% comment %} + Post message (text) +{% endcomment %}
{% autoescape off %} {% if truncated %} @@ -78,6 +76,9 @@
{% endif %} +{% comment %} + Thread metadata: counters, tags etc +{% endcomment %} {% if is_opening %}
{% if is_opening and need_open_link %}