model = MediaTranscoded
+class MediaImageInline(TabularDynamicInlineAdmin):
+
+ model = MediaImage
+
+
class MediaAdmin(BaseTranslationModelAdmin):
model = Media
- inlines = (MediaTranscodedAdmin,)
+ inlines = (MediaTranscodedAdmin, MediaImageInline)
list_display = ['title',]
--- /dev/null
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9.11 on 2017-02-15 10:55
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django.db.models.deletion
+import mezzanine.core.fields
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('organization-media', '0012_auto_20161028_1812'),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='MediaImage',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('_order', mezzanine.core.fields.OrderField(null=True, verbose_name='Order')),
+ ('title', models.CharField(max_length=1024, verbose_name='title')),
+ ('description', models.TextField(blank=True, verbose_name='description')),
+ ('file', mezzanine.core.fields.FileField(max_length=1024, verbose_name='Image')),
+ ('credits', models.CharField(blank=True, max_length=256, null=True, verbose_name='credits')),
+ ('type', models.CharField(choices=[('logo', 'logo'), ('logo_white', 'logo white'), ('logo_black', 'logo black'), ('logo_header', 'logo header'), ('logo_footer', 'logo footer'), ('slider', 'slider'), ('card', 'card'), ('page_slider', 'page - slider'), ('page_featured', 'page - featured')], max_length=64, verbose_name='type')),
+ ('media', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='images', to='organization-media.Media', verbose_name='media')),
+ ],
+ options={
+ 'verbose_name_plural': 'images',
+ 'verbose_name': 'image',
+ 'ordering': ('_order',),
+ },
+ ),
+ ]
return self.url
+class MediaImage(Image):
+
+ media = models.ForeignKey(Media, verbose_name=_('media'), related_name='images', blank=True, null=True, on_delete=models.SET_NULL)
+
+ class Meta:
+ verbose_name = _("image")
+ verbose_name_plural = _("images")
+ order_with_respect_to = "media"
+
+
class MediaCategory(Slugged, Description):
"""Media Category"""
class MediaCategoryTranslationOptions(TranslationOptions):
fields = ('title', 'description',)
+
+
+@register(MediaImage)
+class MediaImageTranslationOptions(TranslationOptions):
+
+ fields = ()
from organization.pages.models import CustomPage
from organization.pages.models import *
from organization.agenda.models import Event
-from organization.media.models import Playlist
+from organization.media.models import Playlist, Media
from organization.network.models import Person
Article.objects.all(),
CustomPage.objects.all(),
Event.objects.all(),
- Person.objects.published()
+ Person.objects.published(),
+ Media.objects.all()
),
required=False,
widget=dal_select2_queryset_sequence.widgets.QuerySetSequenceSelect2('dynamic-content-home-slider'),
Article.objects.all(),
CustomPage.objects.all(),
Brief.objects.all(),
- Event.objects.all()
+ Event.objects.all(),
+ Media.objects.all()
),
required=False,
widget=dal_select2_queryset_sequence.widgets.QuerySetSequenceSelect2('dynamic-content-home-body'),
from organization.magazine.models import Article, Topic, Brief
from organization.pages.models import Home
from organization.agenda.models import Event
-from organization.media.models import Playlist
+from organization.media.models import Playlist, Media
from organization.network.models import Person
custompage = CustomPage.objects.all()
events = Event.objects.all()
persons = Person.objects.published()
-
+ medias = Media.objects.all()
if self.q:
articles = articles.filter(title__icontains=self.q)
custompage = custompage.filter(title__icontains=self.q)
events = events.filter(title__icontains=self.q)
persons = persons.filter(title__icontains=self.q)
+ medias = medias.filter(title__icontains=self.q)
- qs = autocomplete.QuerySetSequence(articles, custompage, events, persons)
+ qs = autocomplete.QuerySetSequence(articles, custompage, events, persons, medias)
if self.q:
# This would apply the filter on all the querysets
custompage = CustomPage.objects.all()
events = Event.objects.all()
briefs = Brief.objects.all()
+ medias = Media.objects.all()
if self.q:
articles = articles.filter(title__icontains=self.q)
custompage = custompage.filter(title__icontains=self.q)
events = events.filter(title__icontains=self.q)
briefs = briefs.filter(title__icontains=self.q)
+ medias = medias.filter(title__icontains=self.q)
- qs = autocomplete.QuerySetSequence(articles, custompage, briefs, events)
+ qs = autocomplete.QuerySetSequence(articles, custompage, briefs, events, medias)
if self.q:
# This would apply the filter on all the querysets
{% include "agenda/event/includes/event_card.html" with object=slider.content_object %}
{% elif slider.content_type.model == "custompage" %}
{% include "pages/page/includes/page_card.html" with object=slider.content_object %}
+ {% elif slider.content_type.model == "media" %}
+ {% include "media/media/includes/media_card.html" with object=slider.content_object %}
{% endif %}
</div>
{% endif %}
{% include "agenda/event/includes/event_card.html" with object=content.content_object %}
{% elif content.content_type.model == "custompage" %}
{% include "pages/page/includes/page_card.html" with object=content.content_object %}
+ {% elif content.content_type.model == "media" %}
+ {% include "media/media/includes/media_card.html" with object=content.content_object %}
{% endif %}
</div>
{% endfor %}
-{% load mezzanine_tags keyword_tags i18n organization_tags staticfiles %}
-
+{% load i18n future mezzanine_tags event_tags keyword_tags disqus_tags organization_tags %}
<div class="">
<div class="media-box media-box--{{object|get_media_type|lower}}">
<a class="media-box__image-container" href="{% url 'organization-media-overlay' object.type object.slug %}" data-video-overlay>
<figure class="media-box__image media-box__image--video">
- {% if object.poster_url %}
- <img src="{{ object.poster_url }}">
- {% else %}
- <div class="media-box__placeholder"></div>
- {% endif %}
+ {% with object.images.all|get_type:'card' as images %}
+ {% if object.poster_url %}
+ <img src="{{ object.poster_url }}">
+ {% elif images %}
+ <img class="lazyload" src="{{ MEDIA_URL }}{% thumbnail images.0.file 720 435 %}" data-original="">
+ {% else %}
+ <div class="media-box__placeholder"></div>
+ {% endif %}
+ {% endwith %}
</figure>
</a>
<a class="media-box__content" href="{% url 'organization-media-detail' object|get_media_type|lower object.slug %}">