forked from rc/aircox
add sound item in diffusions; move programs.Sound's attribute 'remove' into the type + update its public attribute based on diffusion publication
This commit is contained in:
@ -418,6 +418,11 @@ class DiffusionPage(Publication):
|
||||
'initial__isnull': True,
|
||||
},
|
||||
)
|
||||
publish_archive = models.BooleanField(
|
||||
_('publish archive'),
|
||||
default = False,
|
||||
help_text = _('publish the podcast of the complete diffusion'),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _('Diffusion')
|
||||
@ -425,11 +430,11 @@ class DiffusionPage(Publication):
|
||||
|
||||
content_panels = [
|
||||
FieldPanel('diffusion'),
|
||||
FieldPanel('publish_archive'),
|
||||
] + Publication.content_panels + [
|
||||
InlinePanel('tracks', label=_('Tracks')),
|
||||
]
|
||||
|
||||
|
||||
@classmethod
|
||||
def from_diffusion(cl, diff, model = None, **kwargs):
|
||||
model = model or cl
|
||||
@ -470,9 +475,50 @@ class DiffusionPage(Publication):
|
||||
item.css_class = 'diffusion'
|
||||
return item
|
||||
|
||||
def get_archive(self):
|
||||
if not self.publish_archive:
|
||||
return
|
||||
|
||||
sound = self.diffusion.get_archives() \
|
||||
.filter(public = True).first()
|
||||
if sound:
|
||||
sound.detail_url = self.detail_url
|
||||
return sound
|
||||
|
||||
def get_podcasts(self):
|
||||
"""
|
||||
Return a list of podcasts, with archive as the first item of the
|
||||
list when available.
|
||||
"""
|
||||
podcasts = []
|
||||
archive = self.get_archive()
|
||||
if archive:
|
||||
podcasts.append(archive)
|
||||
|
||||
qs = self.diffusion.get_excerpts().filter(public = True)
|
||||
podcasts.extend(qs[:])
|
||||
for podcast in podcasts:
|
||||
podcast.detail_url = self.url
|
||||
return podcasts
|
||||
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
# TODO: update public attribute of the archive + podcasts check if live
|
||||
if self.diffusion:
|
||||
self.date = self.diffusion.start
|
||||
|
||||
# update podcasts' attributes
|
||||
for podcast in self.diffusion.sound_set \
|
||||
.exclude(type = programs.Sound.Type.removed):
|
||||
publish = self.live and self.publish_archive \
|
||||
if podcast.type == podcast.Type.archive else self.live
|
||||
|
||||
if podcast.public != publish:
|
||||
podcast.public = publish
|
||||
podcast.save()
|
||||
|
||||
|
||||
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
|
||||
|
@ -51,8 +51,8 @@ PlayerPlaylist.prototype = {
|
||||
items: undefined,
|
||||
|
||||
find: function(stream) {
|
||||
return this.items.find(function(v) {
|
||||
return v.stream == item;
|
||||
return this.items.find(function(stream_) {
|
||||
return stream_ == stream;
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -30,6 +30,17 @@
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
{% with podcasts=self.get_podcasts %}
|
||||
{% if podcasts %}
|
||||
<div class="podcasts list">
|
||||
<h2>{% trans "Podcasts" %}</h2>
|
||||
{% for item in podcasts %}
|
||||
{% include 'cms/snippets/sound_list_item.html' %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
|
||||
{# TODO: podcasts #}
|
||||
{% endblock %}
|
||||
|
||||
|
13
cms/templates/cms/snippets/sound_list_item.html
Normal file
13
cms/templates/cms/snippets/sound_list_item.html
Normal file
@ -0,0 +1,13 @@
|
||||
{% load static %}
|
||||
|
||||
{# TODO: complete archive podcast -> info #}
|
||||
<a class="list_item sound" onclick="player.playlist.add(new Sound(
|
||||
title='{{ item.name|escape }}',
|
||||
detail='{{ item.detail_url }}',
|
||||
stream='{% static item.path %}'));">
|
||||
<h3>{{ item.name }}</h3>
|
||||
<span class="info">
|
||||
{{ duration.date|date:'H:i:s' }}
|
||||
</span>
|
||||
</a>
|
||||
|
@ -66,7 +66,7 @@ class DiffusionsMenu(GenericMenu):
|
||||
def register_programs_menu_item():
|
||||
return SubmenuMenuItem(
|
||||
_('Today\'s Diffusions'), DiffusionsMenu(),
|
||||
classnames='icon icon-folder-open-inverse', order=10
|
||||
classnames='icon icon-folder-open-inverse', order=101
|
||||
)
|
||||
|
||||
|
||||
@ -97,7 +97,7 @@ class ProgramsMenu(GenericMenu):
|
||||
def register_programs_menu_item():
|
||||
return SubmenuMenuItem(
|
||||
_('Programs'), ProgramsMenu(),
|
||||
classnames='icon icon-folder-open-inverse', order=10
|
||||
classnames='icon icon-folder-open-inverse', order=102
|
||||
)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user