Merge pull request #623 from pcoder/task/4370/ungleich_comic
Task/4370/ungleich comic
This commit is contained in:
commit
526426c6c0
2 changed files with 28 additions and 2 deletions
|
@ -11,6 +11,7 @@ from hosting.views import (
|
|||
RailsHostingView, DjangoHostingView, NodeJSHostingView
|
||||
)
|
||||
from membership import urls as membership_urls
|
||||
from ungleich import views as ungleich_views
|
||||
from ungleich_page.views import LandingView
|
||||
from django.views.generic import RedirectView
|
||||
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]*)/$',
|
||||
RedirectView.as_view(pattern_name='ungleich:post-detail')),
|
||||
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'^blog/', include('djangocms_blog.urls', namespace='djangocms_blog')),
|
||||
url(r'^$', RedirectView.as_view(url='/cms') if REDIRECT_TO_CMS
|
||||
|
|
|
@ -7,6 +7,7 @@ from djangocms_blog.models import Post
|
|||
from djangocms_blog.views import PostListView
|
||||
from djangocms_blog.settings import get_setting
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from djangocms_blog.models import BlogCategory
|
||||
|
||||
|
||||
def blog(request):
|
||||
|
@ -20,6 +21,7 @@ def blog(request):
|
|||
|
||||
|
||||
class PostListViewUngleich(PostListView):
|
||||
category = None
|
||||
model = Post
|
||||
context_object_name = 'post_list'
|
||||
base_template_name = 'post_list_ungleich.html'
|
||||
|
@ -38,7 +40,26 @@ class PostListViewUngleich(PostListView):
|
|||
|
||||
def get_queryset(self):
|
||||
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)
|
||||
return queryset
|
||||
|
||||
|
|
Loading…
Reference in a new issue