##// END OF EJS Templates
Merged with default branch
neko259 -
r805:40a08ce9 merge decentral
parent child Browse files
Show More
@@ -79,7 +79,6 b' class SettingsManager:'
79 79 for tag_name in tag_names:
80 80 tag = get_object_or_404(Tag, name=tag_name)
81 81 tags.append(tag)
82
83 82 return tags
84 83
85 84 def add_fav_tag(self, tag):
@@ -89,6 +88,8 b' class SettingsManager:'
89 88 else:
90 89 if not tag.name in tags:
91 90 tags.append(tag.name)
91
92 tags.sort()
92 93 self.set_setting(SETTING_FAVORITE_TAGS, tags)
93 94
94 95 def del_fav_tag(self, tag):
@@ -114,6 +115,8 b' class SettingsManager:'
114 115 else:
115 116 if not tag.name in tags:
116 117 tags.append(tag.name)
118
119 tags.sort()
117 120 self.set_setting(SETTING_HIDDEN_TAGS, tags)
118 121
119 122 def del_hidden_tag(self, tag):
@@ -31,8 +31,13 b' class KeyPairAdmin(admin.ModelAdmin):'
31 31 list_filter = ('primary',)
32 32 search_fields = ('public_key',)
33 33
34 class BanAdmin(admin.ModelAdmin):
35 list_display = ('ip', 'can_read')
36 list_filter = ('can_read',)
37 search_fields = ('ip',)
38
34 39 admin.site.register(Post, PostAdmin)
35 40 admin.site.register(Tag, TagAdmin)
36 admin.site.register(Ban)
41 admin.site.register(Ban, BanAdmin)
37 42 admin.site.register(Thread, ThreadAdmin)
38 43 admin.site.register(KeyPair, KeyPairAdmin)
@@ -9,7 +9,7 b' import boards'
9 9 __author__ = 'neko259'
10 10
11 11
12 REFLINK_PATTERN = re.compile(r'\d+')
12 REFLINK_PATTERN = re.compile(r'^\d+$')
13 13 MULTI_NEWLINES_PATTERN = re.compile(r'(\r?\n){2,}')
14 14 ONE_NEWLINE = '\n'
15 15
@@ -124,7 +124,7 b' def render_reflink(tag_name, value, opti'
124 124 if posts.exists():
125 125 post = posts[0]
126 126
127 return u'<a href=%s>&gt;&gt;%s</a>' % (post.get_url(), post_id)
127 return u'<a href="%s">&gt;&gt;%s</a>' % (post.get_url(), post_id)
128 128 else:
129 129 return u'>>%s' % value
130 130
@@ -250,6 +250,8 b' a:hover {'
250 250 .last-replies {
251 251 margin-left: 3ex;
252 252 margin-right: 3ex;
253 border-left: solid 1px #777;
254 border-right: solid 1px #777;
253 255 }
254 256
255 257 .thread {
@@ -374,7 +376,12 b' li {'
374 376 }
375 377
376 378 .skipped_replies {
377 margin: 5px;
379 padding: 5px;
380 margin-left: 3ex;
381 margin-right: 3ex;
382 border-left: solid 1px #888;
383 border-right: solid 1px #888;
384 background: #000;
378 385 }
379 386
380 387 .current_page {
@@ -14,8 +14,6 b''
14 14 {% spaceless %}
15 15 {% get_current_language as LANGUAGE_CODE %}
16 16
17 <script src="{% static 'js/thread.js' %}"></script>
18
19 17 {% cache 600 thread_gallery_view thread.id thread.last_edit_time LANGUAGE_CODE request.get_host %}
20 18 <div class="image-mode-tab">
21 19 <a href="{% url 'thread' thread.get_opening_post.id %}">{% trans 'Normal mode' %}</a>,
@@ -1,6 +1,7 b''
1 1 # coding=utf-8
2 2 import time
3 3 import logging
4 import simplejson
4 5 from django.core.paginator import Paginator
5 6
6 7 from django.test import TestCase
@@ -11,6 +12,8 b' from boards.abstracts.settingsmanager im'
11 12 from boards.models import Post, Tag, Thread, KeyPair
12 13 from boards import urls
13 14 from boards import settings
15 from boards.views.api import api_get_threaddiff
16 from boards.utils import datetime_to_epoch
14 17 import neboard
15 18
16 19 TEST_TAG = 'test_tag'
@@ -261,6 +264,8 b' class AbstractTest(TestCase):'
261 264 class MockRequest:
262 265 def __init__(self):
263 266 self.session = dict()
267 self.GET = dict()
268 self.POST = dict()
264 269
265 270
266 271 class KeyTest(TestCase):
@@ -286,3 +291,46 b' class KeyTest(TestCase):'
286 291 self.fail('Exception should be thrown indicating there can be only one primary key.')
287 292 except Exception:
288 293 pass
294
295
296 class ApiTest(TestCase):
297 def test_thread_diff(self):
298 tag = Tag.objects.create(name=TEST_TAG)
299 opening_post = Post.objects.create_post(title='title', text='text',
300 tags=[tag])
301
302 last_edit_time = datetime_to_epoch(opening_post.last_edit_time)
303
304 # Check the exact timestamp post was added
305 empty_response = api_get_threaddiff(MockRequest(),
306 str(opening_post.thread_new.id),
307 str(last_edit_time))
308 diff = simplejson.loads(empty_response.content)
309 self.assertEqual(0, len(diff['added']),
310 'There must be no added posts in the diff.')
311 self.assertEqual(0, len(diff['updated']),
312 'There must be no updated posts in the diff.')
313
314 reply = Post.objects.create_post(title='',
315 text='[post]%d[/post]\ntext' % opening_post.id,
316 thread=opening_post.thread_new)
317
318 # Check the timestamp before post was added
319 response = api_get_threaddiff(MockRequest(),
320 str(opening_post.thread_new.id),
321 str(last_edit_time))
322 diff = simplejson.loads(response.content)
323 self.assertEqual(1, len(diff['added']),
324 'There must be 1 added posts in the diff.')
325 self.assertEqual(1, len(diff['updated']),
326 'There must be 1 updated posts in the diff.')
327
328 empty_response = api_get_threaddiff(MockRequest(),
329 str(opening_post.thread_new.id),
330 str(datetime_to_epoch(reply.last_edit_time)))
331 diff = simplejson.loads(empty_response.content)
332 self.assertEqual(0, len(diff['added']),
333 'There must be no added posts in the diff.')
334 self.assertEqual(0, len(diff['updated']),
335 'There must be no updated posts in the diff.')
336
@@ -38,7 +38,10 b' def api_get_threaddiff(request, thread_i'
38 38
39 39 thread = get_object_or_404(Post, id=thread_id).get_thread()
40 40
41 filter_time = datetime.fromtimestamp(float(last_update_time) / 1000000,
41 # Add 1 to ensure we don't load the same post over and over
42 last_update_timestamp = float(last_update_time) + 1
43
44 filter_time = datetime.fromtimestamp(last_update_timestamp / 1000000,
42 45 timezone.get_current_timezone())
43 46
44 47 json_data = {
General Comments 0
You need to be logged in to leave comments. Login now