Skip to content

Commit cde1e8e

Browse files
author
a.shtyrnyaev
committed
first commit
1 parent 0e5ebb5 commit cde1e8e

File tree

4 files changed

+75
-0
lines changed

4 files changed

+75
-0
lines changed

apps/news/views.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,31 @@ def get_context_data(self, **kwargs):
2828
return context
2929

3030

31+
class PostView(TemplateView):
32+
template_name = 'post.html'
33+
34+
def get_context_data(self, **kwargs):
35+
context = super().get_context_data()
36+
pk = self.kwargs.get('pk')
37+
post = Article.objects.get(id=pk)
38+
39+
article_featured = Article.objects.featured()
40+
context.update({
41+
'article_featured': article_featured,
42+
'articles_top': [a for a in Article.objects.active()[:3] if a != article_featured],
43+
'articles_all': [a for a in Article.objects.active()[3:10] if a != article_featured],
44+
'events': Event.objects.upcoming()[:5],
45+
'post': post,
46+
'links': sorted(Link.objects.all(), key=lambda i: Link.SECTION_SLUGS.index(i.section)),
47+
'social_links': [
48+
{'id': 'facebook', 'url': 'https://www.facebook.com/groups/MoscowDjango/', 'name': 'facebook'},
49+
{'id': 'twitter', 'url': 'https://twitter.com/moscowpython', 'name': 'twitter'},
50+
{'id': 'slack', 'url': 'http://slack.python.ru/', 'name': 'slack'},
51+
]
52+
})
53+
return context
54+
55+
3156
class JuniorView(RedirectView):
3257
permanent = True
3358

python_ru/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
url(r'^$', news_views.IndexView.as_view(), name='index'),
1111
url(r'^meetups/', include('apps.meetups.urls')),
1212
url(r'^junior/$', news_views.JuniorView.as_view(), name='junior'),
13+
url(r'^post/(?P<pk>\d+)/$', news_views.PostView.as_view(), name='post_page'),
1314

1415
url(r'^admin/', include(admin.site.urls)),
1516
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

templates/blocks/news_post.html

Whitespace-only changes.

templates/post.html

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{% extends 'base.html' %}
2+
3+
{% block main_content %}
4+
{% load staticfiles nginx_image %}
5+
<section class="news-section" id="news">
6+
<div class="container">
7+
<div class="js-masonry" data-masonry-options='{"columnWidth": 2, "itemSelector": ".grid-item" }'>
8+
9+
<article class="grid-item large">
10+
<div class="item-holder">
11+
<div class="text-holder">
12+
{% if article_featured.image %}
13+
<img src="{% thumbnail article_featured.image 792 529 %}" width="792" height="529" alt="">
14+
{% endif %}
15+
<div class="description">
16+
<time datetime="">{{ article_featured.published_at|date:"j E Y" }}</time>
17+
<h1>{{ post.name }}</h1>
18+
<article class="article">
19+
{{ post.description }}
20+
</article>
21+
</div>
22+
</div>
23+
</div>
24+
</article>
25+
26+
{# News right sidebar #}
27+
<section class="grid-item articles-list">
28+
<div class="item-holder">
29+
<strong class="title">Новости</strong>
30+
<div class="articles-holder">
31+
{% for article in articles_top %}
32+
<time datetime="{{ event.date|date:"Y-m-d H:m" }}">{{ article.published_at|date:"j E Y" }}</time>
33+
<h1><a href="{{ article.url }}" target="_blank">
34+
{{ article.name }}
35+
</a></h1>
36+
</article>
37+
{% endfor %}
38+
</div>
39+
</div>
40+
</section>
41+
42+
</div>
43+
44+
</div>
45+
</section>
46+
47+
{% include 'blocks/subscribe.html' %}
48+
{% include 'blocks/links.html' %}
49+
{% endblock %}

0 commit comments

Comments
 (0)