As an admin I want to be able to create a custom use. As an user I want to see listed only posts in the current selected language. As an user I want to be able to switch languages between EN-DE

This commit is contained in:
Levi 2016-06-23 21:32:51 -05:00
commit 2b50f9fdd9
7 changed files with 49 additions and 12 deletions

View file

@ -1,4 +1,4 @@
{% load cms_tags staticfiles %}
{% load i18n cms_tags staticfiles menu_tags sekizai_tags %}
<!-- Page Header -->
<!-- Set your background image for this header on the line below. -->
<header class="intro-header"
@ -12,11 +12,26 @@
<div class="container">
<div class="row">
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
<div class="site-heading">
<h1> {% page_attribute 'page_title' %} </h1>
<hr class="small">
<span class="subheading"> {% page_attribute 'meta_description' %}</span>
</div>
<div class="site-heading">
{% if languages|length > 1 %}
<div class="center-block">
<ul class="list-inline center-block language-chooser-list">
{% for language in languages %}
<li class="lang{% if current_language == language.0 %} active{% endif %}">
<a href="{% page_language_url language.0 %}" style="color:white;font-size:16px;"
title="{% trans "Change to language:" %} {{ language.1 }}">{{ language.1 }}</a>
</li>
{% endfor %}
</ul>
</div>
{% endif %}
<h1> {% page_attribute 'page_title' %} </h1>
<hr class="small">
<span class="subheading"> {% page_attribute 'meta_description' %}</span>
</div>
</div>
</div>
</div>

View file

@ -36,10 +36,12 @@
{% render_block "css" postprocessor "compressor.contrib.sekizai.compress" %}
</head>
<body>
{% cms_toolbar %}
{% show_menu 0 0 0 1 "cms/ungleichch/_menu.html" %}
<!-- body -->
<!-- Main Content -->
{% block base_header %}
{% include "cms/ungleichch/_header_base.html" %}
{% endblock %}

View file

@ -1,3 +1,4 @@
from django.conf import settings
from django.shortcuts import render
from django.utils.translation import get_language
from djangocms_blog.models import Post
@ -8,7 +9,6 @@ from djangocms_blog.settings import get_setting
def blog(request):
posts = Post.objects.all()
print(posts)
context = {
'post_list': posts
}
@ -26,6 +26,9 @@ class PostListViewUngleich(PostListView):
def get_context_data(self, **kwargs):
context = super(PostListView, self).get_context_data(**kwargs)
context['TRUNCWORDS_COUNT'] = get_setting('POSTS_LIST_TRUNCWORDS_COUNT')
context['languages'] = settings.LANGUAGES
context['current_language'] = get_language()
return context
def get_paginate_by(self, queryset):