forked from rc/aircox
'Programs' menu in back-office explores instead of edits
This commit is contained in:
parent
b10536efca
commit
3c6912eb9f
|
@ -28,8 +28,9 @@ class DiffusionAdmin(ModelAdmin):
|
||||||
menu_label = _('Diffusions')
|
menu_label = _('Diffusions')
|
||||||
menu_icon = 'date'
|
menu_icon = 'date'
|
||||||
menu_order = 200
|
menu_order = 200
|
||||||
list_display = ('program', 'start', 'end', 'frequency', 'initial')
|
list_display = ('program', 'start', 'end', 'type', 'initial')
|
||||||
list_filter = ('frequency', 'start', 'program')
|
list_filter = ('program', 'start', 'type')
|
||||||
|
search_fields = ('program__name', 'start')
|
||||||
|
|
||||||
class ScheduleAdmin(ModelAdmin):
|
class ScheduleAdmin(ModelAdmin):
|
||||||
model = aircox.models.Schedule
|
model = aircox.models.Schedule
|
||||||
|
@ -54,7 +55,6 @@ class AdvancedAdminGroup(ModelAdminGroup):
|
||||||
|
|
||||||
modeladmin_register(AdvancedAdminGroup)
|
modeladmin_register(AdvancedAdminGroup)
|
||||||
|
|
||||||
|
|
||||||
class SoundAdmin(ModelAdmin):
|
class SoundAdmin(ModelAdmin):
|
||||||
model = aircox.models.Sound
|
model = aircox.models.Sound
|
||||||
menu_label = _('Sounds')
|
menu_label = _('Sounds')
|
||||||
|
@ -79,6 +79,10 @@ def editor_css():
|
||||||
|
|
||||||
class GenericMenu(Menu):
|
class GenericMenu(Menu):
|
||||||
page_model = models.Publication
|
page_model = models.Publication
|
||||||
|
explore = False
|
||||||
|
"""
|
||||||
|
If True, show page explorer instead of page editor.
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__('')
|
super().__init__('')
|
||||||
|
@ -94,7 +98,9 @@ class GenericMenu(Menu):
|
||||||
|
|
||||||
def get_page_url(self, page_model, item):
|
def get_page_url(self, page_model, item):
|
||||||
if item.page.count():
|
if item.page.count():
|
||||||
return reverse('wagtailadmin_pages:edit', args=[item.page.first().id])
|
name = 'wagtailadmin_explore' \
|
||||||
|
if self.explore else 'wagtailadmin_pages:edit'
|
||||||
|
return reverse(name, args=[item.page.first().id])
|
||||||
|
|
||||||
parent_page = self.get_parent(item)
|
parent_page = self.get_parent(item)
|
||||||
if not parent_page:
|
if not parent_page:
|
||||||
|
@ -152,6 +158,7 @@ class ProgramsMenu(GenericMenu):
|
||||||
Menu to display all active programs
|
Menu to display all active programs
|
||||||
"""
|
"""
|
||||||
page_model = models.DiffusionPage
|
page_model = models.DiffusionPage
|
||||||
|
explore = True
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return aircox.models.Program.objects \
|
return aircox.models.Program.objects \
|
||||||
|
|
Loading…
Reference in New Issue
Block a user