diff --git a/boards/migrations/0003_auto__add_field_post_image_width__add_field_post_image_height.py b/boards/migrations/0003_auto__add_field_post_image_width__add_field_post_image_height.py new file mode 100644 --- /dev/null +++ b/boards/migrations/0003_auto__add_field_post_image_width__add_field_post_image_height.py @@ -0,0 +1,66 @@ +# -*- coding: utf-8 -*- +import datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + + +class Migration(SchemaMigration): + + def forwards(self, orm): + # Adding field 'Post.image_width' + db.add_column(u'boards_post', 'image_width', + self.gf('django.db.models.fields.IntegerField')(default=0), + keep_default=False) + + # Adding field 'Post.image_height' + db.add_column(u'boards_post', 'image_height', + self.gf('django.db.models.fields.IntegerField')(default=0), + keep_default=False) + + + def backwards(self, orm): + # Deleting field 'Post.image_width' + db.delete_column(u'boards_post', 'image_width') + + # Deleting field 'Post.image_height' + db.delete_column(u'boards_post', 'image_height') + + + models = { + u'boards.admin': { + 'Meta': {'object_name': 'Admin'}, + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'password': ('django.db.models.fields.CharField', [], {'max_length': '100'}) + }, + u'boards.ban': { + 'Meta': {'object_name': 'Ban'}, + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'ip': ('django.db.models.fields.GenericIPAddressField', [], {'max_length': '39'}) + }, + u'boards.post': { + 'Meta': {'object_name': 'Post'}, + '_text_rendered': ('django.db.models.fields.TextField', [], {}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'image': ('boards.thumbs.ImageWithThumbsField', [], {'max_length': '100', 'blank': 'True'}), + 'image_height': ('django.db.models.fields.IntegerField', [], {}), + 'image_width': ('django.db.models.fields.IntegerField', [], {}), + 'last_edit_time': ('django.db.models.fields.DateTimeField', [], {}), + 'parent': ('django.db.models.fields.BigIntegerField', [], {}), + 'poster_ip': ('django.db.models.fields.GenericIPAddressField', [], {'max_length': '39'}), + 'poster_user_agent': ('django.db.models.fields.TextField', [], {}), + 'pub_time': ('django.db.models.fields.DateTimeField', [], {}), + 'tags': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['boards.Tag']", 'symmetrical': 'False'}), + 'text': ('markupfield.fields.MarkupField', [], {'rendered_field': 'True'}), + 'text_markup_type': ('django.db.models.fields.CharField', [], {'default': "'markdown'", 'max_length': '30'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + u'boards.tag': { + 'Meta': {'object_name': 'Tag'}, + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) + } + } + + complete_apps = ['boards'] \ No newline at end of file diff --git a/boards/models.py b/boards/models.py --- a/boards/models.py +++ b/boards/models.py @@ -27,9 +27,6 @@ OPENING_POST_POPULARITY_WEIGHT = 2 IMAGES_DIRECTORY = 'images/' FILE_EXTENSION_DELIMITER = '.' -REGEX_PRETTY = re.compile(r'^\d(0)+$') -REGEX_SAME = re.compile(r'^(.)\1+$') - class PostManager(models.Manager): def create_post(self, title, text, image=None, parent_id=NO_PARENT, @@ -213,8 +210,15 @@ class Post(models.Model): pub_time = models.DateTimeField() text = MarkupField(default_markup_type=DEFAULT_MARKUP_TYPE, escape_html=False) + + image_width = models.IntegerField() + image_height = models.IntegerField() + image = thumbs.ImageWithThumbsField(upload_to=_update_image_filename, - blank=True, sizes=(IMAGE_THUMB_SIZE,)) + blank=True, sizes=(IMAGE_THUMB_SIZE,), + width_field='image_width', + height_field='image_height') + poster_ip = models.GenericIPAddressField() poster_user_agent = models.TextField() parent = models.BigIntegerField() @@ -223,7 +227,7 @@ class Post(models.Model): def __unicode__(self): return '#' + str(self.id) + ' ' + self.title + ' (' + \ - self.text.raw[:50] + ')' + self.text.raw[:50] + ')' def _get_replies(self): return Post.objects.filter(parent=self.id) @@ -247,17 +251,6 @@ class Post(models.Model): return gets_count - def is_get(self): - """If the post has pretty id (1, 1000, 77777), than it is called GET""" - - first = self.id == 1 - - id_str = str(self.id) - pretty = REGEX_PRETTY.match(id_str) - same_digits = REGEX_SAME.match(id_str) - - return first or pretty or same_digits - def can_bump(self): """Check if the thread can be bumped by replying""" diff --git a/boards/templates/boards/base.html b/boards/templates/boards/base.html --- a/boards/templates/boards/base.html +++ b/boards/templates/boards/base.html @@ -20,9 +20,9 @@ - + - +
diff --git a/boards/templates/boards/posting_general.html b/boards/templates/boards/posting_general.html --- a/boards/templates/boards/posting_general.html +++ b/boards/templates/boards/posting_general.html @@ -31,8 +31,10 @@
{% trans 'Post image' %} + src="{{ thread.image.url_200x150 }}" + alt="{% trans 'Post image' %}" + data-width="{{ thread.image_width }}" + data-height="{{ thread.image_height }}" />
{% endif %} @@ -75,8 +77,10 @@
{% trans 'Post image' %} + src=" {{ post.image.url_200x150 }}" + alt="{% trans 'Post image' %}" + data-width="{{ post.image_width }}" + data-height="{{ post.image_height }}"/>
{% endif %} diff --git a/boards/templates/boards/thread.html b/boards/templates/boards/thread.html --- a/boards/templates/boards/thread.html +++ b/boards/templates/boards/thread.html @@ -24,7 +24,9 @@ class="fancy" href="{{ post.image.url }}">{% trans 'Post image' %} + alt="{% trans 'Post image' %}" + data-width="{{ post.image_width }}" + data-height="{{ post.image_height }}"/>
{% endif %} @@ -34,11 +36,6 @@ (#{{ post.id }}) [{{ post.pub_time }}] - {% if post.is_get %} - - {% trans "Get!" %} - - {% endif %} [>>]