forked from rc/aircox
fix bugs
This commit is contained in:
parent
c04c1f3a53
commit
1c44be4814
|
@ -1,3 +1,5 @@
|
||||||
|
from copy import copy
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
|
@ -5,7 +7,7 @@ from django.utils.translation import gettext as _
|
||||||
from ..models import Episode, Diffusion
|
from ..models import Episode, Diffusion
|
||||||
|
|
||||||
from .page import PageAdmin
|
from .page import PageAdmin
|
||||||
from .sound import SoundInline, TracksInline
|
from .sound import SoundInline, TrackInline
|
||||||
|
|
||||||
|
|
||||||
class DiffusionBaseAdmin:
|
class DiffusionBaseAdmin:
|
||||||
|
@ -14,7 +16,7 @@ class DiffusionBaseAdmin:
|
||||||
def get_readonly_fields(self, request, obj=None):
|
def get_readonly_fields(self, request, obj=None):
|
||||||
fields = super().get_readonly_fields(request, obj)
|
fields = super().get_readonly_fields(request, obj)
|
||||||
if not request.user.has_perm('aircox_program.scheduling'):
|
if not request.user.has_perm('aircox_program.scheduling'):
|
||||||
fields += ('program', 'start', 'end')
|
fields = fields + ('program', 'start', 'end')
|
||||||
return [field for field in fields if field in self.fields]
|
return [field for field in fields if field in self.fields]
|
||||||
|
|
||||||
|
|
||||||
|
@ -59,6 +61,6 @@ class EpisodeAdmin(PageAdmin):
|
||||||
search_fields = PageAdmin.search_fields + ('parent__title',)
|
search_fields = PageAdmin.search_fields + ('parent__title',)
|
||||||
# readonly_fields = ('parent',)
|
# readonly_fields = ('parent',)
|
||||||
|
|
||||||
inlines = [TracksInline, SoundInline, DiffusionInline]
|
inlines = [TrackInline, SoundInline, DiffusionInline]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -33,13 +33,13 @@ class BasePageAdmin(admin.ModelAdmin):
|
||||||
prepopulated_filters = ('parent',)
|
prepopulated_filters = ('parent',)
|
||||||
|
|
||||||
search_fields = ('title',)
|
search_fields = ('title',)
|
||||||
|
|
||||||
fieldsets = [
|
fieldsets = [
|
||||||
('', {
|
('', {
|
||||||
'fields': ['title', 'slug', 'cover', 'content'],
|
'fields': ['title', 'slug', 'cover', 'content'],
|
||||||
}),
|
}),
|
||||||
(_('Publication Settings'), {
|
(_('Publication Settings'), {
|
||||||
'fields': ['status', 'parent'],
|
'fields': ['status', 'parent'],
|
||||||
# 'classes': ('collapse',),
|
|
||||||
}),
|
}),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -55,12 +55,11 @@ class BasePageAdmin(admin.ModelAdmin):
|
||||||
data['parent'] = filters.get('parent', None)
|
data['parent'] = filters.get('parent', None)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def get_common_context(self, query, extra_context=None):
|
def _get_common_context(self, query, extra_context=None):
|
||||||
extra_context = extra_context or {}
|
extra_context = extra_context or {}
|
||||||
parent = query.get('parent', None)
|
parent = query.get('parent', None)
|
||||||
extra_context['parent'] = None if parent is None else \
|
extra_context['parent'] = None if parent is None else \
|
||||||
Page.objects.get_subclass(id=parent)
|
Page.objects.get_subclass(id=parent)
|
||||||
|
|
||||||
return extra_context
|
return extra_context
|
||||||
|
|
||||||
def render_change_form(self, request, context, *args, **kwargs):
|
def render_change_form(self, request, context, *args, **kwargs):
|
||||||
|
@ -70,11 +69,11 @@ class BasePageAdmin(admin.ModelAdmin):
|
||||||
|
|
||||||
def add_view(self, request, form_url='', extra_context=None):
|
def add_view(self, request, form_url='', extra_context=None):
|
||||||
filters = QueryDict(request.GET.get('_changelist_filters', ''))
|
filters = QueryDict(request.GET.get('_changelist_filters', ''))
|
||||||
extra_context = self.get_common_context(filters, extra_context)
|
extra_context = self._get_common_context(filters, extra_context)
|
||||||
return super().add_view(request, form_url, extra_context)
|
return super().add_view(request, form_url, extra_context)
|
||||||
|
|
||||||
def changelist_view(self, request, extra_context=None):
|
def changelist_view(self, request, extra_context=None):
|
||||||
extra_context = self.get_common_context(request.GET, extra_context)
|
extra_context = self._get_common_context(request.GET, extra_context)
|
||||||
return super().changelist_view(request, extra_context)
|
return super().changelist_view(request, extra_context)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from copy import deepcopy
|
from copy import copy
|
||||||
|
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
@ -28,18 +28,21 @@ class ProgramAdmin(PageAdmin):
|
||||||
|
|
||||||
list_display = PageAdmin.list_display + ('schedule', 'station', 'active')
|
list_display = PageAdmin.list_display + ('schedule', 'station', 'active')
|
||||||
list_filter = PageAdmin.list_filter + ('station', 'active')
|
list_filter = PageAdmin.list_filter + ('station', 'active')
|
||||||
fieldsets = deepcopy(PageAdmin.fieldsets) + [
|
|
||||||
(_('Program Settings'), {
|
|
||||||
'fields': ['active', 'station', 'sync'],
|
|
||||||
'classes': ('collapse',),
|
|
||||||
})
|
|
||||||
]
|
|
||||||
|
|
||||||
prepopulated_fields = {'slug': ('title',)}
|
prepopulated_fields = {'slug': ('title',)}
|
||||||
search_fields = ['title']
|
search_fields = ('title',)
|
||||||
|
|
||||||
inlines = [ScheduleInline, StreamInline]
|
inlines = [ScheduleInline, StreamInline]
|
||||||
|
|
||||||
|
def get_fieldsets(self, request, obj=None):
|
||||||
|
fields = super().get_fieldsets(request, obj)
|
||||||
|
if request.user.has_perm('aircox.program.scheduling'):
|
||||||
|
fields = fields + [
|
||||||
|
(_('Program Settings'), {
|
||||||
|
'fields': ['active', 'station', 'sync'],
|
||||||
|
})
|
||||||
|
]
|
||||||
|
return fields
|
||||||
|
|
||||||
|
|
||||||
@admin.register(Schedule)
|
@admin.register(Schedule)
|
||||||
class ScheduleAdmin(admin.ModelAdmin):
|
class ScheduleAdmin(admin.ModelAdmin):
|
||||||
|
|
|
@ -6,15 +6,18 @@ from adminsortable2.admin import SortableInlineAdminMixin
|
||||||
from ..models import Sound, Track
|
from ..models import Sound, Track
|
||||||
|
|
||||||
|
|
||||||
class TracksInline(SortableInlineAdminMixin, admin.TabularInline):
|
class TrackInline(SortableInlineAdminMixin, admin.TabularInline):
|
||||||
template = 'admin/aircox/playlist_inline.html'
|
template = 'admin/aircox/playlist_inline.html'
|
||||||
model = Track
|
model = Track
|
||||||
extra = 0
|
extra = 0
|
||||||
fields = ('position', 'artist', 'title', 'info', 'timestamp', 'tags')
|
fields = ('position', 'artist', 'title', 'info', 'tags')
|
||||||
|
|
||||||
list_display = ['artist', 'title', 'tags', 'related']
|
list_display = ['artist', 'title', 'tags', 'related']
|
||||||
list_filter = ['artist', 'title', 'tags']
|
list_filter = ['artist', 'title', 'tags']
|
||||||
|
|
||||||
|
class SoundTrackInline(TrackInline):
|
||||||
|
fields = TrackInline.fields + ('timestamp',)
|
||||||
|
|
||||||
|
|
||||||
class SoundInline(admin.TabularInline):
|
class SoundInline(admin.TabularInline):
|
||||||
model = Sound
|
model = Sound
|
||||||
|
@ -44,7 +47,7 @@ class SoundAdmin(admin.ModelAdmin):
|
||||||
(None, {'fields': ['is_good_quality']})
|
(None, {'fields': ['is_good_quality']})
|
||||||
]
|
]
|
||||||
readonly_fields = ('path', 'duration',)
|
readonly_fields = ('path', 'duration',)
|
||||||
inlines = [TracksInline]
|
inlines = [SoundTrackInline]
|
||||||
|
|
||||||
|
|
||||||
@admin.register(Track)
|
@admin.register(Track)
|
||||||
|
|
Binary file not shown.
|
@ -87,7 +87,7 @@ msgstr "Épisodes"
|
||||||
|
|
||||||
#: models/episode.py:140 models/log.py:186
|
#: models/episode.py:140 models/log.py:186
|
||||||
msgid "on air"
|
msgid "on air"
|
||||||
msgstr "a l'antenne"
|
msgstr "à l'antenne"
|
||||||
|
|
||||||
#: models/episode.py:141
|
#: models/episode.py:141
|
||||||
msgid "not confirmed"
|
msgid "not confirmed"
|
||||||
|
@ -312,8 +312,7 @@ msgstr "synchroniser"
|
||||||
|
|
||||||
#: models/program.py:63
|
#: models/program.py:63
|
||||||
msgid "update later diffusions according to schedule changes"
|
msgid "update later diffusions according to schedule changes"
|
||||||
msgstr ""
|
msgstr "met à jour les diffusions à venir lorsque l'horaire change"
|
||||||
"mettre à jour les diffusions suivantes selon les changements de l'horaire"
|
|
||||||
|
|
||||||
#: models/program.py:126 templates/admin/base.html:59
|
#: models/program.py:126 templates/admin/base.html:59
|
||||||
msgid "Programs"
|
msgid "Programs"
|
||||||
|
|
|
@ -38,7 +38,7 @@ urls = [
|
||||||
# path('', views.PageDetailView.as_view(model=models.Article),
|
# path('', views.PageDetailView.as_view(model=models.Article),
|
||||||
# name='home'),
|
# name='home'),
|
||||||
path(_('articles/'),
|
path(_('articles/'),
|
||||||
views.ArticleListView.as_view(model=models.Article, is_static=False),
|
views.ArticleListView.as_view(model=models.Article),
|
||||||
name='article-list'),
|
name='article-list'),
|
||||||
path(_('articles/<slug:slug>/'),
|
path(_('articles/<slug:slug>/'),
|
||||||
views.ArticleDetailView.as_view(),
|
views.ArticleDetailView.as_view(),
|
||||||
|
|
|
@ -19,11 +19,7 @@ class ArticleDetailView(PageDetailView):
|
||||||
class ArticleListView(PageListView):
|
class ArticleListView(PageListView):
|
||||||
model = Article
|
model = Article
|
||||||
has_headline = True
|
has_headline = True
|
||||||
is_static = False
|
|
||||||
parent_model = Program
|
parent_model = Program
|
||||||
attach_to_value = StaticPage.ATTACH_TO_ARTICLES
|
attach_to_value = StaticPage.ATTACH_TO_ARTICLES
|
||||||
|
|
||||||
def get_queryset(self):
|
|
||||||
return super().get_queryset().filter(is_static=self.is_static)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user