diff --git a/README.md b/README.md index 8d02542..d4bdc85 100644 --- a/README.md +++ b/README.md @@ -12,10 +12,6 @@ Platform to manage a radio. We use the power of Django ## Applications * **programs**: managing stations, programs, schedules and diffusions. This is the core application, that handle most of the work. * **cms**: cms manager with reusable tools. -* **liquidsoap**: liquidsoap manager and control. +* **liquidsoap**: liquidsoap controls. -## Code and names conventions and uses -* absolute dates: datetime fields, named "begin" "end" for ranges and "date" otherwise -* time range: timefield name "duration" -* parents: when only one parent, named "parent", otherwise model/reference's name diff --git a/aircox/cms/templates/aircox_cms/base_content.html b/aircox/cms/templates/aircox/cms/base_content.html similarity index 100% rename from aircox/cms/templates/aircox_cms/base_content.html rename to aircox/cms/templates/aircox/cms/base_content.html diff --git a/aircox/cms/templates/aircox_cms/base_section.html b/aircox/cms/templates/aircox/cms/base_section.html similarity index 100% rename from aircox/cms/templates/aircox_cms/base_section.html rename to aircox/cms/templates/aircox/cms/base_section.html diff --git a/aircox/cms/templates/aircox_cms/base_site.html b/aircox/cms/templates/aircox/cms/base_site.html similarity index 100% rename from aircox/cms/templates/aircox_cms/base_site.html rename to aircox/cms/templates/aircox/cms/base_site.html diff --git a/aircox/cms/templates/aircox_cms/detail.html b/aircox/cms/templates/aircox/cms/detail.html similarity index 100% rename from aircox/cms/templates/aircox_cms/detail.html rename to aircox/cms/templates/aircox/cms/detail.html diff --git a/aircox/cms/templates/aircox_cms/embed.html b/aircox/cms/templates/aircox/cms/embed.html similarity index 100% rename from aircox/cms/templates/aircox_cms/embed.html rename to aircox/cms/templates/aircox/cms/embed.html diff --git a/aircox/cms/templates/aircox_cms/list.html b/aircox/cms/templates/aircox/cms/list.html similarity index 100% rename from aircox/cms/templates/aircox_cms/list.html rename to aircox/cms/templates/aircox/cms/list.html diff --git a/aircox/cms/templates/aircox_cms/menu.html b/aircox/cms/templates/aircox/cms/menu.html similarity index 100% rename from aircox/cms/templates/aircox_cms/menu.html rename to aircox/cms/templates/aircox/cms/menu.html diff --git a/aircox/cms/templates/aircox_cms/section.html b/aircox/cms/templates/aircox/cms/section.html similarity index 100% rename from aircox/cms/templates/aircox_cms/section.html rename to aircox/cms/templates/aircox/cms/section.html diff --git a/aircox/cms/templates/aircox_cms/section_list.html b/aircox/cms/templates/aircox/cms/section_list.html similarity index 100% rename from aircox/cms/templates/aircox_cms/section_list.html rename to aircox/cms/templates/aircox/cms/section_list.html diff --git a/aircox/cms/templates/aircox_cms/tags b/aircox/cms/templates/aircox/cms/tags similarity index 100% rename from aircox/cms/templates/aircox_cms/tags rename to aircox/cms/templates/aircox/cms/tags diff --git a/aircox/cms/views.py b/aircox/cms/views.py index 3ba6547..0ca3e71 100644 --- a/aircox/cms/views.py +++ b/aircox/cms/views.py @@ -70,7 +70,7 @@ class PostListView (PostBaseView, ListView): return self.__dict__.update(query) - template_name = 'aircox_cms/list.html' + template_name = 'aircox/cms/list.html' allow_empty = True paginate_by = 50 model = None @@ -143,7 +143,7 @@ class PostDetailView (DetailView, PostBaseView): """ Detail view for posts and children """ - template_name = 'aircox_cms/detail.html' + template_name = 'aircox/cms/detail.html' sections = [] @@ -179,7 +179,7 @@ class PostDetailView (DetailView, PostBaseView): class Menu (View): - template_name = 'aircox_cms/menu.html' + template_name = 'aircox/cms/menu.html' name = '' tag = 'nav' @@ -218,7 +218,7 @@ class BaseSection (View): Base class for sections. Sections are view that can be used in detail view in order to have extra content about a post, or in menus. """ - template_name = 'aircox_cms/base_section.html' + template_name = 'aircox/cms/base_section.html' kwargs = None # kwargs argument passed to get tag = 'div' # container tags classes = '' # container classes @@ -253,7 +253,7 @@ class Section (BaseSection): """ A Section that can be related to an object. """ - template_name = 'aircox_cms/section.html' + template_name = 'aircox/cms/section.html' object = None object_required = False title = '' @@ -331,7 +331,7 @@ class Sections: use_icons = True # print icons paginate_by = 0 # number of items icon_size = '32x32' # icons size - template_name = 'aircox_cms/section_list.html' + template_name = 'aircox/cms/section_list.html' def get_object_list (self): return [] diff --git a/aircox/liquidsoap/management/commands/liquidsoap.py b/aircox/liquidsoap/management/commands/liquidsoap.py index 786c929..c53e86f 100644 --- a/aircox/liquidsoap/management/commands/liquidsoap.py +++ b/aircox/liquidsoap/management/commands/liquidsoap.py @@ -8,6 +8,7 @@ import time import re from argparse import RawTextHelpFormatter +from django.conf import settings as main_settings from django.core.management.base import BaseCommand, CommandError from django.template.loader import render_to_string from django.utils import timezone as tz @@ -36,12 +37,20 @@ class StationConfig: self.make_playlists() def make_config (self): + log_script = main_settings.BASE_DIR \ + if hasattr(main_settings, 'BASE_DIR') else \ + main_settings.PROJECT_ROOT + log_script = os.path.join(log_script, 'manage.py') + \ + ' liquidsoap_log' + + context = { 'controller': self.controller, 'settings': settings, + 'log_script': log_script, } - data = render_to_string('aircox_liquidsoap/station.liq', context) + data = render_to_string('aircox/liquidsoap/station.liq', context) data = re.sub(r'\s*\\\n', r'#\\n#', data) data = data.replace('\n', '') data = re.sub(r'#\\n#', '\n', data) diff --git a/aircox/liquidsoap/management/commands/liquidsoap_log.py b/aircox/liquidsoap/management/commands/liquidsoap_log.py new file mode 100644 index 0000000..8d36e50 --- /dev/null +++ b/aircox/liquidsoap/management/commands/liquidsoap_log.py @@ -0,0 +1,62 @@ +""" +This script is used by liquidsoap in order to log a file change. It should not +be used for other purposes. +""" +import os +from argparse import RawTextHelpFormatter + +from django.utils import timezone as tz +from django.core.management.base import BaseCommand, CommandError + +import aircox.programs.models as programs + + +class Command (BaseCommand): + help= __doc__ + + @staticmethod + def date(s): + try: + return tz.make_aware(tz.datetime.strptime(s, '%Y/%m/%d %H:%M:%S')) + except ValueError: + raise argparse.ArgumentTypeError('Invalid date format') + + + def add_arguments (self, parser): + parser.formatter_class=RawTextHelpFormatter + parser.add_argument( + '-c', '--comment', type=str, + help='log comment' + ) + parser.add_argument( + '-s', '--source', type=str, + required=True, + help='source path' + ) + parser.add_argument( + '-p', '--path', type=str, + required=True, + help='sound path to log' + ) + parser.add_argument( + '-d', '--date', type=Command.date, + help='set date instead of now (using format "%Y/%m/%d %H:%M:%S")' + ) + + + def handle (self, *args, **options): + comment = options.get('comment') or '' + path = os.path.realpath(options.get('path')) + + sound = programs.Sound.objects.filter(path = path) + if sound: + sound = sound[0] + else: + sound = None + comment += '\nunregistered sound: {}'.format(path) + + programs.Log(source = options.get('source'), + comment = comment, + related_object = sound).save() + + diff --git a/aircox/liquidsoap/templates/aircox_liquidsoap/controller.html b/aircox/liquidsoap/templates/aircox/liquidsoap/controller.html similarity index 94% rename from aircox/liquidsoap/templates/aircox_liquidsoap/controller.html rename to aircox/liquidsoap/templates/aircox/liquidsoap/controller.html index 46fa95f..4a46241 100644 --- a/aircox/liquidsoap/templates/aircox_liquidsoap/controller.html +++ b/aircox/liquidsoap/templates/aircox/liquidsoap/controller.html @@ -106,15 +106,15 @@