##// 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 for tag_name in tag_names:
79 for tag_name in tag_names:
80 tag = get_object_or_404(Tag, name=tag_name)
80 tag = get_object_or_404(Tag, name=tag_name)
81 tags.append(tag)
81 tags.append(tag)
82
83 return tags
82 return tags
84
83
85 def add_fav_tag(self, tag):
84 def add_fav_tag(self, tag):
@@ -89,6 +88,8 b' class SettingsManager:'
89 else:
88 else:
90 if not tag.name in tags:
89 if not tag.name in tags:
91 tags.append(tag.name)
90 tags.append(tag.name)
91
92 tags.sort()
92 self.set_setting(SETTING_FAVORITE_TAGS, tags)
93 self.set_setting(SETTING_FAVORITE_TAGS, tags)
93
94
94 def del_fav_tag(self, tag):
95 def del_fav_tag(self, tag):
@@ -114,6 +115,8 b' class SettingsManager:'
114 else:
115 else:
115 if not tag.name in tags:
116 if not tag.name in tags:
116 tags.append(tag.name)
117 tags.append(tag.name)
118
119 tags.sort()
117 self.set_setting(SETTING_HIDDEN_TAGS, tags)
120 self.set_setting(SETTING_HIDDEN_TAGS, tags)
118
121
119 def del_hidden_tag(self, tag):
122 def del_hidden_tag(self, tag):
@@ -31,8 +31,13 b' class KeyPairAdmin(admin.ModelAdmin):'
31 list_filter = ('primary',)
31 list_filter = ('primary',)
32 search_fields = ('public_key',)
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 admin.site.register(Post, PostAdmin)
39 admin.site.register(Post, PostAdmin)
35 admin.site.register(Tag, TagAdmin)
40 admin.site.register(Tag, TagAdmin)
36 admin.site.register(Ban)
41 admin.site.register(Ban, BanAdmin)
37 admin.site.register(Thread, ThreadAdmin)
42 admin.site.register(Thread, ThreadAdmin)
38 admin.site.register(KeyPair, KeyPairAdmin)
43 admin.site.register(KeyPair, KeyPairAdmin)
@@ -9,7 +9,7 b' import boards'
9 __author__ = 'neko259'
9 __author__ = 'neko259'
10
10
11
11
12 REFLINK_PATTERN = re.compile(r'\d+')
12 REFLINK_PATTERN = re.compile(r'^\d+$')
13 MULTI_NEWLINES_PATTERN = re.compile(r'(\r?\n){2,}')
13 MULTI_NEWLINES_PATTERN = re.compile(r'(\r?\n){2,}')
14 ONE_NEWLINE = '\n'
14 ONE_NEWLINE = '\n'
15
15
@@ -124,7 +124,7 b' def render_reflink(tag_name, value, opti'
124 if posts.exists():
124 if posts.exists():
125 post = posts[0]
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 else:
128 else:
129 return u'>>%s' % value
129 return u'>>%s' % value
130
130
@@ -250,6 +250,8 b' a:hover {'
250 .last-replies {
250 .last-replies {
251 margin-left: 3ex;
251 margin-left: 3ex;
252 margin-right: 3ex;
252 margin-right: 3ex;
253 border-left: solid 1px #777;
254 border-right: solid 1px #777;
253 }
255 }
254
256
255 .thread {
257 .thread {
@@ -374,7 +376,12 b' li {'
374 }
376 }
375
377
376 .skipped_replies {
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 .current_page {
387 .current_page {
@@ -14,8 +14,6 b''
14 {% spaceless %}
14 {% spaceless %}
15 {% get_current_language as LANGUAGE_CODE %}
15 {% get_current_language as LANGUAGE_CODE %}
16
16
17 <script src="{% static 'js/thread.js' %}"></script>
18
19 {% cache 600 thread_gallery_view thread.id thread.last_edit_time LANGUAGE_CODE request.get_host %}
17 {% cache 600 thread_gallery_view thread.id thread.last_edit_time LANGUAGE_CODE request.get_host %}
20 <div class="image-mode-tab">
18 <div class="image-mode-tab">
21 <a href="{% url 'thread' thread.get_opening_post.id %}">{% trans 'Normal mode' %}</a>,
19 <a href="{% url 'thread' thread.get_opening_post.id %}">{% trans 'Normal mode' %}</a>,
@@ -1,6 +1,7 b''
1 # coding=utf-8
1 # coding=utf-8
2 import time
2 import time
3 import logging
3 import logging
4 import simplejson
4 from django.core.paginator import Paginator
5 from django.core.paginator import Paginator
5
6
6 from django.test import TestCase
7 from django.test import TestCase
@@ -11,6 +12,8 b' from boards.abstracts.settingsmanager im'
11 from boards.models import Post, Tag, Thread, KeyPair
12 from boards.models import Post, Tag, Thread, KeyPair
12 from boards import urls
13 from boards import urls
13 from boards import settings
14 from boards import settings
15 from boards.views.api import api_get_threaddiff
16 from boards.utils import datetime_to_epoch
14 import neboard
17 import neboard
15
18
16 TEST_TAG = 'test_tag'
19 TEST_TAG = 'test_tag'
@@ -261,6 +264,8 b' class AbstractTest(TestCase):'
261 class MockRequest:
264 class MockRequest:
262 def __init__(self):
265 def __init__(self):
263 self.session = dict()
266 self.session = dict()
267 self.GET = dict()
268 self.POST = dict()
264
269
265
270
266 class KeyTest(TestCase):
271 class KeyTest(TestCase):
@@ -286,3 +291,46 b' class KeyTest(TestCase):'
286 self.fail('Exception should be thrown indicating there can be only one primary key.')
291 self.fail('Exception should be thrown indicating there can be only one primary key.')
287 except Exception:
292 except Exception:
288 pass
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 thread = get_object_or_404(Post, id=thread_id).get_thread()
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 timezone.get_current_timezone())
45 timezone.get_current_timezone())
43
46
44 json_data = {
47 json_data = {
General Comments 0
You need to be logged in to leave comments. Login now