diff --git a/boards/abstracts/settingsmanager.py b/boards/abstracts/settingsmanager.py --- a/boards/abstracts/settingsmanager.py +++ b/boards/abstracts/settingsmanager.py @@ -79,7 +79,6 @@ class SettingsManager: for tag_name in tag_names: tag = get_object_or_404(Tag, name=tag_name) tags.append(tag) - return tags def add_fav_tag(self, tag): @@ -89,6 +88,8 @@ class SettingsManager: else: if not tag.name in tags: tags.append(tag.name) + + tags.sort() self.set_setting(SETTING_FAVORITE_TAGS, tags) def del_fav_tag(self, tag): @@ -114,6 +115,8 @@ class SettingsManager: else: if not tag.name in tags: tags.append(tag.name) + + tags.sort() self.set_setting(SETTING_HIDDEN_TAGS, tags) def del_hidden_tag(self, tag): diff --git a/boards/admin.py b/boards/admin.py --- a/boards/admin.py +++ b/boards/admin.py @@ -31,8 +31,13 @@ class KeyPairAdmin(admin.ModelAdmin): list_filter = ('primary',) search_fields = ('public_key',) +class BanAdmin(admin.ModelAdmin): + list_display = ('ip', 'can_read') + list_filter = ('can_read',) + search_fields = ('ip',) + admin.site.register(Post, PostAdmin) admin.site.register(Tag, TagAdmin) -admin.site.register(Ban) +admin.site.register(Ban, BanAdmin) admin.site.register(Thread, ThreadAdmin) admin.site.register(KeyPair, KeyPairAdmin) diff --git a/boards/mdx_neboard.py b/boards/mdx_neboard.py --- a/boards/mdx_neboard.py +++ b/boards/mdx_neboard.py @@ -9,7 +9,7 @@ import boards __author__ = 'neko259' -REFLINK_PATTERN = re.compile(r'\d+') +REFLINK_PATTERN = re.compile(r'^\d+$') MULTI_NEWLINES_PATTERN = re.compile(r'(\r?\n){2,}') ONE_NEWLINE = '\n' @@ -124,7 +124,7 @@ def render_reflink(tag_name, value, opti if posts.exists(): post = posts[0] - return u'>>%s' % (post.get_url(), post_id) + return u'>>%s' % (post.get_url(), post_id) else: return u'>>%s' % value diff --git a/boards/static/css/md/base_page.css b/boards/static/css/md/base_page.css --- a/boards/static/css/md/base_page.css +++ b/boards/static/css/md/base_page.css @@ -250,6 +250,8 @@ a:hover { .last-replies { margin-left: 3ex; margin-right: 3ex; + border-left: solid 1px #777; + border-right: solid 1px #777; } .thread { @@ -374,7 +376,12 @@ li { } .skipped_replies { - margin: 5px; + padding: 5px; + margin-left: 3ex; + margin-right: 3ex; + border-left: solid 1px #888; + border-right: solid 1px #888; + background: #000; } .current_page { diff --git a/boards/templates/boards/thread_gallery.html b/boards/templates/boards/thread_gallery.html --- a/boards/templates/boards/thread_gallery.html +++ b/boards/templates/boards/thread_gallery.html @@ -14,8 +14,6 @@ {% spaceless %} {% get_current_language as LANGUAGE_CODE %} - - {% cache 600 thread_gallery_view thread.id thread.last_edit_time LANGUAGE_CODE request.get_host %}
{% trans 'Normal mode' %}, diff --git a/boards/tests.py b/boards/tests.py --- a/boards/tests.py +++ b/boards/tests.py @@ -1,6 +1,7 @@ # coding=utf-8 import time import logging +import simplejson from django.core.paginator import Paginator from django.test import TestCase @@ -11,6 +12,8 @@ from boards.abstracts.settingsmanager im from boards.models import Post, Tag, Thread, KeyPair from boards import urls from boards import settings +from boards.views.api import api_get_threaddiff +from boards.utils import datetime_to_epoch import neboard TEST_TAG = 'test_tag' @@ -261,6 +264,8 @@ class AbstractTest(TestCase): class MockRequest: def __init__(self): self.session = dict() + self.GET = dict() + self.POST = dict() class KeyTest(TestCase): @@ -286,3 +291,46 @@ class KeyTest(TestCase): self.fail('Exception should be thrown indicating there can be only one primary key.') except Exception: pass + + +class ApiTest(TestCase): + def test_thread_diff(self): + tag = Tag.objects.create(name=TEST_TAG) + opening_post = Post.objects.create_post(title='title', text='text', + tags=[tag]) + + last_edit_time = datetime_to_epoch(opening_post.last_edit_time) + + # Check the exact timestamp post was added + empty_response = api_get_threaddiff(MockRequest(), + str(opening_post.thread_new.id), + str(last_edit_time)) + diff = simplejson.loads(empty_response.content) + self.assertEqual(0, len(diff['added']), + 'There must be no added posts in the diff.') + self.assertEqual(0, len(diff['updated']), + 'There must be no updated posts in the diff.') + + reply = Post.objects.create_post(title='', + text='[post]%d[/post]\ntext' % opening_post.id, + thread=opening_post.thread_new) + + # Check the timestamp before post was added + response = api_get_threaddiff(MockRequest(), + str(opening_post.thread_new.id), + str(last_edit_time)) + diff = simplejson.loads(response.content) + self.assertEqual(1, len(diff['added']), + 'There must be 1 added posts in the diff.') + self.assertEqual(1, len(diff['updated']), + 'There must be 1 updated posts in the diff.') + + empty_response = api_get_threaddiff(MockRequest(), + str(opening_post.thread_new.id), + str(datetime_to_epoch(reply.last_edit_time))) + diff = simplejson.loads(empty_response.content) + self.assertEqual(0, len(diff['added']), + 'There must be no added posts in the diff.') + self.assertEqual(0, len(diff['updated']), + 'There must be no updated posts in the diff.') + diff --git a/boards/views/api.py b/boards/views/api.py --- a/boards/views/api.py +++ b/boards/views/api.py @@ -38,7 +38,10 @@ def api_get_threaddiff(request, thread_i thread = get_object_or_404(Post, id=thread_id).get_thread() - filter_time = datetime.fromtimestamp(float(last_update_time) / 1000000, + # Add 1 to ensure we don't load the same post over and over + last_update_timestamp = float(last_update_time) + 1 + + filter_time = datetime.fromtimestamp(last_update_timestamp / 1000000, timezone.get_current_timezone()) json_data = {