Skip to content

Commit c7b8bdd

Browse files
author
roman
committed
Некоторые хотфиксы.
1 parent 7825d43 commit c7b8bdd

File tree

6 files changed

+32
-11
lines changed

6 files changed

+32
-11
lines changed

play_murmansk/board/templates/board/board_list.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{% block title %}Продам Куплю Обменяю - PLAYSTATION и XBOX в Мурманске{% endblock %}
55

66
{% block content %}
7-
<td valign="top" style="padding:0px 10px 0px 10px;"><table border="0" cellpadding="0" cellspacing="0" width="100%">
7+
<table border="0" cellpadding="0" cellspacing="0" width="100%">
88
<tbody><tr>
99
<td width="80%"><a class="m" href="https://web.archive.org/web/20100907080651/http://play-murmansk.ru/">Главная</a> » Доска объявлений (<b>119</b>)</td>
1010
<td align="right" style="white-space: nowrap;"></td>
@@ -47,5 +47,4 @@
4747
{% endfor %}
4848
</div>
4949
{% include "pagination.html" %}
50-
</td>
5150
{% endblock %}

play_murmansk/board/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from django.views.generic import ListView, DetailView, CreateView, UpdateView, DeleteView
1+
from django.views.generic import ListView, DetailView, CreateView
22
from django.db.models import Count
33
from django.urls import reverse
44
from django.contrib.auth.decorators import login_required

play_murmansk/core/templatetags/custom_filters.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,15 @@ def strip_p_tags_for_news_list(value):
1414

1515
@register.filter
1616
def get_item(dictionary, key):
17-
return dictionary.get(key[0])
17+
return dictionary.get(key[0])
18+
19+
@register.filter
20+
def translate_category(key):
21+
categories = {
22+
'SELL': 'ПРОДАМ',
23+
'BUY': 'КУПЛЮ',
24+
'EXCHANGE': 'ОБМЕНЯЮ',
25+
'VARIOUS': 'РАЗНОЕ',
26+
'SERVICES': 'УСЛУГИ',
27+
}
28+
return categories.get(key, None)

play_murmansk/links/templates/links/link_list.html

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,11 @@
1515
<tbody>
1616
{% for category_link in link_category_list %}
1717
<tr>
18-
<td style="width:100%" class="catsTd" id="cid1" valign="top"><a href="https://web.archive.org/web/20100907080651/http://play-murmansk.ru/board/1" class="catName">{{ category_link.0 }}</a> <span class="catNumData" style="unicode-bidi:embed;">[59]</span></td>
18+
<td style="width:100%" class="catsTd" id="cid1" valign="top"><a href="{% url 'links' %}?category={{ category_link.0 }}" class="catName">{{ category_link.0 }}</a> <span class="catNumData" style="unicode-bidi:embed;">[{{ link_category_counts|get_item:category_link|default:0 }}]</span></td>
1919
</tr>
2020
{% endfor %}
2121
</tbody>
2222
</table>
23-
<hr>
24-
<span class="pagesBlockuz1"><b class="swchItemA"><span>1</span></b> <a class="swchItem" href="javascript://" rel="nofollow" onclick="spages('2');return false;"><span>2</span></a> <a class="swchItem" href="javascript://" rel="nofollow" onclick="spages('3');return false;"><span>3</span></a> <a class="swchItem" href="javascript://" rel="nofollow" onclick="spages('2');return false;"><span>»</span></a></span>
25-
<hr>
2623
<div id="myGrid" style="display:none;"><div style="position:fixed;width:100%;text-align:center;padding-top:250px;"><img alt="" src="https://web.archive.org/web/20100907080651im_/http://s28.ucoz.net/img/ma/m/i3.gif" border="0" width="220" height="19"></div></div>
2724
<div id="allEntries">
2825
{% for links in link_list %}
@@ -42,7 +39,5 @@
4239
</div></td></tr></tbody></table><br></div>
4340
{% endfor %}
4441
</div>
45-
<hr>
4642
{% include "pagination.html" %}
47-
<hr>
4843
{% endblock %}

play_murmansk/links/views.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,30 @@ class LinkListView(ListView):
88
model = Link
99
template_name = 'links/link_list.html'
1010
context_object_name = 'link_list'
11+
paginate_by = 10
1112

1213
def get_queryset(self):
14+
category_filter = self.request.GET.get('category')
15+
1316
queryset = Link.objects.annotate(
1417
comments_count=Count('comments')
1518
).order_by('-id')
19+
if category_filter:
20+
queryset = queryset.filter(category=category_filter)
1621
return queryset
1722

1823
def get_context_data(self, **kwargs):
1924
context = super().get_context_data(**kwargs)
25+
26+
category_counts = Link.objects.values('category').annotate(
27+
count=Count('id')
28+
)
29+
30+
# Преобразование в словарь
31+
category_counts_dict = {item['category']: item['count'] for item in category_counts}
32+
33+
# Добавление в контекст
34+
context['link_category_counts'] = category_counts_dict
2035
context['link_category_list'] = LinkCategory.choices
2136
return context
2237

play_murmansk/templates/base.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{% extends "index.html" %}
22
{% load static %}
3+
{% load custom_filters %}
34
{% block center %}
45
<div id="centerBlock1">
56
<!-- Body -->
@@ -182,7 +183,7 @@
182183
<table border="0" cellpadding="2" cellspacing="1" width="100%" class="infTable">
183184
<tbody>
184185
<tr>
185-
<td class="infTitle" colspan="2"> <span style="font-size: 7pt" ;=""> {{ board.category }} от {{ board.author }} </span> <br> <a class="ma" href="20110828124907/http://play-murmansk.ru/board/">{{ board.title }}</a></td>
186+
<td class="infTitle" colspan="2"> <span style="font-size: 7pt" ;=""> {{ board.category|translate_category }} от {{ board.author }} </span> <br> <a class="ma" href="20110828124907/http://play-murmansk.ru/board/">{{ board.title }}</a></td>
186187
</tr>
187188
</tbody>
188189
</table>

0 commit comments

Comments
 (0)