##// END OF EJS Templates
Removed method that checks gets (this will be implemented in JS). Added image width and height fields that will be used for image previews. This refs #72
neko259 -
r127:e120a390 default
parent child Browse files
Show More
@@ -0,0 +1,66 b''
1 # -*- coding: utf-8 -*-
2 import datetime
3 from south.db import db
4 from south.v2 import SchemaMigration
5 from django.db import models
6
7
8 class Migration(SchemaMigration):
9
10 def forwards(self, orm):
11 # Adding field 'Post.image_width'
12 db.add_column(u'boards_post', 'image_width',
13 self.gf('django.db.models.fields.IntegerField')(default=0),
14 keep_default=False)
15
16 # Adding field 'Post.image_height'
17 db.add_column(u'boards_post', 'image_height',
18 self.gf('django.db.models.fields.IntegerField')(default=0),
19 keep_default=False)
20
21
22 def backwards(self, orm):
23 # Deleting field 'Post.image_width'
24 db.delete_column(u'boards_post', 'image_width')
25
26 # Deleting field 'Post.image_height'
27 db.delete_column(u'boards_post', 'image_height')
28
29
30 models = {
31 u'boards.admin': {
32 'Meta': {'object_name': 'Admin'},
33 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
34 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
35 'password': ('django.db.models.fields.CharField', [], {'max_length': '100'})
36 },
37 u'boards.ban': {
38 'Meta': {'object_name': 'Ban'},
39 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
40 'ip': ('django.db.models.fields.GenericIPAddressField', [], {'max_length': '39'})
41 },
42 u'boards.post': {
43 'Meta': {'object_name': 'Post'},
44 '_text_rendered': ('django.db.models.fields.TextField', [], {}),
45 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
46 'image': ('boards.thumbs.ImageWithThumbsField', [], {'max_length': '100', 'blank': 'True'}),
47 'image_height': ('django.db.models.fields.IntegerField', [], {}),
48 'image_width': ('django.db.models.fields.IntegerField', [], {}),
49 'last_edit_time': ('django.db.models.fields.DateTimeField', [], {}),
50 'parent': ('django.db.models.fields.BigIntegerField', [], {}),
51 'poster_ip': ('django.db.models.fields.GenericIPAddressField', [], {'max_length': '39'}),
52 'poster_user_agent': ('django.db.models.fields.TextField', [], {}),
53 'pub_time': ('django.db.models.fields.DateTimeField', [], {}),
54 'tags': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['boards.Tag']", 'symmetrical': 'False'}),
55 'text': ('markupfield.fields.MarkupField', [], {'rendered_field': 'True'}),
56 'text_markup_type': ('django.db.models.fields.CharField', [], {'default': "'markdown'", 'max_length': '30'}),
57 'title': ('django.db.models.fields.CharField', [], {'max_length': '50'})
58 },
59 u'boards.tag': {
60 'Meta': {'object_name': 'Tag'},
61 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
62 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
63 }
64 }
65
66 complete_apps = ['boards'] No newline at end of file
@@ -27,9 +27,6 b' OPENING_POST_POPULARITY_WEIGHT = 2'
27 IMAGES_DIRECTORY = 'images/'
27 IMAGES_DIRECTORY = 'images/'
28 FILE_EXTENSION_DELIMITER = '.'
28 FILE_EXTENSION_DELIMITER = '.'
29
29
30 REGEX_PRETTY = re.compile(r'^\d(0)+$')
31 REGEX_SAME = re.compile(r'^(.)\1+$')
32
33
30
34 class PostManager(models.Manager):
31 class PostManager(models.Manager):
35 def create_post(self, title, text, image=None, parent_id=NO_PARENT,
32 def create_post(self, title, text, image=None, parent_id=NO_PARENT,
@@ -213,8 +210,15 b' class Post(models.Model):'
213 pub_time = models.DateTimeField()
210 pub_time = models.DateTimeField()
214 text = MarkupField(default_markup_type=DEFAULT_MARKUP_TYPE,
211 text = MarkupField(default_markup_type=DEFAULT_MARKUP_TYPE,
215 escape_html=False)
212 escape_html=False)
213
214 image_width = models.IntegerField()
215 image_height = models.IntegerField()
216
216 image = thumbs.ImageWithThumbsField(upload_to=_update_image_filename,
217 image = thumbs.ImageWithThumbsField(upload_to=_update_image_filename,
217 blank=True, sizes=(IMAGE_THUMB_SIZE,))
218 blank=True, sizes=(IMAGE_THUMB_SIZE,),
219 width_field='image_width',
220 height_field='image_height')
221
218 poster_ip = models.GenericIPAddressField()
222 poster_ip = models.GenericIPAddressField()
219 poster_user_agent = models.TextField()
223 poster_user_agent = models.TextField()
220 parent = models.BigIntegerField()
224 parent = models.BigIntegerField()
@@ -223,7 +227,7 b' class Post(models.Model):'
223
227
224 def __unicode__(self):
228 def __unicode__(self):
225 return '#' + str(self.id) + ' ' + self.title + ' (' + \
229 return '#' + str(self.id) + ' ' + self.title + ' (' + \
226 self.text.raw[:50] + ')'
230 self.text.raw[:50] + ')'
227
231
228 def _get_replies(self):
232 def _get_replies(self):
229 return Post.objects.filter(parent=self.id)
233 return Post.objects.filter(parent=self.id)
@@ -247,17 +251,6 b' class Post(models.Model):'
247
251
248 return gets_count
252 return gets_count
249
253
250 def is_get(self):
251 """If the post has pretty id (1, 1000, 77777), than it is called GET"""
252
253 first = self.id == 1
254
255 id_str = str(self.id)
256 pretty = REGEX_PRETTY.match(id_str)
257 same_digits = REGEX_SAME.match(id_str)
258
259 return first or pretty or same_digits
260
261 def can_bump(self):
254 def can_bump(self):
262 """Check if the thread can be bumped by replying"""
255 """Check if the thread can be bumped by replying"""
263
256
@@ -20,9 +20,9 b''
20 </head>
20 </head>
21 <body>
21 <body>
22 <script src="{{ STATIC_URL }}js/jquery-2.0.1.min.js"></script>
22 <script src="{{ STATIC_URL }}js/jquery-2.0.1.min.js"></script>
23 <script src="{{ STATIC_URL }}js/jquery.fancybox.pack.js"></script>
23 <!--<script src="{{ STATIC_URL }}js/jquery.fancybox.pack.js"></script>-->
24 <script src="{% url 'django.views.i18n.javascript_catalog' %}"></script>
24 <script src="{% url 'django.views.i18n.javascript_catalog' %}"></script>
25 <script src="{{ STATIC_URL }}js/refmaps.js"></script>
25 <!--<script src="{{ STATIC_URL }}js/refmaps.js"></script>-->
26 <script src="{{ STATIC_URL }}js/main.js"></script>
26 <script src="{{ STATIC_URL }}js/main.js"></script>
27 <div id="admin_panel">
27 <div id="admin_panel">
28
28
@@ -31,8 +31,10 b''
31 <div class="image">
31 <div class="image">
32 <a class="fancy"
32 <a class="fancy"
33 href="{{ thread.image.url }}"><img
33 href="{{ thread.image.url }}"><img
34 src="{{ thread.image.url_200x150 }}"
34 src="{{ thread.image.url_200x150 }}"
35 alt="{% trans 'Post image' %}" />
35 alt="{% trans 'Post image' %}"
36 data-width="{{ thread.image_width }}"
37 data-height="{{ thread.image_height }}" />
36 </a>
38 </a>
37 </div>
39 </div>
38 {% endif %}
40 {% endif %}
@@ -75,8 +77,10 b''
75 <div class="image">
77 <div class="image">
76 <a class="fancy"
78 <a class="fancy"
77 href="{{ post.image.url }}"><img
79 href="{{ post.image.url }}"><img
78 src=" {{ post.image.url_200x150 }}"
80 src=" {{ post.image.url_200x150 }}"
79 alt="{% trans 'Post image' %}" />
81 alt="{% trans 'Post image' %}"
82 data-width="{{ post.image_width }}"
83 data-height="{{ post.image_height }}"/>
80 </a>
84 </a>
81 </div>
85 </div>
82 {% endif %}
86 {% endif %}
@@ -24,7 +24,9 b''
24 class="fancy"
24 class="fancy"
25 href="{{ post.image.url }}"><img
25 href="{{ post.image.url }}"><img
26 src="{{ post.image.url_200x150 }}"
26 src="{{ post.image.url_200x150 }}"
27 alt="{% trans 'Post image' %}" />
27 alt="{% trans 'Post image' %}"
28 data-width="{{ post.image_width }}"
29 data-height="{{ post.image_height }}"/>
28 </a>
30 </a>
29 </div>
31 </div>
30 {% endif %}
32 {% endif %}
@@ -34,11 +36,6 b''
34 <a class="post_id" href="#{{ post.id }}">
36 <a class="post_id" href="#{{ post.id }}">
35 (#{{ post.id }})</a>
37 (#{{ post.id }})</a>
36 [{{ post.pub_time }}]
38 [{{ post.pub_time }}]
37 {% if post.is_get %}
38 <span class="get">
39 {% trans "Get!" %}
40 </span>
41 {% endif %}
42 [<a href="#" onclick="javascript:addQuickReply('{{ post.id }}')
39 [<a href="#" onclick="javascript:addQuickReply('{{ post.id }}')
43 ; return false;">&gt;&gt;</a>]
40 ; return false;">&gt;&gt;</a>]
44 </div>
41 </div>
General Comments 0
You need to be logged in to leave comments. Login now