]> git.parisson.com Git - mezzo.git/commitdiff
Article view
authorEmilie <zawadzki@ircam.fr>
Thu, 7 Jul 2016 16:32:26 +0000 (18:32 +0200)
committerEmilie <zawadzki@ircam.fr>
Thu, 7 Jul 2016 16:32:26 +0000 (18:32 +0200)
app/organization/magazine/urls.py [new file with mode: 0644]
app/organization/magazine/views.py
app/templates/templates/magazine/article/article_detail.html [new file with mode: 0644]
app/urls.py

diff --git a/app/organization/magazine/urls.py b/app/organization/magazine/urls.py
new file mode 100644 (file)
index 0000000..6eb9a9b
--- /dev/null
@@ -0,0 +1,16 @@
+from __future__ import unicode_literals
+
+from django.conf.urls import patterns, include, url
+from django.conf.urls.i18n import i18n_patterns
+from django.contrib import admin
+
+from mezzanine.core.views import direct_to_template
+from mezzanine.conf import settings
+
+from organization.magazine.views import *
+
+
+urlpatterns = [
+    url(r'^article/$', ArticleListView.as_view(), name="magazine-article-list"),
+    url(r'^article/detail/(?P<slug>.*)/$', ArticleDetailView.as_view(), name="magazine-article-detail"),
+]
index 91ea44a218fbd2f408430959283f0419c921093e..c3dc0f4637aa4dfbd6c7790ee6b25487a2c0e537 100644 (file)
@@ -1,3 +1,32 @@
 from django.shortcuts import render
+from organization.magazine.models import Article
+from organization.core.views import SlugMixin
 
 # Create your views here.
