Commit 4674eafd24738890b60b787caaf1dc1897e40e69
1 parent
b68b6b67
Exists in
master
and in
10 other branches
Add Pagination to ThreadDashboard view
Signed-off-by: Alexandre Barbosa <alexandreab@live.com> Signed-off-by: Gustavo Jaruga <darksshades@gmail.com> Signed-off-by: Lucas Moura <lucas.moura128@gmail.com> Signed-off-by: Lucas Kanashiro <kanashiro.duarte@gmail.com> Signed-off-by: Macartur Sousa <macartur.sc@gmail.com> Signed-off-by: Matheus Faria <matheus.sousa.faria@gmail.com>
Showing
2 changed files
with
49 additions
and
0 deletions
Show diff stats
colab/super_archives/templates/superarchives/thread-dashboard.html
@@ -49,4 +49,52 @@ | @@ -49,4 +49,52 @@ | ||
49 | {% endif %} | 49 | {% endif %} |
50 | {% endfor %} | 50 | {% endfor %} |
51 | 51 | ||
52 | + {% if page_obj.has_other_pages %} | ||
53 | + <div class="text-center"> | ||
54 | + <ul class="pagination"> | ||
55 | + <li {% if page_obj.number == 1 %}class="disabled"{% endif %}> | ||
56 | + <a href="{% if page_obj.number == 1 %}javascript:void(0);{% else %}?page={{1}}{% endif %}"><span class="glyphicon glyphicon-chevron-left small-icon"></span><span class="glyphicon glyphicon-chevron-left small-icon"></span></a> | ||
57 | + </li> | ||
58 | + <li {% if not page_obj.has_previous %}class="disabled"{% endif %}> | ||
59 | + <a href="{% if page_obj.has_previous %}?page={{page_obj.previous_page_number }}{% else %}javascript:void(0);{% endif %}"><span class="glyphicon glyphicon-chevron-left small-icon"></span></a> | ||
60 | + </li> | ||
61 | + | ||
62 | + {% if page_obj.has_previous %} | ||
63 | + {% if page_obj.previous_page_number > 1 %} | ||
64 | + <li> | ||
65 | + <a href="?page={{page_obj.previous_page_number|add:-2 }}">{{ page_obj.number|add:-2 }}</a> | ||
66 | + </li> | ||
67 | + {% endif %} | ||
68 | + <li> | ||
69 | + <a href="?page={{page_obj.previous_page_number }}">{{ page_obj.number|add:-1 }}</a> | ||
70 | + </li> | ||
71 | + {% endif %} | ||
72 | + | ||
73 | + <li class="active"> | ||
74 | + <a href="javascript:void(0);">{{ page_obj.number }}</a> | ||
75 | + </li> | ||
76 | + | ||
77 | + {% if page_obj.has_next %} | ||
78 | + <li> | ||
79 | + <a href="?page={{page_obj.next_page_number }}">{{ page_obj.number|add:1 }}</a> | ||
80 | + </li> | ||
81 | + {% if page_obj.next_page_number < page_obj.paginator.num_pages %} | ||
82 | + <li> | ||
83 | + <a href="?page={{page_obj.next_page_number|add:1 }}">{{ page_obj.number|add:2 }}</a> | ||
84 | + </li> | ||
85 | + {% endif %} | ||
86 | + {% endif %} | ||
87 | + | ||
88 | + <li {% if not page_obj.has_next %}class="disabled"{% endif %}> | ||
89 | + <a href="{% if page_obj.has_next %}?page={{page_obj.next_page_number }}{% else %}javascript:void(0);{% endif %}"><span class="glyphicon glyphicon-chevron-right small-icon"></span></a> | ||
90 | + </li> | ||
91 | + | ||
92 | + <li {% if page_obj.number == page_obj.paginator.num_pages %}class="disabled"{% endif %}> | ||
93 | + <a href="{% if page_obj.number == page_obj.paginator.num_pages %}javascript:void(0);{% else %}?page={{page_obj.paginator.num_pages }}{% endif %}"><span class="glyphicon glyphicon-chevron-right small-icon"></span><span class="glyphicon glyphicon-chevron-right small-icon"></span></a> | ||
94 | + </li> | ||
95 | + | ||
96 | + </ul> | ||
97 | + </div> | ||
98 | + {% endif %} | ||
99 | + | ||
52 | {% endblock %} | 100 | {% endblock %} |
colab/super_archives/views.py
@@ -142,6 +142,7 @@ class ThreadDashboardView(ListView): | @@ -142,6 +142,7 @@ class ThreadDashboardView(ListView): | ||
142 | http_method_names = ['get'] | 142 | http_method_names = ['get'] |
143 | context_object_name = 'lists' | 143 | context_object_name = 'lists' |
144 | template_name = 'superarchives/thread-dashboard.html' | 144 | template_name = 'superarchives/thread-dashboard.html' |
145 | + paginate_by = 10 | ||
145 | 146 | ||
146 | def get_queryset(self): | 147 | def get_queryset(self): |
147 | listnames_for_user = [] | 148 | listnames_for_user = [] |