Show More
@@ -0,0 +1,26 b'' | |||||
|
1 | {% extends 'boards/base.html' %} | |||
|
2 | ||||
|
3 | {% load i18n %} | |||
|
4 | {% load board %} | |||
|
5 | ||||
|
6 | {% block metapanel %} | |||
|
7 | ||||
|
8 | <span class="metapanel"> | |||
|
9 | {% trans "Pages:" %} | |||
|
10 | [ | |||
|
11 | {% with dividers=paginator.get_dividers %} | |||
|
12 | {% for page in paginator.get_divided_range %} | |||
|
13 | {% if page in dividers %} | |||
|
14 | β¦, | |||
|
15 | {% endif %} | |||
|
16 | <a | |||
|
17 | {% ifequal page current_page.number %} | |||
|
18 | class="current_page" | |||
|
19 | {% endifequal %} | |||
|
20 | href="{% page_url paginator page %}">{{ page }}</a>{% if not forloop.last %},{% endif %} | |||
|
21 | {% endfor %} | |||
|
22 | {% endwith %} | |||
|
23 | ] | |||
|
24 | </span> | |||
|
25 | ||||
|
26 | {% endblock %} |
@@ -1,4 +1,4 b'' | |||||
1 |
{% extends "boards/ |
|
1 | {% extends "boards/paginated.html" %} | |
2 |
|
2 | |||
3 | {% load i18n %} |
|
3 | {% load i18n %} | |
4 | {% load board %} |
|
4 | {% load board %} |
@@ -1,4 +1,4 b'' | |||||
1 |
{% extends "boards/ |
|
1 | {% extends "boards/paginated.html" %} | |
2 |
|
2 | |||
3 | {% load i18n %} |
|
3 | {% load i18n %} | |
4 | {% load board %} |
|
4 | {% load board %} | |
@@ -50,24 +50,3 b'' | |||||
50 | {% endif %} |
|
50 | {% endif %} | |
51 | {% endblock %} |
|
51 | {% endblock %} | |
52 |
|
52 | |||
53 | {% block metapanel %} |
|
|||
54 |
|
||||
55 | <span class="metapanel"> |
|
|||
56 | {% trans "Pages:" %} |
|
|||
57 | [ |
|
|||
58 | {% with dividers=paginator.get_dividers %} |
|
|||
59 | {% for page in paginator.get_divided_range %} |
|
|||
60 | {% if page in dividers %} |
|
|||
61 | β¦, |
|
|||
62 | {% endif %} |
|
|||
63 | <a |
|
|||
64 | {% ifequal page current_page.number %} |
|
|||
65 | class="current_page" |
|
|||
66 | {% endifequal %} |
|
|||
67 | href="{% page_url paginator page %}">{{ page }}</a>{% if not forloop.last %},{% endif %} |
|
|||
68 | {% endfor %} |
|
|||
69 | {% endwith %} |
|
|||
70 | ] |
|
|||
71 | </span> |
|
|||
72 |
|
||||
73 | {% endblock %} |
|
@@ -1,4 +1,4 b'' | |||||
1 |
{% extends 'boards/ |
|
1 | {% extends 'boards/paginated.html' %} | |
2 |
|
2 | |||
3 | {% load board %} |
|
3 | {% load board %} | |
4 | {% load i18n %} |
|
4 | {% load i18n %} | |
@@ -6,6 +6,13 b'' | |||||
6 | {% block head %} |
|
6 | {% block head %} | |
7 | <title>{% trans 'Search' %} - {{ site_name }}</title> |
|
7 | <title>{% trans 'Search' %} - {{ site_name }}</title> | |
8 | <meta name="robots" content="noindex"> |
|
8 | <meta name="robots" content="noindex"> | |
|
9 | ||||
|
10 | {% if prev_page_link %} | |||
|
11 | <link rel="prev" href="{{ prev_page_link }}" /> | |||
|
12 | {% endif %} | |||
|
13 | {% if next_page_link %} | |||
|
14 | <link rel="next" href="{{ next_page_link }}" /> | |||
|
15 | {% endif %} | |||
9 | {% endblock %} |
|
16 | {% endblock %} | |
10 |
|
17 | |||
11 | {% block content %} |
|
18 | {% block content %} | |
@@ -20,23 +27,22 b'' | |||||
20 | </div> |
|
27 | </div> | |
21 | </div> |
|
28 | </div> | |
22 |
|
29 | |||
23 | {% if page %} |
|
30 | {% if current_page %} | |
24 |
{% if p |
|
31 | {% if prev_page_link %} | |
25 | <div class="page_link"> |
|
32 | <div class="page_link"> | |
26 |
<a href=" |
|
33 | <a href="{{ prev_page_link }}"><< {% trans "Previous page" %} <<</a> | |
27 | </a> |
|
|||
28 | </div> |
|
34 | </div> | |
29 | {% endif %} |
|
35 | {% endif %} | |
30 |
|
36 | |||
31 | {% for result in page.object_list %} |
|
37 | {% for result in current_page.object_list %} | |
32 | {% post_view result truncated=True need_op_data=True %} |
|
38 | {% post_view result truncated=True need_op_data=True %} | |
33 | {% endfor %} |
|
39 | {% endfor %} | |
34 |
|
40 | |||
35 |
{% if |
|
41 | {% if next_page_link %} | |
36 | <div class="page_link"> |
|
42 | <div class="page_link"> | |
37 |
<a href=" |
|
43 | <a href="{{ next_page_link }}">>> {% trans "Next page" %} >></a> | |
38 | </a> |
|
|||
39 | </div> |
|
44 | </div> | |
40 | {% endif %} |
|
45 | {% endif %} | |
41 | {% endif %} |
|
46 | {% endif %} | |
42 | {% endblock %} |
|
47 | {% endblock %} | |
|
48 |
@@ -1,10 +1,12 b'' | |||||
1 | from django.shortcuts import render |
|
1 | from django.shortcuts import render | |
2 | from django.views.generic import View |
|
2 | from django.views.generic import View | |
3 | from django.db.models import Q |
|
3 | from django.db.models import Q | |
|
4 | from django.core.urlresolvers import reverse | |||
4 |
|
5 | |||
5 | from boards.abstracts.paginator import get_paginator |
|
6 | from boards.abstracts.paginator import get_paginator | |
6 | from boards.forms import SearchForm, PlainErrorList |
|
7 | from boards.forms import SearchForm, PlainErrorList | |
7 | from boards.models import Post |
|
8 | from boards.models import Post | |
|
9 | from boards.views.mixins import PaginatedMixin | |||
8 |
|
10 | |||
9 |
|
11 | |||
10 | MIN_QUERY_LENGTH = 3 |
|
12 | MIN_QUERY_LENGTH = 3 | |
@@ -23,7 +25,7 b" REQUEST_PAGE = 'page'" | |||||
23 | TEMPLATE = 'search/search.html' |
|
25 | TEMPLATE = 'search/search.html' | |
24 |
|
26 | |||
25 |
|
27 | |||
26 | class BoardSearchView(View): |
|
28 | class BoardSearchView(View, PaginatedMixin): | |
27 | def get(self, request): |
|
29 | def get(self, request): | |
28 | params = dict() |
|
30 | params = dict() | |
29 |
|
31 | |||
@@ -37,10 +39,11 b' class BoardSearchView(View):' | |||||
37 | | Q(title__icontains=query) | Q(opening=True, |
|
39 | | Q(title__icontains=query) | Q(opening=True, | |
38 | thread__tags__aliases__name__icontains=query)).order_by('-id').distinct() |
|
40 | thread__tags__aliases__name__icontains=query)).order_by('-id').distinct() | |
39 | paginator = get_paginator(results, RESULTS_PER_PAGE) |
|
41 | paginator = get_paginator(results, RESULTS_PER_PAGE) | |
|
42 | paginator.set_url(reverse('search'), request.GET.dict()) | |||
40 |
|
43 | |||
41 | page = int(request.GET.get(REQUEST_PAGE, '1')) |
|
44 | page = int(request.GET.get(REQUEST_PAGE, '1')) | |
42 |
|
45 | |||
43 | params[CONTEXT_PAGE] = paginator.page(page) |
|
|||
44 | params[CONTEXT_QUERY] = query |
|
46 | params[CONTEXT_QUERY] = query | |
|
47 | params.update(self.get_page_context(paginator, page)) | |||
45 |
|
48 | |||
46 | return render(request, TEMPLATE, params) |
|
49 | return render(request, TEMPLATE, params) |
General Comments 0
You need to be logged in to leave comments.
Login now