Show More
@@ -0,0 +1,74 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.bump_time' | |||
|
12 | db.add_column(u'boards_post', 'bump_time', | |||
|
13 | self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime(2013, 9, 14, 0, 0)), | |||
|
14 | keep_default=False) | |||
|
15 | ||||
|
16 | ||||
|
17 | def backwards(self, orm): | |||
|
18 | # Deleting field 'Post.bump_time' | |||
|
19 | db.delete_column(u'boards_post', 'bump_time') | |||
|
20 | ||||
|
21 | ||||
|
22 | models = { | |||
|
23 | u'boards.ban': { | |||
|
24 | 'Meta': {'object_name': 'Ban'}, | |||
|
25 | u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | |||
|
26 | 'ip': ('django.db.models.fields.GenericIPAddressField', [], {'max_length': '39'}) | |||
|
27 | }, | |||
|
28 | u'boards.post': { | |||
|
29 | 'Meta': {'object_name': 'Post'}, | |||
|
30 | '_text_rendered': ('django.db.models.fields.TextField', [], {}), | |||
|
31 | 'bump_time': ('django.db.models.fields.DateTimeField', [], {}), | |||
|
32 | u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | |||
|
33 | 'image': ('boards.thumbs.ImageWithThumbsField', [], {'max_length': '100', 'blank': 'True'}), | |||
|
34 | 'image_height': ('django.db.models.fields.IntegerField', [], {'default': '0'}), | |||
|
35 | 'image_width': ('django.db.models.fields.IntegerField', [], {'default': '0'}), | |||
|
36 | 'last_edit_time': ('django.db.models.fields.DateTimeField', [], {}), | |||
|
37 | 'parent': ('django.db.models.fields.BigIntegerField', [], {'default': '-1'}), | |||
|
38 | 'poster_ip': ('django.db.models.fields.GenericIPAddressField', [], {'max_length': '39'}), | |||
|
39 | 'poster_user_agent': ('django.db.models.fields.TextField', [], {}), | |||
|
40 | 'pub_time': ('django.db.models.fields.DateTimeField', [], {}), | |||
|
41 | 'replies': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'re+'", 'null': 'True', 'symmetrical': 'False', 'to': u"orm['boards.Post']"}), | |||
|
42 | 'tags': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['boards.Tag']", 'symmetrical': 'False'}), | |||
|
43 | 'text': ('markupfield.fields.MarkupField', [], {'rendered_field': 'True'}), | |||
|
44 | 'text_markup_type': ('django.db.models.fields.CharField', [], {'default': "'markdown'", 'max_length': '30'}), | |||
|
45 | 'thread': ('django.db.models.fields.related.ForeignKey', [], {'default': 'None', 'to': u"orm['boards.Post']", 'null': 'True'}), | |||
|
46 | 'title': ('django.db.models.fields.CharField', [], {'max_length': '50'}), | |||
|
47 | 'user': ('django.db.models.fields.related.ForeignKey', [], {'default': 'None', 'to': u"orm['boards.User']", 'null': 'True'}) | |||
|
48 | }, | |||
|
49 | u'boards.setting': { | |||
|
50 | 'Meta': {'object_name': 'Setting'}, | |||
|
51 | u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | |||
|
52 | 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}), | |||
|
53 | 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['boards.User']"}), | |||
|
54 | 'value': ('django.db.models.fields.CharField', [], {'max_length': '50'}) | |||
|
55 | }, | |||
|
56 | u'boards.tag': { | |||
|
57 | 'Meta': {'object_name': 'Tag'}, | |||
|
58 | u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | |||
|
59 | 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}), | |||
|
60 | 'threads': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'tag+'", 'null': 'True', 'symmetrical': 'False', 'to': u"orm['boards.Post']"}) | |||
|
61 | }, | |||
|
62 | u'boards.user': { | |||
|
63 | 'Meta': {'object_name': 'User'}, | |||
|
64 | 'fav_tags': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': u"orm['boards.Tag']", 'null': 'True', 'blank': 'True'}), | |||
|
65 | 'fav_threads': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'+'", 'null': 'True', 'symmetrical': 'False', 'to': u"orm['boards.Post']"}), | |||
|
66 | u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | |||
|
67 | 'last_access_time': ('django.db.models.fields.DateTimeField', [], {}), | |||
|
68 | 'rank': ('django.db.models.fields.IntegerField', [], {}), | |||
|
69 | 'registration_time': ('django.db.models.fields.DateTimeField', [], {}), | |||
|
70 | 'user_id': ('django.db.models.fields.CharField', [], {'max_length': '50'}) | |||
|
71 | } | |||
|
72 | } | |||
|
73 | ||||
|
74 | complete_apps = ['boards'] No newline at end of file |
@@ -44,6 +44,7 b' class PostManager(models.Manager):' | |||||
44 | poster_ip=ip, |
|
44 | poster_ip=ip, | |
45 | poster_user_agent=UNKNOWN_UA, |
|
45 | poster_user_agent=UNKNOWN_UA, | |
46 | last_edit_time=timezone.now(), |
|
46 | last_edit_time=timezone.now(), | |
|
47 | bump_time=timezone.now(), | |||
47 | user=user) |
|
48 | user=user) | |
48 |
|
49 | |||
49 | if tags: |
|
50 | if tags: | |
@@ -54,6 +55,8 b' class PostManager(models.Manager):' | |||||
54 | if thread: |
|
55 | if thread: | |
55 | thread.replies.add(post) |
|
56 | thread.replies.add(post) | |
56 | thread.bump() |
|
57 | thread.bump() | |
|
58 | thread.last_edit_time = timezone.now() | |||
|
59 | thread.save() | |||
57 | else: |
|
60 | else: | |
58 | self._delete_old_threads() |
|
61 | self._delete_old_threads() | |
59 |
|
62 | |||
@@ -69,7 +72,7 b' class PostManager(models.Manager):' | |||||
69 | map(self.delete_post, posts) |
|
72 | map(self.delete_post, posts) | |
70 |
|
73 | |||
71 | def get_threads(self, tag=None, page=ALL_PAGES, |
|
74 | def get_threads(self, tag=None, page=ALL_PAGES, | |
72 |
order_by='- |
|
75 | order_by='-bump_time'): | |
73 | if tag: |
|
76 | if tag: | |
74 | threads = tag.threads |
|
77 | threads = tag.threads | |
75 |
|
78 | |||
@@ -218,6 +221,7 b' class Post(models.Model):' | |||||
218 | thread = models.ForeignKey('Post', null=True, default=None) |
|
221 | thread = models.ForeignKey('Post', null=True, default=None) | |
219 | tags = models.ManyToManyField(Tag) |
|
222 | tags = models.ManyToManyField(Tag) | |
220 | last_edit_time = models.DateTimeField() |
|
223 | last_edit_time = models.DateTimeField() | |
|
224 | bump_time = models.DateTimeField() | |||
221 | user = models.ForeignKey('User', null=True, default=None) |
|
225 | user = models.ForeignKey('User', null=True, default=None) | |
222 |
|
226 | |||
223 | replies = models.ManyToManyField('Post', symmetrical=False, null=True, |
|
227 | replies = models.ManyToManyField('Post', symmetrical=False, null=True, | |
@@ -254,8 +258,7 b' class Post(models.Model):' | |||||
254 | """Bump (move to up) thread""" |
|
258 | """Bump (move to up) thread""" | |
255 |
|
259 | |||
256 | if self.can_bump(): |
|
260 | if self.can_bump(): | |
257 |
self. |
|
261 | self.bump_time = timezone.now() | |
258 | self.save() |
|
|||
259 |
|
262 | |||
260 | def get_last_replies(self): |
|
263 | def get_last_replies(self): | |
261 | if settings.LAST_REPLIES_COUNT > 0: |
|
264 | if settings.LAST_REPLIES_COUNT > 0: |
@@ -2,6 +2,7 b'' | |||||
2 |
|
2 | |||
3 | {% load i18n %} |
|
3 | {% load i18n %} | |
4 | {% load markup %} |
|
4 | {% load markup %} | |
|
5 | {% load cache %} | |||
5 |
|
6 | |||
6 | {% block head %} |
|
7 | {% block head %} | |
7 | {% if tag %} |
|
8 | {% if tag %} | |
@@ -29,6 +30,7 b'' | |||||
29 |
|
30 | |||
30 | {% if threads %} |
|
31 | {% if threads %} | |
31 | {% for thread in threads %} |
|
32 | {% for thread in threads %} | |
|
33 | {% cache 600 thread_cache thread.thread.last_edit_time %} | |||
32 | <div class="thread"> |
|
34 | <div class="thread"> | |
33 | {% if thread.bumpable %} |
|
35 | {% if thread.bumpable %} | |
34 | <div class="post" id="{{ thread.thread.id }}"> |
|
36 | <div class="post" id="{{ thread.thread.id }}"> | |
@@ -118,6 +120,7 b'' | |||||
118 | {% endfor %} |
|
120 | {% endfor %} | |
119 | </div> |
|
121 | </div> | |
120 | {% endif %} |
|
122 | {% endif %} | |
|
123 | {% endcache %} | |||
121 | </div> |
|
124 | </div> | |
122 | {% endfor %} |
|
125 | {% endfor %} | |
123 | {% else %} |
|
126 | {% else %} |
@@ -2,6 +2,7 b'' | |||||
2 |
|
2 | |||
3 | {% load i18n %} |
|
3 | {% load i18n %} | |
4 | {% load markup %} |
|
4 | {% load markup %} | |
|
5 | {% load cache %} | |||
5 |
|
6 | |||
6 | {% block head %} |
|
7 | {% block head %} | |
7 | <title>Neboard - {{ posts.0.get_title }}</title> |
|
8 | <title>Neboard - {{ posts.0.get_title }}</title> | |
@@ -11,6 +12,7 b'' | |||||
11 | <script src="{{ STATIC_URL }}js/thread.js"></script> |
|
12 | <script src="{{ STATIC_URL }}js/thread.js"></script> | |
12 |
|
13 | |||
13 | {% if posts %} |
|
14 | {% if posts %} | |
|
15 | {% cache 600 thread_view posts.0.last_edit_time %} | |||
14 | <div id="posts"> |
|
16 | <div id="posts"> | |
15 | {% for post in posts %} |
|
17 | {% for post in posts %} | |
16 | {% if bumpable %} |
|
18 | {% if bumpable %} | |
@@ -66,6 +68,7 b'' | |||||
66 | </div> |
|
68 | </div> | |
67 | {% endfor %} |
|
69 | {% endfor %} | |
68 | </div> |
|
70 | </div> | |
|
71 | {% endcache %} | |||
69 | {% endif %} |
|
72 | {% endif %} | |
70 |
|
73 | |||
71 | <form id="form" enctype="multipart/form-data" method="post" |
|
74 | <form id="form" enctype="multipart/form-data" method="post" |
@@ -24,6 +24,13 b' DATABASES = {' | |||||
24 | } |
|
24 | } | |
25 | } |
|
25 | } | |
26 |
|
26 | |||
|
27 | CACHES = { | |||
|
28 | 'default': { | |||
|
29 | 'BACKEND': 'django.core.cache.backends.db.DatabaseCache', | |||
|
30 | 'LOCATION': 'neboard_cache', | |||
|
31 | } | |||
|
32 | } | |||
|
33 | ||||
27 | # Local time zone for this installation. Choices can be found here: |
|
34 | # Local time zone for this installation. Choices can be found here: | |
28 | # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name |
|
35 | # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name | |
29 | # although not all choices may be available on all operating systems. |
|
36 | # although not all choices may be available on all operating systems. |
General Comments 0
You need to be logged in to leave comments.
Login now