Commit 51efce9d authored by fred's avatar fred

add a settings for jingles path prefix

parent 8650f9e8
......@@ -13,5 +13,10 @@ class AppSettings:
def LOCAL_BASE_PATH(self):
return self.get_setting('LOCAL_BASE_PATH', '/media/nonstop/')
@property
def JINGLES_PREFIX(self):
# relative to ..._BASE_PATH
return self.get_setting('JINGLES_PREFIX', 'SPOTS')
app_settings = AppSettings()
......@@ -38,7 +38,7 @@ class Command(BaseCommand):
if self.verbose:
print(i, count, filepath)
short_filepath = filepath[len(app_settings.LOCAL_BASE_PATH):]
if short_filepath.startswith('SPOTS'):
if short_filepath.startswith(app_settings.JINGLES_PREFIX):
continue
if not os.path.exists(filepath):
if self.verbose and short_filepath.startswith('Tranches'):
......
......@@ -198,7 +198,7 @@ class Jingle(models.Model):
def get_local_filepath(self):
if not self.short:
return None
return os.path.join(app_settings.LOCAL_BASE_PATH, 'SPOTS', self.short)
return os.path.join(app_settings.LOCAL_BASE_PATH, app_settings.JINGLES_PREFIX, self.short)
@property
def title(self):
......
......@@ -404,4 +404,4 @@ class DelSomaDiffusionView(RedirectView):
def jingle_audio_view(request, *args, **kwargs):
jingle = Jingle.objects.get(id=kwargs['pk'])
return FileResponse(open(os.path.join(app_settings.LOCAL_BASE_PATH, 'SPOTS', jingle.filepath), 'rb'))
return FileResponse(open(os.path.join(app_settings.LOCAL_BASE_PATH, app_settings.JINGLES_PREFIX, jingle.filepath), 'rb'))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment