aboutsummaryrefslogtreecommitdiff
path: root/weblog/views.py
diff options
context:
space:
mode:
authorYaroslsav-95 <contact@yaroslavps.com>2018-06-22 20:20:50 +0300
committerYaroslsav-95 <contact@yaroslavps.com>2018-06-22 20:20:50 +0300
commit8fd79ffe610d4fce69913fd167d437322347c3d4 (patch)
treeaff5144c6c04ca91f62dfeaa6fc9a9c9323248df /weblog/views.py
parent2f255efc8f662fa29e8112e6eb9642f33af25ad9 (diff)
downloadw3blog-8fd79ffe610d4fce69913fd167d437322347c3d4.tar.gz
w3blog-8fd79ffe610d4fce69913fd167d437322347c3d4.zip
read post in another language (templates missing links)
Diffstat (limited to 'weblog/views.py')
-rwxr-xr-xweblog/views.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/weblog/views.py b/weblog/views.py
index e082d05..f28f201 100755
--- a/weblog/views.py
+++ b/weblog/views.py
@@ -153,7 +153,9 @@ def Index(request, **kwargs):
return render(request, 'weblog/index.html', context_dict)
-def PostView(request, category_slug, post_slug):
+def PostView(request, category_slug, post_slug, language=None):
+ if language and not IS_MULTILINGUAL:
+ redirect('weblog:PostView', category_slug=category_slug, post_slug=post_slug)
post = get_object_or_404(BlogPost, slug=post_slug)
context_dict = blog_settings.copy()
context_dict['comment_form'] = PostCommentForm()
@@ -218,7 +220,9 @@ def PostView(request, category_slug, post_slug):
context_dict['languages'] = [orig_lang,]
for post_translation in post_translations:
context_dict['languages'].append(post_translation.language)
- if current_language[0:2] == post_translation.language[0:2]:
+ if language and language == post_translation.language[0:2]:
+ context_dict['post_translation'] = post_translation
+ elif current_language[0:2] == post_translation.language[0:2]:
context_dict['post_translation'] = post_translation
if 'post_translation' in context_dict:
context_dict['breadcrumbs'].append({'url': post.get_absolute_url(), 'name': post_translation.title})