check section playlist

This commit is contained in:
bkfox 2016-06-08 00:48:10 +02:00
parent 83e425349b
commit 13bf57b401
6 changed files with 7 additions and 6 deletions

View File

@ -96,7 +96,7 @@ class Section(Viewable, View):
def add_css_class(self, css_class):
if self.css_class:
if css_class not in self.css_class:
if css_class not in self.css_class.split(' '):
self.css_class += ' ' + css_class
else:
self.css_class = css_class
@ -255,8 +255,6 @@ class List(Section):
"""
super().__init__(*args, **kwargs)
self.add_css_class('list')
if type(self) != Section:
self.add_css_class('section_' + type(self).__name__.lower())
if items:
self.object_list = [

View File

@ -32,7 +32,7 @@ class PostBaseView:
Add the given class to the current class list if not yet present.
"""
if self.css_class:
if css_class not in self.css_class:
if css_class not in self.css_class.split(' '):
self.css_class += ' ' + css_class
else:
self.css_class = css_class

View File

@ -132,7 +132,7 @@ class DiffusionAdmin(admin.ModelAdmin):
We want rerun to redirect to the given object.
"""
obj = super().get_object(*args, **kwargs)
if obj.initial:
if obj and obj.initial:
obj = obj.initial
return obj

View File

@ -78,6 +78,7 @@ class Track(Nameable):
)
tags = TaggableManager(
verbose_name=_('tags'),
blank=True,
)
def __str__(self):

View File

@ -14,9 +14,11 @@ class TrackInline(SortableTabularInline):
sortable = 'position'
extra = 10
admin.site.register(models.Program, cms.RelatedPostAdmin)
admin.site.register(models.Diffusion, cms.RelatedPostAdmin)
cms.inject_related_inline(models.Program, True)
cms.inject_inline(programs.Diffusion, TrackInline, True)
cms.inject_related_inline(models.Diffusion, True)

View File

@ -110,7 +110,7 @@ class Playlist(sections.List):
tracks = programs.Track.objects \
.filter(diffusion = self.object.related) \
.order_by('position')
return [ sections.ListItem(title=track.title, content=track.artist)
return [ sections.ListItem(title=track.name, content=track.artist)
for track in tracks ]