diff --git a/aircox/admin/sound.py b/aircox/admin/sound.py
index 2d39545..10184e3 100644
--- a/aircox/admin/sound.py
+++ b/aircox/admin/sound.py
@@ -1,5 +1,6 @@
from django.contrib import admin
-from django.utils.translation import gettext as _, gettext_lazy
+from django.utils.safestring import mark_safe
+from django.utils.translation import gettext as _
from adminsortable2.admin import SortableInlineAdminMixin
@@ -21,9 +22,13 @@ class SoundTrackInline(TrackInline):
class SoundInline(admin.TabularInline):
model = Sound
- fields = ['type', 'path', 'embed', 'duration', 'is_public']
- readonly_fields = ['type', 'path', 'duration']
+ fields = ['type', 'name', 'audio', 'duration', 'is_good_quality', 'is_public']
+ readonly_fields = ['type', 'audio', 'duration', 'is_good_quality']
extra = 0
+ max_num = 0
+
+ def audio(self, obj):
+ return mark_safe(''.format(obj.url()))
def get_queryset(self, request):
return super().get_queryset(request).available()
@@ -40,11 +45,10 @@ class SoundAdmin(admin.ModelAdmin):
'is_public', 'is_good_quality', 'episode', 'filename']
list_filter = ('type', 'is_good_quality', 'is_public')
- search_fields = ['name', 'program']
+ search_fields = ['name', 'program__title']
fieldsets = [
(None, {'fields': ['name', 'path', 'type', 'program', 'episode']}),
- (None, {'fields': ['embed', 'duration', 'is_public', 'mtime']}),
- (None, {'fields': ['is_good_quality']})
+ (None, {'fields': ['duration', 'is_public', 'is_good_quality', 'mtime']}),
]
readonly_fields = ('path', 'duration',)
inlines = [SoundTrackInline]
diff --git a/aircox/management/commands/sounds_quality_check.py b/aircox/management/commands/sounds_quality_check.py
index b2469b0..774c5e9 100755
--- a/aircox/management/commands/sounds_quality_check.py
+++ b/aircox/management/commands/sounds_quality_check.py
@@ -60,6 +60,12 @@ class Stats:
self.parse(str(out, encoding='utf-8'))
+#class SoundFile:
+# path = None
+# sample_rate = None
+# length = None
+
+
class Sound:
path = None # file path
sample_length = 120 # default sample length in seconds
diff --git a/aircox/models/sound.py b/aircox/models/sound.py
index d437c15..3c5885c 100644
--- a/aircox/models/sound.py
+++ b/aircox/models/sound.py
@@ -37,9 +37,9 @@ class SoundQuerySet(models.QuerySet):
def available(self):
return self.exclude(type=Sound.TYPE_REMOVED)
- def podcasts(self):
+ def public(self):
""" Return sounds available as podcasts """
- return self.filter(Q(embed__isnull=False) | Q(is_public=True))
+ return self.filter(is_public=True)
def archive(self):
""" Return sounds that are archives """
@@ -103,11 +103,11 @@ class Sound(models.Model):
recursive=True, max_length=255,
blank=True, null=True, unique=True,
)
- embed = models.TextField(
- _('embed'),
- blank=True, null=True,
- help_text=_('HTML code to embed a sound from an external plateform'),
- )
+ #embed = models.TextField(
+ # _('embed'),
+ # blank=True, null=True,
+ # help_text=_('HTML code to embed a sound from an external plateform'),
+ #)
duration = models.TimeField(
_('duration'),
blank=True, null=True,
@@ -156,19 +156,12 @@ class Sound(models.Model):
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
+ """ Return an url to the stream. """
path = self.path.replace(main_settings.MEDIA_ROOT, '', 1)
- #path = self.path.replace(path, '', 1)
-
return main_settings.MEDIA_URL + '/' + path
def file_exists(self):
- """
- Return true if the file still exists
- """
+ """ Return true if the file still exists. """
return os.path.exists(self.path)
@@ -241,23 +234,6 @@ class Sound(models.Model):
return changed
- def check_perms(self):
- """
- Check file permissions and update it if the sound is public
- """
-
- if not settings.AIRCOX_SOUND_AUTO_CHMOD or \
- self.removed or not os.path.exists(self.path):
-
- return
-
- flags = settings.AIRCOX_SOUND_CHMOD_FLAGS[self.is_public]
- try:
- os.chmod(self.path, flags)
- except PermissionError as err:
- logger.error('cannot set permissions {} to file {}: {}'.format(
- self.flags[self.is_public], self.path, err))
-
def __check_name(self):
if not self.name and self.path:
# FIXME: later, remove date?
diff --git a/aircox/settings.py b/aircox/settings.py
index 3fc44e2..8ca0ceb 100755
--- a/aircox/settings.py
+++ b/aircox/settings.py
@@ -1,5 +1,4 @@
import os
-import stat
from django.conf import settings
@@ -38,8 +37,6 @@ from django.conf import settings
# sounds_default_dir = os.path.join(settings.MEDIA_ROOT, 'programs/defaults')
# sound_archive_dir = 'archives'
# sound_excerpt_dir = 'excerpts'
-# sound_auto_chmod = True
-# sound_chmod_flags = (stat.S_IRWXU, stat.S_IRWXU | stat.S_IRWXG | stat.S_IROTH)
# sound_quality = {
# 'attribute': 'RMS lev dB',
# 'range': (-18.0, -8.0),
@@ -116,15 +113,6 @@ ensure('AIRCOX_SOUND_ARCHIVES_SUBDIR', 'archives')
# Sub directory used for the excerpts of the episode
ensure('AIRCOX_SOUND_EXCERPTS_SUBDIR', 'excerpts')
-# Change sound perms based on 'public' attribute if True
-ensure('AIRCOX_SOUND_AUTO_CHMOD', True)
-# Chmod bits flags as a tuple for (not public, public). Use os.chmod
-# and stat.*
-ensure(
- 'AIRCOX_SOUND_CHMOD_FLAGS',
- (stat.S_IRWXU, stat.S_IRWXU | stat.S_IRWXG | stat.S_IROTH)
-)
-
# Quality attributes passed to sound_quality_check from sounds_monitor
ensure('AIRCOX_SOUND_QUALITY', {
'attribute': 'RMS lev dB',
diff --git a/aircox/templates/aircox/widgets/player.html b/aircox/templates/aircox/widgets/player.html
index 1e45dc0..856512f 100644
--- a/aircox/templates/aircox/widgets/player.html
+++ b/aircox/templates/aircox/widgets/player.html
@@ -28,7 +28,7 @@ The audio player
-
+
-
♬
[[ onAir.title ]]
@@ -39,14 +39,14 @@ The audio player
+
-
[[ onAir.title ]]
{{ station.name }}
+ {{ station.name }}
diff --git a/aircox/templates/aircox/widgets/podcast_item.html b/aircox/templates/aircox/widgets/podcast_item.html
index 7543f81..44a3fde 100644
--- a/aircox/templates/aircox/widgets/podcast_item.html
+++ b/aircox/templates/aircox/widgets/podcast_item.html
@@ -3,9 +3,11 @@ List item for a podcast.
{% endcomment %}