]> git.0d.be Git - django-panik-nonstop.git/commitdiff
use new settings
authorFrédéric Péters <fpeters@0d.be>
Sun, 14 Jun 2020 11:49:45 +0000 (13:49 +0200)
committerFrédéric Péters <fpeters@0d.be>
Sun, 14 Jun 2020 11:51:15 +0000 (13:51 +0200)
nonstop/utils.py
nonstop/views.py

index 7666dc41a8e4f3872ff960e5f6833cfa128e869c..b474ac6e8278a9a7e42754d54e2921887281bde3 100644 (file)
@@ -8,7 +8,8 @@ from django.template import loader
 from django.utils.timezone import now
 import xml.etree.ElementTree as ET
 
-from .models import Track, SomaLogLine, ScheduledDiffusion, Jingle, LOCAL_BASE_PATH
+from .models import Track, SomaLogLine, ScheduledDiffusion, Jingle
+from .app_settings import app_settings
 
 
 class SomaException(Exception):
@@ -79,20 +80,20 @@ def add_soma_diffusion(diffusion):
         diffusion_path = get_diffusion_file_path(diffusion)
 
         # copy file
-        if not os.path.exists(LOCAL_BASE_PATH):
+        if not os.path.exists(app_settings.LOCAL_BASE_PATH):
             raise SomaException('soma directory is not available')
         local_diffusion_path = os.path.join(LOCAL_BASE_PATH, diffusion_path)
         if os.path.exists(local_diffusion_path):
             for filename in os.listdir(local_diffusion_path):
                 os.unlink(os.path.join(local_diffusion_path, filename))
         else:
-            os.mkdir(os.path.join(LOCAL_BASE_PATH, diffusion_path))
+            os.mkdir(os.path.join(app_settings.LOCAL_BASE_PATH, diffusion_path))
         try:
             shutil.copyfile(soundfile.file.path,
-                os.path.join(LOCAL_BASE_PATH, diffusion_path, os.path.basename(soundfile.file.path)))
+                os.path.join(app_settings.LOCAL_BASE_PATH, diffusion_path, os.path.basename(soundfile.file.path)))
         except IOError:
             try:
-                os.rmdir(os.path.join(LOCAL_BASE_PATH, diffusion_path))
+                os.rmdir(os.path.join(app_settings.LOCAL_BASE_PATH, diffusion_path))
             except IOError:
                 pass
             raise SomaException('error copying file to soma')
index 65f42d89c519d2b2e20501f19f4f44a05b501746..3984318648df4538ce6f253014e84e0e57a5178c 100644 (file)
@@ -21,11 +21,11 @@ from django.views.generic.edit import CreateView, FormView
 from django.views.generic.list import ListView
 
 from .forms import UploadTracksForm, TrackMetaForm, TrackSearchForm, CleanupForm
-from .models import (SomaLogLine, Track, Artist, NonstopFile, ScheduledDiffusion, Jingle,
-        Stream, LOCAL_BASE_PATH)
+from .models import (SomaLogLine, Track, Artist, NonstopFile, ScheduledDiffusion, Jingle, Stream)
 from emissions.models import Nonstop, Diffusion
 
 from . import utils
+from .app_settings import app_settings
 
 
 class SomaDayArchiveView(DayArchiveView):
@@ -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(LOCAL_BASE_PATH, 'SPOTS', jingle.filepath), 'rb'))
+    return FileResponse(open(os.path.join(app_settings.LOCAL_BASE_PATH, 'SPOTS', jingle.filepath), 'rb'))