diff --git a/programs/models.py b/programs/models.py index da2be06..d9e4158 100755 --- a/programs/models.py +++ b/programs/models.py @@ -10,6 +10,7 @@ from django.utils import timezone as tz from django.utils.html import strip_tags from django.contrib.contenttypes.fields import GenericForeignKey from django.contrib.contenttypes.models import ContentType +from django.conf import settings as main_settings from taggit.managers import TaggableManager @@ -152,6 +153,16 @@ class Sound(Nameable): mtime = mtime.replace(microsecond = 0) return tz.make_aware(mtime, tz.get_current_timezone()) + def url(self): + """ + Return an url to the stream + """ + # path = self._meta.get_field('path').path + path = self.path.replace(main_settings.MEDIA_ROOT, '', 1) + #path = self.path.replace(path, '', 1) + # print(path, self._meta.get_field('path').path) + return path + def file_exists(self): """ Return true if the file still exists diff --git a/website/admin.py b/website/admin.py index 5bdfce9..a8440a7 100644 --- a/website/admin.py +++ b/website/admin.py @@ -21,5 +21,5 @@ 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) - +cms.inject_related_inline(models.Sound, True) diff --git a/website/models.py b/website/models.py index 66a8aad..f020cac 100644 --- a/website/models.py +++ b/website/models.py @@ -1,4 +1,5 @@ import os +import stat import logging logger = logging.getLogger('aircox') @@ -110,13 +111,14 @@ class Sound (RelatedPost): """ change file permission depending on the "published" attribute. """ - chmod_flags = (750, 700) + chmod_flags = (stat.S_IRWXU, stat.S_IRWXU | stat.S_IRWXG | stat.S_IROTH ) """ chmod bit flags, for (not_published, published) """ class Relation: model = programs.Sound bindings = { + 'title': 'name', 'date': 'mtime', } rel_to_post = True diff --git a/website/sections.py b/website/sections.py index 21ea34a..1e1bc4d 100644 --- a/website/sections.py +++ b/website/sections.py @@ -46,7 +46,10 @@ class Player(sections.Section): context.update({ 'base_template': 'aircox/cms/section.html', - 'live_streams': self.live_streams + 'live_streams': self.live_streams, + 'last_sounds': models.Sound.objects. \ + filter(published = True). \ + order_by('-pk')[:10], }) return context diff --git a/website/templates/aircox/website/player.html b/website/templates/aircox/website/player.html new file mode 100644 index 0000000..418802b --- /dev/null +++ b/website/templates/aircox/website/player.html @@ -0,0 +1,285 @@ +{% extends 'aircox/cms/list.html' %} + +{% load staticfiles %} +{% load i18n %} + +{% block header %} + +