+from urllib.parse import urlparse
from django.shortcuts import render
from django.utils import timezone
#from django.views.generic import *
from django.views.generic.base import *
from django.shortcuts import get_object_or_404
-from organization.magazine.models import Article, Topic ,Brief
+from organization.magazine.models import Article, Topic, Brief
+from organization.team.models import Department
+
from organization.core.views import SlugMixin
from django.template.defaultfilters import slugify
template_name='magazine/article/article_detail.html'
context_object_name = 'article'
+ def get(self, request, *args, **kwargs):
+ previous_page_url = request.META['HTTP_REFERER']
+ previous_page_slug = request.META['HTTP_REFERER'].rsplit("/")[-2]
+ if previous_page_slug:
+ #find parents page
+ parsed_url = urlparse(previous_page_url)
+ self.department_parent = Department.objects.filter(slug=parsed_url.path[1:][:-1])
+ self.topic_parent = Topic.objects.filter(slug=previous_page_slug)
+ return super(ArticleDetailView, self).get(request, *args, **kwargs)
+
def get_context_data(self, **kwargs):
context = super(ArticleDetailView, self).get_context_data(**kwargs)
+ if self.topic_parent:
+ context['topic_parent'] = self.topic_parent.all()[0]
+ if self.department_parent:
+ context['department_parent'] = self.department_parent.all()[0]
return context
from organization.media.models import Photo
from organization.core.models import *
+from organization.magazine.models import Article
from django_countries.fields import CountryField
# from .nationalities.fields import NationalityField
organization = models.ForeignKey('Organization', verbose_name=_('organization'))
url = models.URLField(_('URL'), max_length=512, blank=True)
weaving_css_class = models.CharField(_('weaving CSS class'), max_length=64, blank=True)
+ articles_related = models.ManyToManyField(Article, verbose_name=_('Related articles'), blank=True)
class Meta:
verbose_name = _('department')
{% block breadcrumb_menu %}
{{ block.super }}
- <li class="active">{{ article.title }}</li>
+ {% if topic_parent %}
+ <li class="breadcrumb__item"><a href="{% url "topic-detail" parent_topic.slug %}" class="breadcrumb__link" title="{{ parent_topic.title }}">{{ parent_topic.title }}</a></li>
+ {% endif %}
+ {% if department_parent %}
+ <li class="breadcrumb__item"><a href="{% url "page" department_parent.slug %}" class="breadcrumb__link" title="{{ department_parent.title }}">{{ department_parent.title }}</a></li>
+ {% endif %}
+
+ <li class="breadcrumb__item active">{{ article.title }}</li>
{% endblock %}
{% block page_title %}
{% endblock %}
{% block page_content %}
-
{% if page.department.sub_title %}
{% editable page.department.sub_title %}
<div class="chapo">
{% endif %}
{% endif %}
+ {% if page.department.articles_related.all %}
+ <h2 class="dashed dashed--center">{% trans "Also discover" %}</h2>
+ {% for article in page.department.articles_related.all %}
+ {% include 'magazine/article/includes/article_card.html' %}
+ {% endfor %}
+ {% endif %}
+
+
{% if page.department.pageblock_set.all %}
<div class="white-bg">
<div class="container">