From 745891233de254a9224c1c5ffde8e95ddda9c9cd Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Tue, 17 May 2016 14:58:01 +0200 Subject: [PATCH] add video and audio to artists relations --- .../migrations/0022_auto_20160517_1457.py | 25 +++++++++++++++++++ app/festival/models.py | 2 ++ .../templates/festival/artist_detail.html | 7 +++--- 3 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 app/festival/migrations/0022_auto_20160517_1457.py diff --git a/app/festival/migrations/0022_auto_20160517_1457.py b/app/festival/migrations/0022_auto_20160517_1457.py new file mode 100644 index 00000000..2dceb3cb --- /dev/null +++ b/app/festival/migrations/0022_auto_20160517_1457.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.2 on 2016-05-17 12:57 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('festival', '0021_delete_pagecategory'), + ] + + operations = [ + migrations.AddField( + model_name='audio', + name='artists', + field=models.ManyToManyField(blank=True, related_name='audios', to='festival.Artist', verbose_name='artists'), + ), + migrations.AddField( + model_name='video', + name='artists', + field=models.ManyToManyField(blank=True, related_name='videos', to='festival.Artist', verbose_name='artists'), + ), + ] diff --git a/app/festival/models.py b/app/festival/models.py index 0eb414fe..f937090b 100644 --- a/app/festival/models.py +++ b/app/festival/models.py @@ -153,6 +153,7 @@ class Audio(Media): closed_source_mime_type = 'audio/mp4' event = models.ForeignKey(Event, related_name='audios', verbose_name=_('event'), blank=True, null=True, on_delete=models.SET_NULL) + artists = models.ManyToManyField(Artist, verbose_name=_('artists'), related_name='audios', blank=True) class Meta(MetaCore): verbose_name = _('audio') @@ -170,6 +171,7 @@ class Video(Media): event = models.ForeignKey(Event, related_name='videos', verbose_name=_('event'), blank=True, null=True, on_delete=models.SET_NULL) category = models.ForeignKey('VideoCategory', related_name='videos', verbose_name=_('category'), blank=True, null=True, on_delete=models.SET_NULL) + artists = models.ManyToManyField(Artist, verbose_name=_('artists'), related_name='videos', blank=True) class Meta(MetaCore): verbose_name = _('video') diff --git a/app/festival/templates/festival/artist_detail.html b/app/festival/templates/festival/artist_detail.html index 3e4fe4ef..60e924ad 100644 --- a/app/festival/templates/festival/artist_detail.html +++ b/app/festival/templates/festival/artist_detail.html @@ -29,9 +29,10 @@
{% for event in artist.events.all %} {% include 'agenda/includes/event_card.html' %} - {% for video in event.videos.all %} - {% include 'festival/inc/video_card.html' %} - {% endfor %} + {% endfor %} + {% for video in artist.videos.all %} + {% include 'festival/inc/video_card.html' %} + {% endfor %} {% endfor %} {% with artist.events.all|unique_posts as posts %} {% for post in posts %} -- 2.39.5