Skip to content

Commit 54c1966

Browse files
authored
Merge pull request #22 from moscowpython/fix_link_banners
Fix link banners
2 parents 2f86d92 + a8c2464 commit 54c1966

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

apps/banners/templatetags/banner_tag.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,14 @@ def get_banner(context, place):
4848

4949
if not banners:
5050
return ''
51-
for banner in banners:
52-
53-
response = loader.render_to_string("blocks/banner.html", {
54-
'image': banner.file_img,
55-
'place': place,
56-
'width': banner.width,
57-
'height': banner.height,
58-
})
51+
52+
banner = banners.first()
53+
54+
response = loader.render_to_string("blocks/banner.html", {
55+
'image': banner.file_img,
56+
'place': place,
57+
'width': banner.width,
58+
'height': banner.height,
59+
'link_to': banner.link_to,
60+
})
5961
return response

templates/blocks/banner.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{% load staticfiles nginx_image %}
22

33
<div id="banner" style="text-align: center;">
4-
5-
{% if image %}
6-
<img src="{% thumbnail image %}" width="{{width}}" height="{{height}}" alt="">
7-
{% endif %}
8-
9-
{% if context %}
10-
{{ context }}
11-
{% endif %}
12-
4+
<a href="{% if link_to %}{{ link_to }}{% endif %}">
5+
{% if image %}
6+
<img src="{% thumbnail image %}" width="{{width}}" height="{{height}}" alt="">
7+
{% endif %}
8+
9+
{% if context %}
10+
{{ context }}
11+
{% endif %}
12+
</a>
1313
</div>

0 commit comments

Comments
 (0)