##// END OF EJS Templates
Continue to extract section strings
neko259 -
r2004:d0cc4756 default
parent child Browse files
Show More
@@ -4,6 +4,7 b' from boards.models import Banner'
4 from boards.models.user import Notification
4 from boards.models.user import Notification
5 from boards import settings
5 from boards import settings
6 from boards.models import Post, Tag, Thread
6 from boards.models import Post, Tag, Thread
7 from boards.settings import SECTION_FORMS
7
8
8 CONTEXT_SITE_NAME = 'site_name'
9 CONTEXT_SITE_NAME = 'site_name'
9 CONTEXT_VERSION = 'version'
10 CONTEXT_VERSION = 'version'
@@ -66,7 +67,7 b' def user_and_ui_processor(request):'
66
67
67 if (settings.get_bool('Forms', 'LimitFirstPosting') and not settings_manager.get_setting('confirmed_user'))\
68 if (settings.get_bool('Forms', 'LimitFirstPosting') and not settings_manager.get_setting('confirmed_user'))\
68 or settings.get_bool('Forms', 'LimitPostingSpeed'):
69 or settings.get_bool('Forms', 'LimitPostingSpeed'):
69 context[CONTEXT_POW_DIFFICULTY] = settings.get_int('Forms', 'PowDifficulty')
70 context[CONTEXT_POW_DIFFICULTY] = settings.get_int(SECTION_FORMS, 'PowDifficulty')
70
71
71 context[CONTEXT_IMAGE_VIEWER] = settings_manager.get_setting(
72 context[CONTEXT_IMAGE_VIEWER] = settings_manager.get_setting(
72 SETTING_IMAGE_VIEWER,
73 SETTING_IMAGE_VIEWER,
@@ -10,7 +10,8 b' from boards import settings'
10 from boards.models import STATUS_BUMPLIMIT, STATUS_ACTIVE, STATUS_ARCHIVE
10 from boards.models import STATUS_BUMPLIMIT, STATUS_ACTIVE, STATUS_ARCHIVE
11 from boards.models.attachment import FILE_TYPES_IMAGE
11 from boards.models.attachment import FILE_TYPES_IMAGE
12 from boards.models.post import Post
12 from boards.models.post import Post
13 from boards.models.tag import Tag, DEFAULT_LOCALE, TagAlias
13 from boards.models.tag import Tag, TagAlias
14 from boards.settings import SECTION_VIEW
14 from boards.utils import cached_result, datetime_to_epoch
15 from boards.utils import cached_result, datetime_to_epoch
15
16
16 FAV_THREAD_NO_UPDATES = -1
17 FAV_THREAD_NO_UPDATES = -1
@@ -157,7 +158,7 b' class Thread(models.Model):'
157 Gets several last replies, not including opening post
158 Gets several last replies, not including opening post
158 """
159 """
159
160
160 last_replies_count = settings.get_int('View', 'LastRepliesCount')
161 last_replies_count = settings.get_int(SECTION_VIEW, 'LastRepliesCount')
161
162
162 if last_replies_count > 0:
163 if last_replies_count > 0:
163 reply_count = self.get_reply_count()
164 reply_count = self.get_reply_count()
@@ -175,7 +176,7 b' class Thread(models.Model):'
175 Gets number of posts between opening post and last replies.
176 Gets number of posts between opening post and last replies.
176 """
177 """
177 reply_count = self.get_reply_count()
178 reply_count = self.get_reply_count()
178 last_replies_count = min(settings.get_int('View', 'LastRepliesCount'),
179 last_replies_count = min(settings.get_int(SECTION_VIEW, 'LastRepliesCount'),
179 reply_count - 1)
180 reply_count - 1)
180 return reply_count - last_replies_count - 1
181 return reply_count - last_replies_count - 1
181
182
@@ -4,6 +4,7 b' from django.test import TestCase'
4 from boards import settings
4 from boards import settings
5 from boards.models import Tag, Post, Thread, KeyPair
5 from boards.models import Tag, Post, Thread, KeyPair
6 from boards.models.thread import STATUS_ARCHIVE
6 from boards.models.thread import STATUS_ARCHIVE
7 from boards.settings import SECTION_VIEW
7
8
8
9
9 class PostTests(TestCase):
10 class PostTests(TestCase):
@@ -93,17 +94,18 b' class PostTests(TestCase):'
93 def test_pages(self):
94 def test_pages(self):
94 """Test that the thread list is properly split into pages"""
95 """Test that the thread list is properly split into pages"""
95
96
96 for i in range(settings.get_int('View', 'ThreadsPerPage') * 2):
97 threads_per_page = settings.get_int(SECTION_VIEW, 'ThreadsPerPage')
98 for i in range(threads_per_page * 2):
97 self._create_post()
99 self._create_post()
98
100
99 all_threads = Thread.objects.exclude(status=STATUS_ARCHIVE)
101 all_threads = Thread.objects.exclude(status=STATUS_ARCHIVE)
100
102
101 paginator = Paginator(Thread.objects.exclude(status=STATUS_ARCHIVE),
103 paginator = Paginator(Thread.objects.exclude(status=STATUS_ARCHIVE),
102 settings.get_int('View', 'ThreadsPerPage'))
104 threads_per_page)
103 posts_in_second_page = paginator.page(2).object_list
105 posts_in_second_page = paginator.page(2).object_list
104 first_post = posts_in_second_page[0]
106 first_post = posts_in_second_page[0]
105
107
106 self.assertEqual(all_threads[settings.get_int('View', 'ThreadsPerPage')].id,
108 self.assertEqual(all_threads[threads_per_page].id,
107 first_post.id)
109 first_post.id)
108
110
109 def test_reflinks(self):
111 def test_reflinks(self):
@@ -5,10 +5,11 b' from boards import settings'
5 from boards.abstracts.paginator import get_paginator
5 from boards.abstracts.paginator import get_paginator
6 from boards.abstracts.settingsmanager import get_settings_manager
6 from boards.abstracts.settingsmanager import get_settings_manager
7 from boards.models import Post
7 from boards.models import Post
8 from boards.settings import SECTION_VIEW
8 from boards.views.base import BaseBoardView
9 from boards.views.base import BaseBoardView
9 from boards.views.mixins import PaginatedMixin
10 from boards.views.mixins import PaginatedMixin
10
11
11 POSTS_PER_PAGE = settings.get_int('View', 'PostsPerPage')
12 POSTS_PER_PAGE = settings.get_int(SECTION_VIEW, 'PostsPerPage')
12
13
13 PARAMETER_POSTS = 'posts'
14 PARAMETER_POSTS = 'posts'
14 PARAMETER_QUERIES = 'queries'
15 PARAMETER_QUERIES = 'queries'
@@ -7,8 +7,8 b' from django.utils.decorators import meth'
7 from django.views.decorators.csrf import csrf_protect
7 from django.views.decorators.csrf import csrf_protect
8
8
9 from boards import settings
9 from boards import settings
10 from boards.models import Post, Tag, Attachment, STATUS_ACTIVE, TagAlias
10 from boards.models import Post, Tag, STATUS_ACTIVE, TagAlias
11 from boards.models.tag import DEFAULT_LOCALE
11 from boards.settings import SECTION_VIEW
12 from boards.views.base import BaseBoardView
12 from boards.views.base import BaseBoardView
13
13
14 PARAM_SECTION_STR = 'section_str'
14 PARAM_SECTION_STR = 'section_str'
@@ -31,7 +31,7 b' class LandingView(BaseBoardView):'
31 .annotate(today_post_count=Count('thread__replies'))\
31 .annotate(today_post_count=Count('thread__replies'))\
32 .order_by('-pub_time')
32 .order_by('-pub_time')
33
33
34 max_landing_threads = settings.get_int('View', 'MaxLandingThreads')
34 max_landing_threads = settings.get_int(SECTION_VIEW, 'MaxLandingThreads')
35 if max_landing_threads > 0:
35 if max_landing_threads > 0:
36 ops = ops[:max_landing_threads]
36 ops = ops[:max_landing_threads]
37
37
@@ -4,10 +4,11 b' from django.urls import reverse'
4 from boards import settings
4 from boards import settings
5 from boards.abstracts.paginator import get_paginator
5 from boards.abstracts.paginator import get_paginator
6 from boards.models import TagAlias
6 from boards.models import TagAlias
7 from boards.settings import SECTION_VIEW
7 from boards.views.base import BaseBoardView
8 from boards.views.base import BaseBoardView
8 from boards.views.mixins import PaginatedMixin
9 from boards.views.mixins import PaginatedMixin
9
10
10 IMAGES_PER_PAGE = settings.get_int('View', 'ImagesPerPageGallery')
11 IMAGES_PER_PAGE = settings.get_int(SECTION_VIEW, 'ImagesPerPageGallery')
11
12
12 TEMPLATE = 'boards/tag_gallery.html'
13 TEMPLATE = 'boards/tag_gallery.html'
13
14
@@ -1,4 +1,5 b''
1 from boards import settings
1 from boards import settings
2 from boards.settings import SECTION_FORMS
2 from boards.views.thread import ThreadView
3 from boards.views.thread import ThreadView
3 from boards.views.mixins import FileUploadMixin
4 from boards.views.mixins import FileUploadMixin
4
5
@@ -31,6 +32,6 b' class NormalThreadView(ThreadView, FileU'
31 params[CONTEXT_BUMPLIMIT_PRG] = str(
32 params[CONTEXT_BUMPLIMIT_PRG] = str(
32 float(left_posts) / max_posts * 100)
33 float(left_posts) / max_posts * 100)
33 params[PARAM_MAX_FILE_SIZE] = self.get_max_upload_size()
34 params[PARAM_MAX_FILE_SIZE] = self.get_max_upload_size()
34 params[PARAM_MAX_FILES] = settings.get_int('Forms', 'MaxFileCount')
35 params[PARAM_MAX_FILES] = settings.get_int(SECTION_FORMS, 'MaxFileCount')
35
36
36 return params
37 return params
General Comments 0
You need to be logged in to leave comments. Login now