Skip to content
Snippets Groups Projects
Commit 8ad8059f authored by Ernesto Rico Schmidt's avatar Ernesto Rico Schmidt
Browse files

Remove program admin. We do everything over the API

parent 96866e5d
No related branches found
No related tags found
No related merge requests found
#
# steering, Programme/schedule management for AURA
#
# Copyright (C) 2011-2017, 2020, Ernesto Rico Schmidt
# Copyright (C) 2017-2019, Ingo Leindecker
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from django.contrib import admin
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from .models import Language, Type, MusicFocus, Category, Topic, FundingCategory, Host
class ActiveHostsFilter(admin.SimpleListFilter):
title = _("Activity")
parameter_name = 'has_shows_and_schedules'
def lookups(self, request, model_admin):
return (
('yes', _("active")),
('no', _("inactive"))
)
def queryset(self, request, queryset):
if self.value() == 'yes':
return queryset.filter(shows__schedules__until__gt=timezone.now()).distinct()
if self.value() == 'no':
return queryset.filter(shows__schedules__until__lt=timezone.now()).distinct()
class TypeAdmin(admin.ModelAdmin):
list_display = ('type', 'is_active')
list_filter = ('is_active',)
prepopulated_fields = {'slug': ('type',)}
class MusicFocusAdmin(admin.ModelAdmin):
list_display = ('focus', 'abbrev', 'is_active')
list_filter = ('is_active',)
prepopulated_fields = {'slug': ('focus',)}
class CategoryAdmin(admin.ModelAdmin):
list_display = ('category', 'abbrev', 'is_active')
list_filter = ('is_active',)
prepopulated_fields = {'slug': ('category',)}
class LanguageAdmin(admin.ModelAdmin):
list_display = ('name', 'is_active')
list_filter = ('is_active',)
class TopicAdmin(admin.ModelAdmin):
list_display = ('topic', 'abbrev', 'is_active')
list_filter = ('is_active',)
prepopulated_fields = {'slug': ('topic',)}
class FundingCategoryAdmin(admin.ModelAdmin):
list_display = ('fundingcategory', 'abbrev', 'is_active')
list_filter = ('is_active',)
prepopulated_fields = {'slug': ('fundingcategory',)}
class HostAdmin(admin.ModelAdmin):
list_display = ('name', 'email', 'is_active')
list_filter = (ActiveHostsFilter, 'is_active',)
def get_queryset(self, request):
if request.user.is_superuser:
return Host.objects.all()
# Common users only see hosts of shows they own
return Host.objects.filter(shows__in=request.user.shows.all()).distinct()
admin.site.register(Language, LanguageAdmin)
admin.site.register(Type, TypeAdmin)
admin.site.register(MusicFocus, MusicFocusAdmin)
admin.site.register(Category, CategoryAdmin)
admin.site.register(Topic, TopicAdmin)
admin.site.register(FundingCategory, FundingCategoryAdmin)
admin.site.register(Host, HostAdmin)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment