diff --git a/digitalglarus/views.py b/digitalglarus/views.py index 3fe04e88..4f45cf1b 100644 --- a/digitalglarus/views.py +++ b/digitalglarus/views.py @@ -62,7 +62,7 @@ def contact(request): def blog(request): tags = ["digitalglarus"] - posts = Post.objects.filter_by_language(get_language()).filter(tags__name__in=tags) + posts = Post.objects.filter_by_language(get_language()).filter(tags__name__in=tags).filter(slug=slug) context = { 'post_list': posts, } diff --git a/dynamicweb/settings/base.py b/dynamicweb/settings/base.py index 37561a74..f6486c56 100644 --- a/dynamicweb/settings/base.py +++ b/dynamicweb/settings/base.py @@ -132,7 +132,12 @@ TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(PROJECT_DIR,'cms_templates/'), - os.path.join(PROJECT_DIR,'cms_templates/djangocms_blog/') + os.path.join(PROJECT_DIR,'cms_templates/djangocms_blog/'), + os.path.join(PROJECT_DIR,'membership'), + os.path.join(PROJECT_DIR,'ungleich/templates/djangocms_blog/'), + os.path.join(PROJECT_DIR,'ungleich/templates/cms/ungleichch'), + os.path.join(PROJECT_DIR,'ungleich/templates/ungleich') + ], 'APP_DIRS': True, 'OPTIONS': { @@ -162,8 +167,11 @@ CMS_TEMPLATES = ( ('contact.html', gettext('DG.Contact')), ('index.html', gettext('DG.Home')), ('letscowork.html', gettext('DG.CoWork')), - ('detail.html', gettext('DG.Detail')), - ('one_column.html', gettext('DG.OneColumn')) + # ('detail.html', gettext('DG.Detail')), + ('one_column.html', gettext('DG.OneColumn')), + #ungleich + ('blog_ungleich.html', gettext('Blog')), + ('page.html', gettext('Page')), ) DATABASES = { diff --git a/dynamicweb/urls.py b/dynamicweb/urls.py index 7f06be82..1d5e5823 100644 --- a/dynamicweb/urls.py +++ b/dynamicweb/urls.py @@ -18,6 +18,8 @@ urlpatterns = [ # note the django CMS URLs included via i18n_patterns urlpatterns += i18n_patterns('', + url(r'^$',include('ungleich.urls')), + url(r'^blog/',include('ungleich.urls',namespace='ungleich')), url(r'^login/',include(membership_urls)), url(r'^admin/', include(admin.site.urls)), url(r'^digitalglarus/', include('digitalglarus.urls', diff --git a/ungleich/templates/cms/ungleichch/__init__.py b/ungleich/templates/cms/ungleichch/__init__.py index 403fbcc0..c2394ab6 100644 --- a/ungleich/templates/cms/ungleichch/__init__.py +++ b/ungleich/templates/cms/ungleichch/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- from django.utils.translation import ugettext_lazy as _ -TEMPLATES = { - 'blog.html': _('Blog'), - 'page.html': _('Page'), -} +# TEMPLATES = { +# 'blog_u.html': _('Blog'), +# 'page.html': _('Page'), +# } diff --git a/ungleich/templates/cms/ungleichch/_header_base.html b/ungleich/templates/cms/ungleichch/_header_base.html index 43e535f6..35e1973c 100644 --- a/ungleich/templates/cms/ungleichch/_header_base.html +++ b/ungleich/templates/cms/ungleichch/_header_base.html @@ -2,8 +2,8 @@
+ {% block content_blog %}{% endblock %} + +{% endblock content %} \ No newline at end of file diff --git a/ungleich/templates/ungleich/djangocms_blog/includes/blog_item.html b/ungleich/templates/ungleich/djangocms_blog/includes/blog_item.html new file mode 100644 index 00000000..0ec8535a --- /dev/null +++ b/ungleich/templates/ungleich/djangocms_blog/includes/blog_item.html @@ -0,0 +1,31 @@ +{% load i18n thumbnail cms_tags %} + +
+ +

+ {{ post.title }} +

+

+ {% if not TRUNCWORDS_COUNT %} + {% render_model post "abstract" %} + {% else %} + {% render_model post "abstract" "" "" 'truncatewords_html:TRUNCWORDS_COUNT' %} + {% endif %} +

+
+ +
+
diff --git a/ungleich/templates/ungleich/djangocms_blog/post_detail.html b/ungleich/templates/ungleich/djangocms_blog/post_detail.html new file mode 100644 index 00000000..3139c71c --- /dev/null +++ b/ungleich/templates/ungleich/djangocms_blog/post_detail.html @@ -0,0 +1,49 @@ +{% extends "ungleich/djangocms_blog/base.html" %} +{% load i18n thumbnail cms_tags %} +{% block meta_description %}{{ post.meta_description }}{% endblock meta_description %} +{% block meta_keywords %}{{ post.meta_keywords }}{% endblock meta_keywords %} +{% block canonical_url %}{% endblock canonical_url %} +{% block title %}{% page_attribute "page_title" %} - {{ post.get_title }}{% endblock %} + +{% block base_header %} +{% include "_header_post_detail.html" %} +{% endblock %} + +{% block content_blog %} +
+ {% if post.app_config.use_placeholder %} +
{% render_placeholder post.content %}
+ {% else %} +
{% render_model post "post_text" "post_text" %}
+ {% endif %} +
+{% endblock content_blog %} +{#{% load i18n thumbnail cms_tags %}#} +{##} +{#{% block meta_description %}{{ post.meta_description }}{% endblock meta_description %}#} +{#{% block meta_keywords %}{{ post.meta_keywords }}{% endblock meta_keywords %}#} +{#{% block canonical_url %}{% endblock canonical_url %}#} +{#{% block title %}{{ post.get_title }}{% endblock %}#} +{##} +{#{% block content_blog %}{% spaceless %}#} +{#
#} +{#
#} +{#

{% render_model post "title" %}

#} +{# {% block blog_meta %}#} +{# {% include "djangocms_blog/includes/blog_meta.html" %}#} +{# {% endblock %}#} +{#
#} +{# {% if post.main_image_id %}#} +{#
#} +{# {% thumbnail post.main_image post.full_image_options.size crop=post.full_image_options.crop upscale=post.full_image_options.upscale subject_location=post.main_image.subject_location as thumb %}#} +{# {{ post.main_image.default_alt_text }}#} +{#
#} +{# {% endif %}#} +{# {% endspaceless %}#} +{# {% if post.app_config.use_placeholder %}#} +{#
{% render_placeholder post.content %}
#} +{# {% else %}#} +{#
{% render_model post "post_text" "post_text" %}
#} +{# {% endif %}#} +{#
#} +{#{% endblock content_blog %}#} \ No newline at end of file diff --git a/ungleich/templates/ungleich/djangocms_blog/post_list_ungleich.html b/ungleich/templates/ungleich/djangocms_blog/post_list_ungleich.html new file mode 100644 index 00000000..e377fa90 --- /dev/null +++ b/ungleich/templates/ungleich/djangocms_blog/post_list_ungleich.html @@ -0,0 +1,90 @@ +{% extends "ungleich/djangocms_blog/base.html" %} +{% load i18n thumbnail %}{% spaceless %} + +{% block canonical_url %}{% endblock canonical_url %} + +{% block content_blog %} +
+ {% block blog_title %} +
+

+ {% if author %}{% trans "Articles by" %} {{ author.get_full_name }} + {% elif archive_date %}{% trans "Archive" %} – {% if month %}{{ archive_date|date:'F' }} {% endif %}{{ year }} + {% elif tagged_entries %}{% trans "Tag" %} – {{ tagged_entries|capfirst }} + {% elif category %}{% trans "Category" %} – {{ category }}{% endif %} +

+
+ + {% endblock %} + {% for post in post_list %} + {% include "ungleich/djangocms_blog/includes/blog_item.html" with post=post image="true" TRUNCWORDS_COUNT=TRUNCWORDS_COUNT %} + {% empty %} +

{% trans "No article found." %}

+ {% endfor %} + {% if author or archive_date or tagged_entries %} +

{% trans "Back" %}

+ {% endif %} + {% if is_paginated %} + + + {% endif %} +
+{% endblock %} +{% endspaceless %} + + +{#{% load i18n thumbnail %}{% spaceless %}#} +{##} +{#{% block canonical_url %}{% endblock canonical_url %}#} +{##} +{#{% block content_blog %}#} +{#
#} +{# {% block blog_title %}#} +{#
#} +{#

#} +{# {% if author %}{% trans "Articles by" %} {{ author.get_full_name }}#} +{# {% elif archive_date %}{% trans "Archive" %} – {% if month %}{{ archive_date|date:'F' }} {% endif %}{{ year }}#} +{# {% elif tagged_entries %}{% trans "Tag" %} – {{ tagged_entries|capfirst }}#} +{# {% elif category %}{% trans "Category" %} – {{ category }}{% endif %}#} +{#

#} +{#
#} +{# {% endblock %}#} +{# {% for post in post_list %}#} +{# {% include "djangocms_blog/includes/blog_item.html" with post=post image="true" TRUNCWORDS_COUNT=TRUNCWORDS_COUNT %}#} +{# {% empty %}#} +{#

{% trans "No article found." %}

#} +{# {% endfor %}#} +{# {% if author or archive_date or tagged_entries %}#} +{#

{% trans "Back" %}

#} +{# {% endif %}#} +{# {% if is_paginated %}#} +{# #} +{# {% endif %}#} +{#
#} +{#{% endblock %}#} +{#{% endspaceless %}#} \ No newline at end of file diff --git a/ungleich/urls.py b/ungleich/urls.py new file mode 100644 index 00000000..8e768c6e --- /dev/null +++ b/ungleich/urls.py @@ -0,0 +1,8 @@ +from django.conf.urls import url +from . import views + +urlpatterns = [ + url(r'^$',views.PostListViewUngleich.as_view()), + # url(r'^$',views.PostListView.as_view()), + url(r'^(?P\d{4})/(?P\d{1,2})/(?P\d{1,2})/(?P\w[-\w]*)/$',views.details) +] \ No newline at end of file diff --git a/ungleich/views.py b/ungleich/views.py index 91ea44a2..238632b5 100644 --- a/ungleich/views.py +++ b/ungleich/views.py @@ -1,3 +1,47 @@ from django.shortcuts import render +from django.utils.translation import get_language +from djangocms_blog.models import Post +from django.views.generic import ListView +from djangocms_blog.views import PostListView,BaseBlogView +from django.core.paginator import Paginator +from django.core.paginator import PageNotAnInteger +from django.core.paginator import EmptyPage +from djangocms_blog.settings import get_setting -# Create your views here. + +def blog(request): + posts = Post.objects.all() + print(posts) + context = { + 'post_list': posts + } + + # PostListView.base_template_name='post_list.html' + return render(request, 'ungleich/djangocms_blog/post_list_ungleich.html', context=context) + + +class PostListViewUngleich(PostListView): + model = Post + context_object_name = 'post_list' + base_template_name = 'post_list_ungleich.html' + paginate_by = 5 + + def get_context_data(self, **kwargs): + context = super(PostListView, self).get_context_data(**kwargs) + context['TRUNCWORDS_COUNT'] = get_setting('POSTS_LIST_TRUNCWORDS_COUNT') + return context + + def get_paginate_by(self, queryset): + return get_setting('PAGINATION') + + def get_queryset(self): + language = get_language() + queryset = self.model.objects.translated(language) + setattr(self.request, get_setting('CURRENT_NAMESPACE'), self.config) + return queryset + + +def details(request, year, month, day, slug): + post = Post.objects.translated(get_language(), slug=slug).first() + context = {'post': post} + return render(request, 'ungleich/djangocms_blog/post_detail.html', context=context)