Merge pull request #623 from pcoder/task/4370/ungleich_comic

Task/4370/ungleich comic
This commit is contained in:
Arvind Tiwari 2018-04-21 22:47:08 +05:30 committed by GitHub
commit 526426c6c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 2 deletions

View file

@ -11,6 +11,7 @@ from hosting.views import (
RailsHostingView, DjangoHostingView, NodeJSHostingView RailsHostingView, DjangoHostingView, NodeJSHostingView
) )
from membership import urls as membership_urls from membership import urls as membership_urls
from ungleich import views as ungleich_views
from ungleich_page.views import LandingView from ungleich_page.views import LandingView
from django.views.generic import RedirectView from django.views.generic import RedirectView
from django.core.urlresolvers import reverse_lazy from django.core.urlresolvers import reverse_lazy
@ -54,7 +55,11 @@ urlpatterns += i18n_patterns(
url(r'^blog/(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/(?P<slug>\w[-\w]*)/$', url(r'^blog/(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/(?P<slug>\w[-\w]*)/$',
RedirectView.as_view(pattern_name='ungleich:post-detail')), RedirectView.as_view(pattern_name='ungleich:post-detail')),
url(r'^blog/$', url(r'^blog/$',
RedirectView.as_view(url=reverse_lazy('ungleich:post-list')), name='blog_list_view'), RedirectView.as_view(url=reverse_lazy('ungleich:post-list')),
name='blog_list_view'),
url(r'^comic/$',
ungleich_views.PostListViewUngleich.as_view(category='comic'),
name='comic_post_list_view'),
url(r'^cms/', include('cms.urls')), url(r'^cms/', include('cms.urls')),
url(r'^blog/', include('djangocms_blog.urls', namespace='djangocms_blog')), url(r'^blog/', include('djangocms_blog.urls', namespace='djangocms_blog')),
url(r'^$', RedirectView.as_view(url='/cms') if REDIRECT_TO_CMS url(r'^$', RedirectView.as_view(url='/cms') if REDIRECT_TO_CMS

View file

@ -7,6 +7,7 @@ from djangocms_blog.models import Post
from djangocms_blog.views import PostListView from djangocms_blog.views import PostListView
from djangocms_blog.settings import get_setting from djangocms_blog.settings import get_setting
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from djangocms_blog.models import BlogCategory
def blog(request): def blog(request):
@ -20,6 +21,7 @@ def blog(request):
class PostListViewUngleich(PostListView): class PostListViewUngleich(PostListView):
category = None
model = Post model = Post
context_object_name = 'post_list' context_object_name = 'post_list'
base_template_name = 'post_list_ungleich.html' base_template_name = 'post_list_ungleich.html'
@ -38,7 +40,26 @@ class PostListViewUngleich(PostListView):
def get_queryset(self): def get_queryset(self):
language = get_language() language = get_language()
queryset = self.model.objects.filter(publish=True).translated(language) if self.category:
blog_category = (
BlogCategory
._default_manager
.language(language)
.filter(
translations__language_code=language,
translations__slug=self.category
)
)
queryset = (self.model
.objects
.filter(categories=blog_category, publish=True)
.translated(language))
else:
queryset = (self.model
.objects
.filter(publish=True)
.translated(language))
setattr(self.request, get_setting('CURRENT_NAMESPACE'), self.config) setattr(self.request, get_setting('CURRENT_NAMESPACE'), self.config)
return queryset return queryset