2025-01-18 21:31:19 -06:00
|
|
|
from django.contrib import admin
|
|
|
|
|
2025-01-24 15:47:34 -06:00
|
|
|
from .models import OdyseeChannel, OdyseeRelease, Tag, TaggingRule
|
2025-01-18 23:29:52 -06:00
|
|
|
|
2025-01-23 20:02:28 -06:00
|
|
|
# Register your models here.
|
2025-01-23 21:15:18 -06:00
|
|
|
@admin.register(OdyseeChannel)
|
|
|
|
class OdyseeChannelAdmin(admin.ModelAdmin):
|
2025-01-24 15:11:46 -06:00
|
|
|
list_display = ['name', 'handle', 'get_tags', 'description', 'id']
|
2025-01-23 23:28:01 -06:00
|
|
|
search_fields = ['name', 'description', 'handle']
|
|
|
|
ordering = ['name']
|
2025-01-24 15:08:20 -06:00
|
|
|
list_filter = ['tags']
|
|
|
|
|
|
|
|
def get_tags(self, obj):
|
|
|
|
return ", ".join([str(tag) for tag in obj.tags.all()])
|
|
|
|
get_tags.short_description = "Tags"
|
2025-01-23 21:15:18 -06:00
|
|
|
|
|
|
|
@admin.register(OdyseeRelease)
|
|
|
|
class OdyseeReleaseAdmin(admin.ModelAdmin):
|
2025-01-24 15:47:34 -06:00
|
|
|
list_display = ['name', 'channel', 'released', 'get_tags', 'get_inherited_tags']
|
2025-01-24 03:26:16 -06:00
|
|
|
search_fields = ['name', 'url', 'filehash']
|
2025-01-24 03:07:01 -06:00
|
|
|
ordering = ['channel', 'name', 'released']
|
|
|
|
list_filter = ['channel', 'tags', 'released']
|
2025-01-23 21:15:18 -06:00
|
|
|
|
2025-01-24 14:25:06 -06:00
|
|
|
def get_tags(self, obj):
|
|
|
|
return ", ".join([str(tag) for tag in obj.tags.all()])
|
|
|
|
get_tags.short_description = "Tags"
|
|
|
|
|
2025-01-24 15:47:34 -06:00
|
|
|
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"
|
|
|
|
|
2025-01-23 21:15:18 -06:00
|
|
|
@admin.register(Tag)
|
|
|
|
class TagAdmin(admin.ModelAdmin):
|
|
|
|
list_display = ['name', 'description', 'id']
|
|
|
|
search_fields = ['name']
|
2025-01-23 23:28:01 -06:00
|
|
|
ordering = ['name']
|
2025-01-24 15:47:34 -06:00
|
|
|
|
|
|
|
@admin.register(TaggingRule)
|
|
|
|
class TaggingRuleAdmin(admin.ModelAdmin):
|
2025-01-24 16:41:41 -06:00
|
|
|
list_display = ['name', 'tag', 'title_regex', 'description_regex', 'required_tag', 'id']
|
2025-01-24 15:47:34 -06:00
|
|
|
search_fields = ['name', 'tag']
|
|
|
|
ordering = ['tag', 'name']
|
2025-01-24 16:41:41 -06:00
|
|
|
list_filter = ['tag', 'required_tag']
|