+class ArticleDetailView(SlugMixin, DetailView):
+
+    model = Article
+    template_name='magazine/article/article_detail.html'
+    context_object_name = 'article'
+
+    def get_context_data(self, **kwargs):
+        context = super(ArticleDetailView, self).get_context_data(**kwargs)
+        return context
+
+
+def blog_post_detail(request, slug, year=None, month=None, day=None,
+                     template="blog/blog_post_detail.html",
+                     extra_context=None):
+    """. Custom templates are checked for using the name
+    ``blog/blog_post_detail_XXX.html`` where ``XXX`` is the blog
+    posts's slug.
+    """
+    blog_posts = BlogPost.objects.published(
+                                     for_user=request.user).select_related()
+    blog_post = get_object_or_404(blog_posts, slug=slug)
+    related_posts = blog_post.related_posts.published(for_user=request.user)
+    context = {"blog_post": blog_post, "editable_obj": blog_post,
+               "related_posts": related_posts}
+    context.update(extra_context or {})
+    templates = [u"blog/blog_post_detail_%s.html" % str(slug), template]
+    return TemplateResponse(request, templates, context)
diff --git a/app/templates/templates/magazine/article/article_detail.html b/app/templates/templates/magazine/article/article_detail.html
new file mode 100644 (file)
index 0000000..038899f
--- /dev/null
@@ -0,0 +1,148 @@
+{% extends "blog/blog_post_list.html" %}
+{% load mezzanine_tags comment_tags keyword_tags rating_tags i18n disqus_tags featured_tags %}
+
+{% block meta_title %}{{ blog_post.meta_title }}{% endblock %}
+
+{% block meta_keywords %}{% metablock %}
+{% keywords_for blog_post as tags %}
+{% for tag in tags %}{% if not forloop.first %}, {% endif %}{{ tag }}{% endfor %}
+{% endmetablock %}{% endblock %}
+
+{% block meta_description %}{% metablock %}
+{{ blog_post.description }}
+{% endmetablock %}{% endblock %}
+
+{% block title %}
+{% editable blog_post.title %}{{ blog_post.title }}{% endeditable %}
+{% endblock %}
+
+{% block breadcrumb_menu %}
+{{ block.super }}
+<li class="active">{{ blog_post.title }}</li>
+{% endblock %}
+
+{% block main %}
+coucou
+{% block blog_post_detail_postedby %}
+{% editable blog_post.publish_date %}
+<h6 class="post-meta">
+    {% trans "published on" %} {{ blog_post.publish_date|date:"DATE_FORMAT" }}
+</h6>
+{% endeditable %}
+{% endblock %}
+{% block blog_post_detail_commentlink %}
+<p>
+    {% if blog_post.allow_comments %}
+        {% if settings.COMMENTS_DISQUS_SHORTNAME %}
+            (<a href="{{ blog_post.get_absolute_url }}#disqus_thread"
+                data-disqus-identifier="{% disqus_id_for blog_post %}">{% spaceless %}
+                {% trans "Comments" %}
+            {% endspaceless %}</a>)
+        {% else %}(<a href="#comments">{% spaceless %}
+            {% blocktrans count comments_count=blog_post.comments_count %}{{ comments_count }} comment{% plural %}{{ comments_count }} comments{% endblocktrans %}
+            {% endspaceless %}</a>)
+        {% endif %}
+    {% endif %}
+</p>
+{% endblock %}
+
+{% comment %}
+{% block blog_post_detail_featured_image %}
+{% if settings.BLOG_USE_FEATURED_IMAGE and blog_post.featured_image %}
+<p><img class="img-responsive" src="{{ MEDIA_URL }}{% thumbnail blog_post.featured_image 600 0 %}"></p>
+{% endif %}
+{% endblock %}
+{% endcomment %}
+
+{% if settings.COMMENTS_DISQUS_SHORTNAME %}
+{% include "generic/includes/disqus_counts.html" %}
+{% endif %}
+
+{% block blog_post_detail_content %}
+{% editable blog_post.content %}
+{{ blog_post.content|richtext_filters|safe }}
+{% endeditable %}
+{% endblock %}
+
+{% block blog_post_detail_keywords %}
+{% keywords_for blog_post as tags %}
+{% if tags %}
+{% spaceless %}
+<ul class="list-inline tags">
+    <li>{% trans "Tags" %}:</li>
+    {% for tag in tags %}
+    <li><a href="{% url "blog_post_list_tag" tag.slug %}">{{ tag }}</a>{% if not forloop.last %}, {% endif %}</li>
+    {% endfor %}
+</ul>
+{% endspaceless %}
+{% endif %}
+{% endblock %}
+
+{% comment %}
+{% block blog_post_detail_rating %}
+<div class="panel panel-default rating">
+    <div class="panel-body">
+    {% rating_for blog_post %}
+    </div>
+</div>
+{% endblock %}
+{% endcomment %}
+
+{% block event_detail_sharebuttons %}
+  {% with blog_post as object %}
+    {% include "includes/share_buttons.html" %}
+  {% endwith %}
+{% endblock %}
+
+{% block blog_post_previous_next %}
+<ul class="pager">
+{% with blog_post.get_previous_by_publish_date as previous %}
+{% if previous %}
+<li class="previous">
+    <a href="{{ previous.get_absolute_url }}">&larr; {{ previous }}</a>
+</li>
+{% endif %}
+{% endwith %}
+{% with blog_post.get_next_by_publish_date as next %}
+{% if next %}
+<li class="next">
+    <a href="{{ next.get_absolute_url }}">{{ next }} &rarr;</a>
+</li>
+{% endif %}
+{% endwith %}
+</ul>
+{% endblock %}
+
+
+{% block blog_post_detail_related_posts %}
+{% if related_posts or blog_post.events.all %}
+<div id="related-posts">
+<h3>{% trans "Also discover" %}</h3>
+ <div class="msry__container">
+    <div class="msry__sizer"></div>
+    {% for post in related_posts %}
+        {% include 'blog/includes/post_card.html' %}
+    {% endfor %}
+    {% for event in blog_post.events.all|no_parents %}
+        {% for artist in event.artists.all %}
+            {% include "festival/inc/artist_card.html" %}
+        {% endfor %}
+        {% for video in event.videos.all %}
+            {% include 'festival/inc/video_card.html' %}
+        {% endfor %}
+        {% for post in event.blog_posts.all %}
+          {% if post != blog_post %}
+            {% include 'blog/includes/post_card.html' %}
+          {% endif %}
+        {% endfor %}
+    {% endfor %}
+ </div>
+</div>
+{% endif %}
+{% endblock %}
+
+{% block blog_post_detail_comments %}
+{% if blog_post.allow_comments %}{% comments_for blog_post %}{% endif %}
+{% endblock %}
+
+{% endblock %}
index 10df47ebb3ec53d94f45ff8a0e9142fe20c09db3..d7b3673739fb62aaed5326e4bbfd94f3d2f024a3 100644 (file)
@@ -28,6 +28,7 @@ if settings.USE_MODELTRANSLATION:
 
 urlpatterns += [
     url(r'^festival/', include('organization.festival.urls')),
+    url(r'^magazine/', include('organization.magazine.urls')),
     url("^%s/" % settings.EVENT_SLUG, include("mezzanine_agenda.urls")),
 
     # We don't want to presume how your homepage works, so here are a