Skip to content

Commit f3f586d

Browse files
committed
Merge pull request #144 from proevo/index_news
Load blog entries on the homepage from the database.
2 parents 1a707b0 + 50800c2 commit f3f586d

File tree

5 files changed

+15
-16
lines changed

5 files changed

+15
-16
lines changed

blogs/templatetags/blogs.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66

77

88
@register.assignment_tag
9-
def get_latest_blog_entries(number=5):
10-
""" Return number of latest blog entries """
11-
return BlogEntry.objects.order_by("-pub_date")[:number]
9+
def get_latest_blog_entries(limit=5):
10+
""" Return limit of latest blog entries """
11+
return BlogEntry.objects.order_by("-pub_date")[:limit]

blogs/views.py

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ def get_context_data(self, *args, **kwargs):
2525
'translations': Translation.objects.all(),
2626
'contributors': Contributor.objects.all(),
2727
'blog_url': settings.PYTHON_BLOG_URL,
28-
'feed_url': settings.PYTHON_BLOG_FEED_URL,
2928
})
3029

3130
return context

pydotorg/views.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ class IndexView(TemplateView):
1717

1818
def get_context_data(self, **kwargs):
1919
context = super().get_context_data(**kwargs)
20-
context['code_samples'] = CodeSample.objects.published()[:5]
20+
21+
context.update({
22+
'code_samples': CodeSample.objects.published()[:5],
23+
'blog_url': settings.PYTHON_BLOG_URL,
24+
})
2125
return context
2226

2327

templates/components/blog-posts.html

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1+
{% load blogs %}
12
<div class="shrubbery">
2-
3-
<!-- Need to hook this up and make it pull out 5 new blog activities -->
4-
3+
54
<h2 class="widget-title"><span aria-hidden="true" class="icon-news"></span>Latest News</h2>
6-
<p class="give-me-more"><a href="#fixme" title="More News">More</a></p>
5+
<p class="give-me-more"><a href="{{ blog_url }}" title="More News">More</a></p>
76

87
<ul class="menu">
9-
<li><time datetime="2012-09-29">9/29<span class="say-no-more">/2012</span></time> <a href="#example">Python 3.3.0 released</a></li>
10-
<li><time datetime="2012-09-24">9/24<span class="say-no-more">/2012</span></time> <a href="#example">Third rc for Python 3.3.0 released</a></li>
11-
<li><time datetime="2012-09-14">9/14<span class="say-no-more">/2012</span></time> <a href="#example">Python Software Foundation announces Distinguished Service Award</a></li>
12-
<li><time datetime="2012-09-11">9/11<span class="say-no-more">/2012</span></time> <a href="#example">ConFoo conference in Canada, February 25th - March 13th</a></li>
13-
<li><time datetime="2012-09-09">9/9<span class="say-no-more">/2012</span></time> <a href="#example">Second rc for Python 3.3.0 released</a></li>
8+
{% get_latest_blog_entries limit=5 as entries %}
9+
{% for entry in entries %}
10+
<li><time datetime="{{ entry.pub_date|date:'c' }}">{{ entry.pub_date|date:"SHORT_DATE_FORMAT"|slice:":5" }}<span class="say-no-more">/{{ entry.pub_date|date:"Y" }}</span></time> <a href="{{ entry.url }}">{{ entry.summary|striptags|truncatewords:10|safe }}</a></li>
11+
{% endfor %}
1412
</ul>
1513
</div><!-- end .shrubbery -->

templates/components/event-posts.html

-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
<h2 class="widget-title"><span aria-hidden="true" class="icon-calendar"></span>Upcoming Events</h2>
55
<p class="give-me-more"><a href="{% url 'events:calendar_list' %}" title="More Events">More</a></p>
66

7-
<!-- Need to hook these up and pull in 5 upcoming events -->
8-
97
<ul class="menu">
108
{% get_events_upcoming limit=5 as events %}
119
{% for event in events %}

0 commit comments

Comments
 (0)