From 8ad8059fc8288877c7f4b7ec75bfa6d8ce2ecff9 Mon Sep 17 00:00:00 2001 From: Ernesto Rico Schmidt <ernesto@helsinki.at> Date: Tue, 8 Feb 2022 17:07:39 -0400 Subject: [PATCH] Remove program admin. We do everything over the API --- program/admin.py | 98 ------------------------------------------------ 1 file changed, 98 deletions(-) delete mode 100644 program/admin.py diff --git a/program/admin.py b/program/admin.py deleted file mode 100644 index 6d70d0fa..00000000 --- a/program/admin.py +++ /dev/null @@ -1,98 +0,0 @@ -# -# 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) -- GitLab