from dal_select2_queryset_sequence.views import Select2QuerySetSequenceView
from django.core.exceptions import FieldDoesNotExist
+# temporarily excluse not ready models
+EXCLUDED_MODELS = ("organizationplaylist", "personplaylist")
class PlaylistDetailView(SlugMixin, DetailView):
context = super(PlaylistDetailView, self).get_context_data(**kwargs)
self.related_objects = []
self.concrete_objects = []
-
related_model = PlaylistRelated._meta.get_fields()
related_playlist = self.object.playlist_related.all()
+
# get dynamically related objects like articleplaylist, projectplaylist, eventplaylist etc....
for rm in related_model:
- for rp in related_playlist:
- if hasattr(rp, rm.name):
- self.related_objects.append(getattr(rp, rm.name))
+ if rm.name not in EXCLUDED_MODELS :
+ for rp in related_playlist:
+ if hasattr(rp, rm.name):
+ self.related_objects.append(getattr(rp, rm.name))
# get dynamically related instance of related objects. Example: articleplaylist => article
for ro in self.related_objects:
if not isinstance(ro, int) and ro != self.object:
for c_field in ro._meta.get_fields():
- attr = getattr(ro, c_field.name)
- if not isinstance(attr, int) and attr != self.object and not isinstance(attr, PlaylistRelated):
- self.concrete_objects.append(attr)
+ if hasattr(ro, c_field.nam):
+ attr = getattr(ro, c_field.name)
+ if not isinstance(attr, int) and attr != self.object and not isinstance(attr, PlaylistRelated):
+ self.concrete_objects.append(attr)
context['concrete_objects'] = self.concrete_objects
return context
{% load i18n pages_tags mezzanine_tags media_tags organization_tags %}
{% block metatitle %}
- {{ event.title }}
+ {{ object.title }}
{% endblock %}
{% block title %}
- {{ event.title }}
+ {{ object.title }}
{% endblock %}
{% block url %}
- {{ event.get_absolute_url }}
+ {{ object.get_absolute_url }}
{% endblock %}
{% block image %}
- {% with event.images.all|get_type:'card' as images %}
+ {% with object.images.all|get_type:'card' as images %}
{% if images %}
<figure class="article-box__image">
<img src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-original="{{ MEDIA_URL }}{% thumbnail images.0.file 427 286 top=0.5 left=article.photo_alignment|get_photo_alignment %}" class="lazyload" />
</figure>
{% else %}
<figure class="article-box__image">
- {% if event.departments.first %}
- {% with event.departments.first as department %}
+ {% if object.departments.first %}
+ {% with object.departments.first as department %}
<div class="article-box__placeholder {{department.department.name|slugify}}"></div>
{% endwith %}
{% else %}
{% block tags %}
<div class="article-box__tags">
- {% if event.departments.first %}
- {% with event.departments.first as department %}
+ {% if object.departments.first %}
+ {% with object.departments.first as department %}
<div class="tag tag--small dashed dashed--small">
{{ department.department.name }}
</div>
{% endwith %}
{% endif %}
- {% if event.category %}
+ {% if object.category %}
<div class="tag tag--small tag--category">
- {{ event.category|truncatechars:15 }}
+ {{ object.category|truncatechars:15 }}
</div>
{% endif %}
</div>
{% endblock %}
{% block content %}
- {{ event.description|richtext_filters|safe|truncatechars_html:200 }}
+ {{ object.description|richtext_filters|safe|truncatechars_html:200 }}
{% endblock %}
{% block subtitle %}
<strong>
- {% include 'agenda/includes/event_date_line.html' %}
+ {% include 'agenda/includes/event_date_line.html' with object=event %}
</strong>
- {% if event.location %}
- <br />{{ event.location }}
+ {% if object.location %}
+ <br />{{ object.location }}
{% endif %}
{% endblock %}
{% block btn %}
- {% if event.prices.all.0|floatformat != '0' and event.prices.all|length > 0 %}
- {% for price in event.prices.all %}
+ {% if object.prices.all.0|floatformat != '0' and object.prices.all|length > 0 %}
+ {% for price in object.prices.all %}
{% if forloop.first %}
<div class="article-box__btn">
<object><a href="{% url 'event_booking' content.content_object.slug %}" class="button button--small mr0">{% trans "Reserve" %}</a></object>
{% load i18n %}
{% load event_tags %}
-{% if event.start and not event.end %}
- {{ event.start|date:"l j F" }}
+{% if object.start and not object.end %}
+ {{ object.start|date:"l j F" }}
{% else %}
- {% if event.start|date:"d.m.y" == event.end|date:"d.m.y" %}
- {{ event.start|date:"l j F" }}
+ {% if object.start|date:"d.m.y" == object.end|date:"d.m.y" %}
+ {{ object.start|date:"l j F" }}
{% else %}
- {{ event.start|date:"j F" }} {% trans "to" %} {{ event.end|date:"j F" }}
+ {{ object.start|date:"j F" }} {% trans "to" %} {{ object.end|date:"j F" }}
{% endif %}
{% endif %}
<div class="page__meta-date">
<a href="{{ event.get_absolute_url }}">
- {% include 'agenda/includes/event_date_line.html' %}
+ {% include 'agenda/includes/event_date_line.html' with object=event %}
</a>
</div>
{% block subtitle %}
<div class="search-box__subtitle">
- {% include 'agenda/includes/event_date_line.html' %}
+ {% include 'agenda/includes/event_date_line.html' with object=event %}
{% if event.prices.all.0|floatformat != '0' and event.prices.all|length > 0 and not is_archive %}
<a class="button button--small ml1" href="{% url 'event_booking' event.slug %}" class="event__meta__btn">
{% trans "Reserve" %}
{% for content in dynamic_content %}
<div class="col-lg-3 col-md-4 col-sm-4 col-xs-6">
{% if content.content_type.model == "article" %}
- {% with content.content_object as article %}
- {% include "magazine/article/includes/article_card.html" %}
- {% endwith %}
+ {% include "magazine/article/includes/article_card.html" with object=content.content_object %}
{% elif content.content_type.model == "event" %}
- {% with content.content_object as event %}
- {% include "agenda/event/includes/event_card.html" %}
- {% endwith %}
+ {% include "agenda/event/includes/event_card.html" with object=content.content_object %}
{% elif content.content_type.model == "custompage" %}
- {% with content.content_object as page %}
- {% include "pages/page/sincludes/page_card.html" %}
- {% endwith %}
+ {% include "pages/page/includes/page_card.html" with object=content.content_object %}
{% endif %}
</div>
{% endfor %}
<div class="row tac">
{% for concrete_object in concrete_objects %}
<div class="col-lg-3 col-md-4 col-sm-4 col-xs-6">
- {{ concrete_object|app_label_short }}
- {% with app_label=concrete_object|app_label_short classname=concrete_object|classname|lower %}
+ {% with app_label=concrete_object|app_label_short classname=concrete_object|classname|lower object=concrete_object %}
{% with app_label|add:"/"|add:classname|add:"/includes/"|add:classname|add:"_card.html" as template %}
- {% include template with classname=concrete_object %}
+ {% include template %}
{% endwith %}
{% endwith %}
</div>
<div class="msry__container">
<div class="msry__sizer"></div>
{% for event in artist.events.all|no_parents %}
- {% include 'agenda/event/includes/event_card.html' %}
+ {% include 'agenda/event/includes/event_card.html' with object=event %}
{% endfor %}
{% for video in artist.videos.all %}
{% include 'festival/inc/video_card.html' %}
<div class="msry__container">
<div class="msry__sizer"></div>
{% with video.event as event %}
- {% include 'agenda/event/includes/event_card.html' %}
- {% for artist in video.artists.all %}
- {% include "festival/inc/artist_card.html" %}
- {% endfor %}
- {% for v in event.videos.all %}
- {% if v != video %}
- {% with v as video %}
- {% include 'festival/inc/video_card.html' %}
- {% endwith %}
- {% endif %}
- {% endfor %}
- {% for post in event.blog_posts.all %}
- {% include 'blog/includes/post_card.html' %}
- {% endfor %}
+ {% include 'agenda/event/includes/event_card.html' with object=event %}
+ {% for artist in video.artists.all %}
+ {% include "festival/inc/artist_card.html" %}
+ {% endfor %}
+ {% for v in event.videos.all %}
+ {% if v != video %}
+ {% with v as video %}
+ {% include 'festival/inc/video_card.html' %}
+ {% endwith %}
+ {% endif %}
+ {% endfor %}
+ {% for post in event.blog_posts.all %}
+ {% include 'blog/includes/post_card.html' %}
+ {% endfor %}
{% endwith %}
</div>
{% if slider.content_type.model == "brief" %}
{% include "magazine/brief/inc/brief_card.html" %}
{% elif slider.content_type.model == "article" %}
- {% with slider.content_object as article %}
- {% include "magazine/article/includes/article_card.html" %}
- {% endwith %}
+ {% include "magazine/article/includes/article_card.html" with object=slider.content_object %}
{% elif slider.content_type.model == "event" %}
- {% with slider.content_object as event %}
- {% include "agenda/event/includes/event_card.html" %}
- {% endwith %}
+ {% include "agenda/event/includes/event_card.html" with object=slider.content_object %}
{% elif slider.content_type.model == "custompage" %}
- {% with slider.content_object as page %}
- {% include "pages/page/includes/page_card.html" %}
- {% endwith %}
+ {% include "pages/page/includes/page_card.html" with object=slider.content_object %}
{% endif %}
</div>
{% endif %}
{% if content.content_type.model == "brief" %}
{% include "magazine/brief/inc/brief_card.html" %}
{% elif content.content_type.model == "article" %}
- {% with content.content_object as article %}
- {% include "magazine/article/includes/article_card.html" %}
- {% endwith %}
+ {% include "magazine/article/includes/article_card.html" with object=content.content_object %}
{% elif content.content_type.model == "event" %}
- {% with content.content_object as event %}
- {% include "agenda/event/includes/event_card.html" %}
- {% endwith %}
+ {% include "agenda/event/includes/event_card.html" with object=content.content_object %}
{% elif content.content_type.model == "custompage" %}
- {% with content.content_object as page %}
- {% include "pages/page/includes/page_card.html" %}
- {% endwith %}
+ {% include "pages/page/includes/page_card.html" with object=content.content_object %}
{% endif %}
</div>
{% endfor %}
{% load i18n pages_tags mezzanine_tags media_tags organization_tags %}
{% block metatitle %}
- {{ article.title }}
+ {{ object.title }}
{% endblock %}
{% block title %}
- {{ article.title }}
+ {{ object.title }}
{% endblock %}
{% block url %}
- {% if article.content|removetags:"p"|slice:':4' == 'http' %}
- {{ article.content|removetags:"p" }}
+ {% if object.content|removetags:"p"|slice:':4' == 'http' %}
+ {{ object.content|removetags:"p" }}
{% else %}
- {% url 'magazine-article-detail' article.slug %}
+ {% url 'magazine-article-detail' object.slug %}
{% endif %}
{% endblock %}
{% block target %}
- {% if article.content|removetags:"p"|slice:':4' == 'http' %}target="_blank"{% endif %}
+ {% if object.content|removetags:"p"|slice:':4' == 'http' %}target="_blank"{% endif %}
{% endblock %}
{% block image %}
- {% with article.images.all|get_type:'card' as images %}
+ {% with object.images.all|get_type:'card' as images %}
{% if images %}
<figure class="article-box__image">
- <img src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-original="{{ MEDIA_URL }}{% thumbnail images.0.file 427 286 top=0.5 left=article.photo_alignment|get_photo_alignment %}" class="lazyload" />
+ <img src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-original="{{ MEDIA_URL }}{% thumbnail images.0.file 427 286 top=0.5 left=object.photo_alignment|get_photo_alignment %}" class="lazyload" />
</figure>
{% else %}
<figure class="article-box__image">
- {% if article.department %}
- <div class="article-box__placeholder {{article.department.name|slugify}}"></div>
+ {% if object.department %}
+ <div class="article-box__placeholder {{object.department.name|slugify}}"></div>
{% else %}
<div class="article-box__placeholder"></div>
{% endif %}
<div class="tag tag--small tag--category">
{% trans 'News' %}
</div>
- {% if article.department %}
+ {% if object.department %}
<div class="tag tag--small dashed dashed--gray dashed--small">
- {{ article.department.name }}
+ {{ object.department.name }}
</div>
{% endif %}
</div>
{% endblock %}
{% block content %}
- {{ article.description|richtext_filters|safe|truncatechars_html:200 }}
+ {{ object.description|richtext_filters|safe|truncatechars_html:200 }}
{% endblock %}
{% block subtitle %}
- {{ article.publish_date|date:"DATE_FORMAT" }}
- {% for category in article.categories.all %}
+ {{ object.publish_date|date:"DATE_FORMAT" }}
+ {% for category in object.categories.all %}
{% if forloop.first %} | {% endif %}
{% if not forloop.first %}, {% endif %}
<strong>{{ category }}</strong>
<div class="row">
{% for article in articles %}
<div class="col-lg-3 col-md-4 col-sm-4 col-xs-6">
- {% include 'magazine/article/includes/article_card.html' %}
+ {% include 'magazine/article/includes/article_card.html' with object=article %}
</div>
{% endfor %}
</div>
{% load i18n pages_tags mezzanine_tags media_tags organization_tags %}
{% block metatitle %}
- {{ page.title }}
+ {{ object.title }}
{% endblock %}
{% block title %}
- {{ page.title }}
+ {{ object.title }}
{% endblock %}
{% block url %}
- {{ page.get_absolute_url }}
+ {{ object.get_absolute_url }}
{% endblock %}
{% block image %}
- {% with page.images.all|get_type:'card' as images %}
+ {% with object.images.all|get_type:'card' as images %}
{% if images %}
<figure class="article-box__image">
<img src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-original="{{ MEDIA_URL }}{% thumbnail images.0.file 427 286 top=0.5 left=article.photo_alignment|get_photo_alignment %}" class="lazyload" />
{% endblock %}
{% block content %}
- {{ page.description|richtext_filters|safe|truncatechars_html:200 }}
+ {{ object.description|richtext_filters|safe|truncatechars_html:200 }}
{% endblock %}
{% block subtitle %}
- {{ page.sub_title }}
+ {{ object.sub_title }}
{% endblock %}
<div class="msry__container">
<div class="msry__sizer"></div>
{% for event in page.featured.all.0.events.all %}
- {% include 'agenda/event/includes/event_card.html' %}
+ {% include 'agenda/event/includes/event_card.html' with object=event %}
{% endfor %}
</div>
{% endif %}
--- /dev/null
+{% extends "core/inc/generic_card.html" %}
+{% load i18n pages_tags mezzanine_tags media_tags organization_tags %}
+
+{% block metatitle %}
+ {{ object.title }}
+{% endblock %}
+
+{% block title %}
+ {{ object.title }}
+{% endblock %}
+
+{% block url %}
+ {{ object.get_absolute_url }}
+{% endblock %}
+{% block image %}
+ {% with object.images.all|get_type:'card' as images %}
+ {% if images %}
+ <figure class="article-box__image">
+ <img src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-original="{{ MEDIA_URL }}{% thumbnail images.0.file 427 286 top=0.5 left=article.photo_alignment|get_photo_alignment %}" class="lazyload" />
+ </figure>
+ {% endif %}
+ {% endwith %}
+{% endblock %}
+
+{% block content %}
+ {{ object.description|richtext_filters|safe|truncatechars_html:200 }}
+{% endblock %}
+
+{% block subtitle %}
+ {{ object.sub_title }}
+{% endblock %}