Show More
@@ -2,4 +2,6 b' import re' | |||
|
2 | 2 | |
|
3 | 3 | FILE_DIRECTORY = 'files/' |
|
4 | 4 | REGEX_TAGS = re.compile(r'^[\w\s\d\']+$', re.UNICODE) |
|
5 | REGEX_REPLY = re.compile(r'\[post\](\d+)\[/post\]') No newline at end of file | |
|
5 | REGEX_REPLY = re.compile(r'\[post\](\d+)\[/post\]') | |
|
6 | ||
|
7 | PARAM_PAGE = 'page' No newline at end of file |
@@ -6,6 +6,7 b' from django.utils.decorators import meth' | |||
|
6 | 6 | from django.views.decorators.csrf import csrf_protect |
|
7 | 7 | |
|
8 | 8 | from boards import settings |
|
9 | from boards.abstracts.constants import PARAM_PAGE | |
|
9 | 10 | from boards.abstracts.paginator import get_paginator |
|
10 | 11 | from boards.abstracts.settingsmanager import get_settings_manager, \ |
|
11 | 12 | SETTING_ONLY_FAVORITES |
@@ -16,6 +17,10 b' from boards.views.mixins import FileUplo' | |||
|
16 | 17 | DispatcherMixin, PARAMETER_METHOD |
|
17 | 18 | from boards.settings import SECTION_VIEW, SECTION_FORMS |
|
18 | 19 | |
|
20 | ORDER_BUMP = 'bump' | |
|
21 | ||
|
22 | PARAM_ORDER = 'order' | |
|
23 | ||
|
19 | 24 | FORM_TAGS = 'tags' |
|
20 | 25 | FORM_TEXT = 'text' |
|
21 | 26 | FORM_TITLE = 'title' |
@@ -47,29 +52,28 b' class AllThreadsView(FileUploadMixin, Ba' | |||
|
47 | 52 | |
|
48 | 53 | @method_decorator(csrf_protect) |
|
49 | 54 | def get(self, request, form: ThreadForm=None): |
|
50 |
page = request.GET.get( |
|
|
55 | page = request.GET.get(PARAM_PAGE, DEFAULT_PAGE) | |
|
51 | 56 | |
|
52 | 57 | params = self.get_context_data(request=request) |
|
53 | 58 | |
|
54 | 59 | if not form: |
|
55 | 60 | form = ThreadForm(error_class=PlainErrorList, |
|
56 | initial={FORM_TAGS: self.tag_name}) | |
|
61 | initial={FORM_TAGS: self.tag_name}) | |
|
57 | 62 | |
|
58 | 63 | self.settings_manager = get_settings_manager(request) |
|
59 | 64 | |
|
60 | 65 | threads = self.get_threads() |
|
61 | 66 | |
|
62 |
order = request.GET.get( |
|
|
63 |
if order == |
|
|
67 | order = request.GET.get(PARAM_ORDER, ORDER_BUMP) | |
|
68 | if order == ORDER_BUMP: | |
|
64 | 69 | threads = threads.order_by('-bump_time') |
|
65 | 70 | else: |
|
66 | 71 | threads = threads.filter(replies__opening=True)\ |
|
67 | 72 | .order_by('-replies__pub_time') |
|
68 | filter = request.GET.get('filter') | |
|
69 | 73 | threads = threads.distinct() |
|
70 | 74 | |
|
71 | paginator = get_paginator(threads, | |
|
72 |
|
|
|
75 | paginator = get_paginator(threads, settings.get_int( | |
|
76 | SECTION_VIEW, 'ThreadsPerPage')) | |
|
73 | 77 | paginator.current_page = int(page) |
|
74 | 78 | |
|
75 | 79 | try: |
@@ -93,7 +97,7 b' class AllThreadsView(FileUploadMixin, Ba' | |||
|
93 | 97 | if PARAMETER_METHOD in request.POST: |
|
94 | 98 | self.dispatch_method(request) |
|
95 | 99 | |
|
96 | return redirect('index') # FIXME Different for different modes | |
|
100 | return self.get_reverse_url() | |
|
97 | 101 | |
|
98 | 102 | form = ThreadForm(request.POST, request.FILES, |
|
99 | 103 | error_class=PlainErrorList) |
@@ -2,6 +2,7 b' from django.urls import reverse' | |||
|
2 | 2 | from django.shortcuts import render |
|
3 | 3 | |
|
4 | 4 | from boards import settings |
|
5 | from boards.abstracts.constants import PARAM_PAGE | |
|
5 | 6 | from boards.abstracts.paginator import get_paginator |
|
6 | 7 | from boards.abstracts.settingsmanager import get_settings_manager |
|
7 | 8 | from boards.models import Post |
@@ -101,7 +102,7 b' class FeedView(PaginatedMixin, BaseBoard' | |||
|
101 | 102 | ) |
|
102 | 103 | |
|
103 | 104 | def get(self, request): |
|
104 |
page = request.GET.get( |
|
|
105 | page = request.GET.get(PARAM_PAGE, DEFAULT_PAGE) | |
|
105 | 106 | |
|
106 | 107 | params = self.get_context_data(request=request) |
|
107 | 108 |
@@ -1,4 +1,5 b'' | |||
|
1 | 1 | import boards |
|
2 | from boards.settings import SECTION_FORMS | |
|
2 | 3 | |
|
3 | 4 | PARAM_NEXT = 'next' |
|
4 | 5 | PARAMETER_METHOD = 'method' |
@@ -36,7 +37,7 b' class DispatcherMixin:' | |||
|
36 | 37 | |
|
37 | 38 | class FileUploadMixin: |
|
38 | 39 | def get_max_upload_size(self): |
|
39 |
return boards.settings.get_int( |
|
|
40 | return boards.settings.get_int(SECTION_FORMS, 'MaxFileSize') | |
|
40 | 41 | |
|
41 | 42 | |
|
42 | 43 | class PaginatedMixin: |
@@ -1,17 +1,16 b'' | |||
|
1 | 1 | from django.shortcuts import render |
|
2 | 2 | |
|
3 | from boards.abstracts.constants import PARAM_PAGE | |
|
3 | 4 | from boards.abstracts.paginator import get_paginator |
|
4 | 5 | from boards.abstracts.settingsmanager import get_settings_manager, \ |
|
5 |
|
|
|
6 | SETTING_LAST_NOTIFICATION_ID | |
|
6 | 7 | from boards.models.user import Notification |
|
7 | 8 | from boards.views.base import BaseBoardView |
|
8 | 9 | |
|
9 | 10 | DEFAULT_PAGE = '1' |
|
10 | 11 | |
|
11 | 12 | TEMPLATE = 'boards/notifications.html' |
|
12 | PARAM_PAGE = 'page' | |
|
13 | 13 | PARAM_USERNAMES = 'notification_usernames' |
|
14 | REQUEST_PAGE = 'page' | |
|
15 | 14 | RESULTS_PER_PAGE = 10 |
|
16 | 15 | |
|
17 | 16 | |
@@ -41,7 +40,7 b' class NotificationView(BaseBoardView):' | |||
|
41 | 40 | |
|
42 | 41 | paginator = get_paginator(posts, RESULTS_PER_PAGE) |
|
43 | 42 | |
|
44 |
page = int(request.GET.get( |
|
|
43 | page = int(request.GET.get(PARAM_PAGE, DEFAULT_PAGE)) | |
|
45 | 44 | |
|
46 | 45 | params[PARAM_PAGE] = paginator.page(page) |
|
47 | 46 | params[PARAM_USERNAMES] = notification_usernames |
@@ -2,6 +2,7 b' from django.shortcuts import get_object_' | |||
|
2 | 2 | from django.urls import reverse |
|
3 | 3 | |
|
4 | 4 | from boards import settings |
|
5 | from boards.abstracts.constants import PARAM_PAGE | |
|
5 | 6 | from boards.abstracts.paginator import get_paginator |
|
6 | 7 | from boards.models import TagAlias |
|
7 | 8 | from boards.settings import SECTION_VIEW |
@@ -16,7 +17,7 b" TEMPLATE = 'boards/tag_gallery.html'" | |||
|
16 | 17 | class TagGalleryView(BaseBoardView, PaginatedMixin): |
|
17 | 18 | |
|
18 | 19 | def get(self, request, tag_name): |
|
19 |
page = int(request.GET.get( |
|
|
20 | page = int(request.GET.get(PARAM_PAGE, 1)) | |
|
20 | 21 | |
|
21 | 22 | params = dict() |
|
22 | 23 | tag_alias = get_object_or_404(TagAlias, name=tag_name) |
@@ -1,11 +1,11 b'' | |||
|
1 | from django.contrib.auth.decorators import permission_required | |
|
1 | 2 | from django.shortcuts import redirect |
|
2 | 3 | from django.utils.decorators import method_decorator |
|
3 | 4 | from django.views.decorators.csrf import csrf_protect |
|
4 | from django.contrib.auth.decorators import permission_required | |
|
5 | 5 | |
|
6 | from boards.views.base import BaseBoardView, CONTEXT_FORM | |
|
7 | from boards.views.mixins import DispatcherMixin, PARAMETER_METHOD | |
|
8 | 6 | from boards.models import Post, Ban |
|
7 | from boards.views.base import BaseBoardView | |
|
8 | from boards.views.mixins import DispatcherMixin | |
|
9 | 9 | |
|
10 | 10 | |
|
11 | 11 | class UtilsView(BaseBoardView, DispatcherMixin): |
General Comments 0
You need to be logged in to leave comments.
Login now