forked from rc/aircox
- !88 pytest on existing tests - !89 reorganise settings (! see notes for deployment) Co-authored-by: bkfox <thomas bkfox net> Reviewed-on: rc/aircox#92
This commit is contained in:
@ -1,4 +1,3 @@
|
||||
from . import signals
|
||||
from .article import Article
|
||||
from .episode import Diffusion, DiffusionQuerySet, Episode
|
||||
from .log import Log, LogArchiver, LogQuerySet
|
||||
|
@ -7,7 +7,8 @@ from django.utils.functional import cached_property
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from easy_thumbnails.files import get_thumbnailer
|
||||
|
||||
from aircox import settings, utils
|
||||
from aircox.conf import settings
|
||||
from aircox import utils
|
||||
|
||||
from .page import Page
|
||||
from .program import (
|
||||
@ -70,18 +71,18 @@ class Episode(Page):
|
||||
|
||||
@classmethod
|
||||
def get_default_title(cls, page, date):
|
||||
return settings.AIRCOX_EPISODE_TITLE.format(
|
||||
return settings.EPISODE_TITLE.format(
|
||||
program=page,
|
||||
date=date.strftime(settings.AIRCOX_EPISODE_TITLE_DATE_FORMAT),
|
||||
date=date.strftime(settings.EPISODE_TITLE_DATE_FORMAT),
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def get_init_kwargs_from(cls, page, date, title=None, **kwargs):
|
||||
"""Get default Episode's title."""
|
||||
title = (
|
||||
settings.AIRCOX_EPISODE_TITLE.format(
|
||||
settings.EPISODE_TITLE.format(
|
||||
program=page,
|
||||
date=date.strftime(settings.AIRCOX_EPISODE_TITLE_DATE_FORMAT),
|
||||
date=date.strftime(settings.EPISODE_TITLE_DATE_FORMAT),
|
||||
)
|
||||
if title is None
|
||||
else title
|
||||
|
@ -10,8 +10,9 @@ from django.utils import timezone as tz
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from aircox import settings
|
||||
from aircox.conf import settings
|
||||
|
||||
__all__ = ("Settings", "settings")
|
||||
from .episode import Diffusion
|
||||
from .sound import Sound, Track
|
||||
from .station import Station
|
||||
@ -251,7 +252,7 @@ class LogArchiver:
|
||||
@staticmethod
|
||||
def get_path(station, date):
|
||||
return os.path.join(
|
||||
settings.AIRCOX_LOGS_ARCHIVES_DIR,
|
||||
settings.LOGS_ARCHIVES_DIR_ABS,
|
||||
"{}_{}.log.gz".format(date.strftime("%Y%m%d"), station.pk),
|
||||
)
|
||||
|
||||
@ -264,7 +265,7 @@ class LogArchiver:
|
||||
if not qs.exists():
|
||||
return 0
|
||||
|
||||
os.makedirs(settings.AIRCOX_LOGS_ARCHIVES_DIR, exist_ok=True)
|
||||
os.makedirs(settings.LOGS_ARCHIVES_DIR_ABS, exist_ok=True)
|
||||
count = qs.count()
|
||||
logs = self.sort_logs(qs)
|
||||
|
||||
|
@ -15,7 +15,8 @@ from django.utils import timezone as tz
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from aircox import settings, utils
|
||||
from aircox import utils
|
||||
from aircox.conf import settings
|
||||
|
||||
from .page import Page, PageQuerySet
|
||||
from .station import Station
|
||||
@ -77,9 +78,7 @@ class Program(Page):
|
||||
@property
|
||||
def path(self):
|
||||
"""Return program's directory path."""
|
||||
return os.path.join(
|
||||
settings.AIRCOX_PROGRAMS_DIR, self.slug.replace("-", "_")
|
||||
)
|
||||
return os.path.join(settings.PROGRAMS_DIR, self.slug.replace("-", "_"))
|
||||
|
||||
@property
|
||||
def abspath(self):
|
||||
@ -88,11 +87,11 @@ class Program(Page):
|
||||
|
||||
@property
|
||||
def archives_path(self):
|
||||
return os.path.join(self.path, settings.AIRCOX_SOUND_ARCHIVES_SUBDIR)
|
||||
return os.path.join(self.path, settings.SOUND_ARCHIVES_SUBDIR)
|
||||
|
||||
@property
|
||||
def excerpts_path(self):
|
||||
return os.path.join(self.path, settings.AIRCOX_SOUND_ARCHIVES_SUBDIR)
|
||||
return os.path.join(self.path, settings.SOUND_ARCHIVES_SUBDIR)
|
||||
|
||||
def __init__(self, *kargs, **kwargs):
|
||||
super().__init__(*kargs, **kwargs)
|
||||
@ -107,8 +106,8 @@ class Program(Page):
|
||||
We assume the path has been given in a previous time by this
|
||||
model (Program.path getter).
|
||||
"""
|
||||
if path.startswith(settings.AIRCOX_PROGRAMS_DIR_ABS):
|
||||
path = path.replace(settings.AIRCOX_PROGRAMS_DIR_ABS, "")
|
||||
if path.startswith(settings.PROGRAMS_DIR_ABS):
|
||||
path = path.replace(settings.PROGRAMS_DIR_ABS, "")
|
||||
while path[0] == "/":
|
||||
path = path[1:]
|
||||
path = path[: path.index("/")]
|
||||
|
@ -4,7 +4,8 @@ from django.db.models import signals
|
||||
from django.dispatch import receiver
|
||||
from django.utils import timezone as tz
|
||||
|
||||
from .. import settings, utils
|
||||
from aircox import utils
|
||||
from aircox.conf import settings
|
||||
from . import Diffusion, Episode, Page, Program, Schedule
|
||||
|
||||
|
||||
@ -20,7 +21,7 @@ def user_default_groups(sender, instance, created, *args, **kwargs):
|
||||
if not created or instance.is_superuser:
|
||||
return
|
||||
|
||||
for group_name, permissions in settings.AIRCOX_DEFAULT_USER_GROUPS.items():
|
||||
for group_name, permissions in settings.DEFAULT_USER_GROUPS.items():
|
||||
if instance.groups.filter(name=group_name).count():
|
||||
continue
|
||||
|
||||
|
@ -8,7 +8,7 @@ from django.utils import timezone as tz
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from taggit.managers import TaggableManager
|
||||
|
||||
from aircox import settings
|
||||
from aircox.conf import settings
|
||||
|
||||
from .episode import Episode
|
||||
from .program import Program
|
||||
@ -123,9 +123,9 @@ class Sound(models.Model):
|
||||
|
||||
def _upload_to(self, filename):
|
||||
subdir = (
|
||||
settings.AIRCOX_SOUND_ARCHIVES_SUBDIR
|
||||
settings.SOUND_ARCHIVES_SUBDIR
|
||||
if self.type == self.TYPE_ARCHIVE
|
||||
else settings.AIRCOX_SOUND_EXCERPTS_SUBDIR
|
||||
else settings.SOUND_EXCERPTS_SUBDIR
|
||||
)
|
||||
return os.path.join(self.program.path, subdir, filename)
|
||||
|
||||
|
@ -5,7 +5,7 @@ from django.utils.functional import cached_property
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from filer.fields.image import FilerImageField
|
||||
|
||||
from .. import settings
|
||||
from aircox.conf import settings
|
||||
|
||||
__all__ = ("Station", "StationQuerySet", "Port")
|
||||
|
||||
@ -92,7 +92,7 @@ class Station(models.Model):
|
||||
def save(self, make_sources=True, *args, **kwargs):
|
||||
if not self.path:
|
||||
self.path = os.path.join(
|
||||
settings.AIRCOX_CONTROLLERS_WORKING_DIR,
|
||||
settings.CONTROLLERS_WORKING_DIR,
|
||||
self.slug.replace("-", "_"),
|
||||
)
|
||||
|
||||
|
Reference in New Issue
Block a user