From: Frédéric Péters Date: Sun, 14 Jun 2020 11:49:45 +0000 (+0200) Subject: use new settings X-Git-Tag: v2021~207 X-Git-Url: https://git.0d.be/?p=django-panik-nonstop.git;a=commitdiff_plain;h=7d7dab931675275eff025e9a29891b0c23226752 use new settings --- diff --git a/nonstop/utils.py b/nonstop/utils.py index 7666dc4..b474ac6 100644 --- a/nonstop/utils.py +++ b/nonstop/utils.py @@ -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') diff --git a/nonstop/views.py b/nonstop/views.py index 65f42d8..3984318 100644 --- a/nonstop/views.py +++ b/nonstop/views.py @@ -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'))