from django.contrib import admin from .models import OdyseeChannel, OdyseeRelease, Tag, TaggingRule # Register your models here. @admin.register(OdyseeChannel) class OdyseeChannelAdmin(admin.ModelAdmin): list_display = ['name', 'handle', 'get_tags', 'description', 'id'] search_fields = ['name', 'description', 'handle'] ordering = ['name'] list_filter = ['tags'] def get_tags(self, obj): return ", ".join([str(tag) for tag in obj.tags.all()]) get_tags.short_description = "Tags" @admin.register(OdyseeRelease) class OdyseeReleaseAdmin(admin.ModelAdmin): list_display = ['name', 'channel', 'released', 'get_tags', 'get_inherited_tags'] search_fields = ['name', 'url', 'filehash'] ordering = ['channel', 'name', 'released'] list_filter = ['channel', 'tags', 'released'] def get_tags(self, obj): return ", ".join([str(tag) for tag in obj.tags.all()]) get_tags.short_description = "Tags" def get_inherited_tags(self, obj): return ", ".join([str(tag) for tag in obj.channel.tags.all()]) pass get_inherited_tags.short_description = "Inherited Tags" @admin.register(Tag) class TagAdmin(admin.ModelAdmin): list_display = ['name', 'description', 'id'] search_fields = ['name'] ordering = ['name'] @admin.register(TaggingRule) class TaggingRuleAdmin(admin.ModelAdmin): list_display = ['name', 'tag', 'title_regex', 'description_regex', 'required_tag', 'id'] search_fields = ['name', 'tag'] ordering = ['tag', 'name'] list_filter = ['tag', 'required_tag']