Commit 7182bf01 authored by fred's avatar fred

add direct track reference into logline record

parent 17f771e0
# -*- coding: utf-8 -*-
# Generated by Django 1.11.29 on 2020-07-02 09:58
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('nonstop', '0025_recurringrandomdirectorydiffusion_recurringrandomdirectoryoccurence'),
]
operations = [
migrations.AddField(
model_name='somalogline',
name='track',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='nonstop.Track'),
),
]
......@@ -158,9 +158,17 @@ class SomaLogLine(models.Model):
ordering = ['play_timestamp']
filepath = models.ForeignKey(NonstopFile)
track = models.ForeignKey(Track, null=True)
play_timestamp = models.DateTimeField()
on_air = models.NullBooleanField('On Air')
def get_track(self):
if self.track_id:
return self.track
if self.filepath_id:
return self.filepath.track
return None
class Jingle(models.Model):
class Meta:
......
......@@ -17,9 +17,9 @@
<ul class="soma-list">
{% for somalog in object.recent_diffusions|slice:":20" %}
<li><span class="timestamp">{{ somalog.play_timestamp|date:"d/m/Y H:i" }}</span>:
{% if somalog.filepath.track %}
<a href="{{ somalog.filepath.track.get_absolute_url }}" class="tracktitle">{{ somalog.filepath.track.title }}</a>
<span class="trackartist">(<a href="{{ somalog.filepath.track.artist.get_absolute_url }}" class="trackartist">{{ somalog.filepath.track.artist.name }}</a>)</span>
{% if somalog.get_track %}
<a href="{{ somalog.get_track.get_absolute_url }}" class="tracktitle">{{ somalog.get_track.title }}</a>
<span class="trackartist">(<a href="{{ somalog.get_track.artist.get_absolute_url }}" class="trackartist">{{ somalog.get_track.artist.name }}</a>)</span>
{% endif %}
<span class="filepath">{{ somalog.filepath.short }}</span>
</li>
......
......@@ -17,9 +17,9 @@
<ul class="soma-list">
{% for somalog in object_list %}
<li class="on-air-{{ somalog.on_air }}"><span class="timestamp">{{ somalog.play_timestamp|date:"H:i" }}</span>:
{% if somalog.filepath.track %}
<a href="{{ somalog.filepath.track.get_absolute_url }}" class="tracktitle">{{ somalog.filepath.track.title }}</a>
<span class="trackartist">(<a href="{{ somalog.filepath.track.artist.get_absolute_url }}" class="trackartist">{{ somalog.filepath.track.artist.name }}</a>)</span>
{% if somalog.get_track %}
<a href="{{ somalog.get_track.get_absolute_url }}" class="tracktitle">{{ somalog.get_track.title }}</a>
<span class="trackartist">(<a href="{{ somalog.get_track.artist.get_absolute_url }}" class="trackartist">{{ somalog.get_track.artist.name }}</a>)</span>
{% endif %}
<span class="filepath">{{ somalog.filepath.short }}</span>
</li>
......
......@@ -19,9 +19,9 @@
<ul class="soma-list">
{% for somalog in object.recent_diffusions|slice:":20" %}
<li><span class="timestamp">{{ somalog.play_timestamp|date:"d/m/Y H:i" }}</span>:
{% if somalog.filepath.track %}
<a href="{{ somalog.filepath.track.get_absolute_url }}" class="tracktitle">{{ somalog.filepath.track.title }}</a>
<span class="trackartist">(<a href="{{ somalog.filepath.track.artist.get_absolute_url }}" class="trackartist">{{ somalog.filepath.track.artist.name }}</a>)</span>
{% if somalog.get_track %}
<a href="{{ somalog.get_track.get_absolute_url }}" class="tracktitle">{{ somalog.get_track.title }}</a>
<span class="trackartist">(<a href="{{ somalog.get_track.artist.get_absolute_url }}" class="trackartist">{{ somalog.get_track.artist.name }}</a>)</span>
{% endif %}
<span class="filepath">{{ somalog.filepath.short }}</span>
</li>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment