From 0e48b9844c7ccd6a4b966349fcfcf865405a1074 Mon Sep 17 00:00:00 2001 From: bkfox Date: Fri, 11 Oct 2019 16:23:00 +0200 Subject: [PATCH] fix glitches --- aircox/admin/program.py | 9 ++------- aircox/admin/sound.py | 4 +++- aircox/admin_site.py | 3 ++- aircox/management/commands/archiver.py | 4 ++-- aircox/settings.py | 12 ++++-------- aircox/templates/admin/base.html | 4 ++-- requirements.txt | 1 + 7 files changed, 16 insertions(+), 21 deletions(-) diff --git a/aircox/admin/program.py b/aircox/admin/program.py index df732ea..12e9390 100644 --- a/aircox/admin/program.py +++ b/aircox/admin/program.py @@ -51,15 +51,10 @@ class ScheduleAdmin(admin.ModelAdmin): return obj.get_frequency_verbose() freq.short_description = _('Day') - def rerun(self, obj): - return obj.initial is not None - rerun.short_description = _('Rerun') - rerun.boolean = True - list_filter = ['frequency', 'program'] list_display = ['program_title', 'freq', 'time', 'timezone', 'duration', - 'rerun'] - list_editable = ['time', 'duration'] + 'initial'] + list_editable = ['time', 'duration', 'initial'] def get_readonly_fields(self, request, obj=None): if obj: diff --git a/aircox/admin/sound.py b/aircox/admin/sound.py index ca0f9f5..b2e4d3a 100644 --- a/aircox/admin/sound.py +++ b/aircox/admin/sound.py @@ -16,13 +16,15 @@ class TracksInline(SortableInlineAdminMixin, admin.TabularInline): list_filter = ['artist', 'title', 'tags'] - class SoundInline(admin.TabularInline): model = Sound fields = ['type', 'path', 'embed', 'duration', 'is_public'] readonly_fields = ['type', 'path', 'duration'] extra = 0 + def get_queryset(self, request): + return super().get_queryset(request).available() + @admin.register(Sound) class SoundAdmin(admin.ModelAdmin): diff --git a/aircox/admin_site.py b/aircox/admin_site.py index 82feb7a..edddc9e 100644 --- a/aircox/admin_site.py +++ b/aircox/admin_site.py @@ -26,7 +26,8 @@ class AdminSite(admin.AdminSite): def each_context(self, request): context = super().each_context(request) context.update({ - 'programs': Program.objects.all().active().values('pk', 'title'), + 'programs': Program.objects.all().active().values('pk', 'title') \ + .order_by('title'), }) return context diff --git a/aircox/management/commands/archiver.py b/aircox/management/commands/archiver.py index b652af5..920a49e 100644 --- a/aircox/management/commands/archiver.py +++ b/aircox/management/commands/archiver.py @@ -23,9 +23,9 @@ class Command (BaseCommand): group = parser.add_argument_group('actions') group.add_argument( '-a', '--age', type=int, - default=settings.AIRCOX_LOGS_ARCHIVES_MIN_AGE, + default=settings.AIRCOX_LOGS_ARCHIVES_AGE, help='minimal age in days of logs to archive. Default is ' - 'settings.AIRCOX_LOGS_ARCHIVES_MIN_AGE' + 'settings.AIRCOX_LOGS_ARCHIVES_AGE' ) group.add_argument( '-f', '--force', action='store_true', diff --git a/aircox/settings.py b/aircox/settings.py index 4805ba4..d8d60c6 100755 --- a/aircox/settings.py +++ b/aircox/settings.py @@ -15,17 +15,13 @@ def ensure(key, default): # group to assign to users at their creation, along with the permissions # to add to each group. ensure('AIRCOX_DEFAULT_USER_GROUPS', { - 'Radio Hosts': ( - 'change_program', 'change_diffusion', + 'radio hosts': ( + 'change_program', 'change_episode', 'change_diffusion', 'change_sound', 'add_track', 'change_track', 'delete_track', 'add_tag', 'change_tag', 'delete_tag', 'add_comment', 'edit_comment', 'delete_comment', ), - # ensure user can log in using Wagtail - 'Editors': None, - # ensure user can publish - 'Moderators': None, }) # Directory for the programs data @@ -50,10 +46,10 @@ ensure('AIRCOX_EPISODE_TITLE_DATE_FORMAT', '%-d %B %Y') ######################################################################## # Directory where to save logs' archives ensure('AIRCOX_LOGS_ARCHIVES_DIR', - os.path.join(AIRCOX_DATA_DIR, 'archives') + os.path.join(AIRCOX_DATA_DIR, 'episodes') ) # In days, minimal age of a log before it is archived -ensure('AIRCOX_LOGS_ARCHIVES_MIN_AGE', 60) +ensure('AIRCOX_LOGS_ARCHIVES_AGE', 60) ######################################################################## diff --git a/aircox/templates/admin/base.html b/aircox/templates/admin/base.html index 83ea901..459fa92 100644 --- a/aircox/templates/admin/base.html +++ b/aircox/templates/admin/base.html @@ -44,7 +44,7 @@