playlists and podcasts on episode view

This commit is contained in:
bkfox 2019-08-07 22:52:34 +02:00
parent bd185125ac
commit aabbcd97fa
10 changed files with 45 additions and 29 deletions

9
.gitignore vendored Normal file
View File

@ -0,0 +1,9 @@
__pycache__/
*.py[cod]
venv/
node_modules/
*.egg-info/
*.egg

View File

@ -19,8 +19,8 @@ class TracksInline(SortableInlineAdminMixin, admin.TabularInline):
class SoundInline(admin.TabularInline): class SoundInline(admin.TabularInline):
model = Sound model = Sound
fields = ['type', 'path', 'duration', 'is_public'] fields = ['type', 'path', 'embed', 'duration', 'is_public']
readonly_fields = ['type'] readonly_fields = ['type', 'path', 'duration']
extra = 0 extra = 0

View File

@ -23,5 +23,3 @@ class Article(Page):
verbose_name = _('Article') verbose_name = _('Article')
verbose_name_plural = _('Articles') verbose_name_plural = _('Articles')

View File

@ -53,14 +53,14 @@ Context:
{% block header %} {% block header %}
<h1 class="title is-1">{% block title %}{% endblock %}</h1> <h1 class="title is-1">{% block title %}{% endblock %}</h1>
<h4 class="subtitle is-size-3 columns"> <h3 class="subtitle is-3 columns">
{% block subtitle %} {% block subtitle %}
{% if parent %} {% if parent %}
<a href="{{ parent.get_absolute_url }}" class="column"> <a href="{{ parent.get_absolute_url }}" class="column">
&#10092; {{ parent.title }}</a></li> &#10092; {{ parent.title }}</a></li>
{% endif %} {% endif %}
{% endblock %} {% endblock %}
</h4> </h3>
{% endblock %} {% endblock %}
</header> </header>

View File

@ -31,11 +31,32 @@
{% block main %} {% block main %}
{{ block.super }} {{ block.super }}
{% if podcasts %} {% if podcasts or tracks %}
{% for object in podcasts %} <section class="columns is-desktop">
{% include "aircox/podcast_item.html" %} {% if tracks %}
{% endfor %} <div class="column">
{% endif %} <h4 class="title is-4">{% trans "Playlist" %}</h4>
<ol>
{% for track in tracks %}
<li><span>{{ track.title }}</span>
<span class="has-text-grey-dark has-text-weight-light">
&mdash; {{ track.artist }}
{% if track.info %}(<i>{{ track.info }}</i>){% endif %}
</span>
</li>
{% endfor %}
</ol>
</div>
{% endif %}
{% if podcasts %}
<div class="column">
<h4 class="title is-4">{% trans "Podcasts" %}</h4>
{% for object in podcasts %}
{% include "aircox/podcast_item.html" %}
{% endfor %}
{% endif %}
</div>
{% endif %}
</section>
{% endblock %} {% endblock %}

View File

@ -3,17 +3,9 @@
{% with object.track as track %} {% with object.track as track %}
<span class="has-text-info is-size-5">&#9836;</span> <span class="has-text-info is-size-5">&#9836;</span>
<span>{{ track.title }}</span> <span>{{ track.title }}</span>
{% with track.artist as artist %}
{% with track.info as info %}
<span class="has-text-grey-dark has-text-weight-light"> <span class="has-text-grey-dark has-text-weight-light">
{% blocktrans %} &mdash; {{ track.artist }}
by {{ artist }} {% if track.info %}(<i>{{ track.info }}</i>){% endif %}
{% endblocktrans %}
{% if info %}
({% blocktrans %}<i>{{ info }}</i>{% endblocktrans %})
{% endif %}
</span> </span>
{% endwith %} {% endwith %}
{% endwith %}
{% endwith %}

View File

@ -22,12 +22,6 @@ Context:
{% block main %} {% block main %}
{% block headline %}
{% if page and page.headline %}
<p class="headline">{{ page.headline }}</p>
{% endif %}
{% endblock %}
{% block content %} {% block content %}
{{ page.content|default_if_none:''|safe }} {{ page.content|default_if_none:''|safe }}
{% endblock %} {% endblock %}

View File

@ -6,7 +6,7 @@
{% if episodes %} {% if episodes %}
<section> <section>
<h4 class="subtitle is-size-4">{% trans "Last shows" %}</h4> <h4 class="title is-4">{% trans "Last shows" %}</h4>
{% for object in episodes %} {% for object in episodes %}
{% include "aircox/episode_item.html" %} {% include "aircox/episode_item.html" %}

View File

@ -23,6 +23,8 @@ class EpisodeDetailView(ProgramPageDetailView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
kwargs.setdefault('program', self.object.program) kwargs.setdefault('program', self.object.program)
kwargs.setdefault('parent', kwargs['program']) kwargs.setdefault('parent', kwargs['program'])
if not 'tracks' in kwargs:
kwargs['tracks'] = self.object.track_set.order_by('position')
if not 'podcasts' in kwargs: if not 'podcasts' in kwargs:
kwargs['podcasts'] = self.object.sound_set.podcasts() kwargs['podcasts'] = self.object.sound_set.podcasts()
return super().get_context_data(**kwargs) return super().get_context_data(**kwargs)