From f5c0b8eaaa48cb9f0b56b3d9cd09d0a03c4aa839 Mon Sep 17 00:00:00 2001 From: Tehom Date: Sun, 30 Oct 2016 06:29:47 -0400 Subject: [PATCH] Small changes to make tag admin usable - needed to have a search function and list filter since the number of aliases can make finding tags otherwise impossible. Put in similar functionality to AttributeInline for TagInline. --- evennia/typeclasses/admin.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/evennia/typeclasses/admin.py b/evennia/typeclasses/admin.py index c0b995f19a..2f326a9b74 100644 --- a/evennia/typeclasses/admin.py +++ b/evennia/typeclasses/admin.py @@ -9,7 +9,10 @@ class TagAdmin(admin.ModelAdmin): A django Admin wrapper for Tags. """ - fields = ('db_key', 'db_category', 'db_data') + search_fields = ('db_key', 'db_category', 'db_tagtype') + list_display = ('db_key', 'db_category', 'db_tagtype', 'db_data') + fields = ('db_key', 'db_category', 'db_tagtype', 'db_data') + list_filter = ('db_tagtype',) class TagInline(admin.TabularInline): @@ -19,8 +22,33 @@ class TagInline(admin.TabularInline): """ # Set this to the through model of your desired M2M when subclassing. model = None + fields = ('tag', 'key', 'category', 'data', 'tagtype') raw_id_fields = ('tag',) + readonly_fields = ('key', 'category', 'data', 'tagtype') extra = 0 + def key(self, instance): + if not instance.id: + return "Not yet set or saved." + return '%s' % ( + reverse("admin:typeclasses_tag_change", + args=[instance.tag.id]), + instance.tag.db_key) + key.allow_tags = True + + def category(self, instance): + if not instance.id: + return "Not yet set or saved." + return instance.tag.db_category + + def data(self, instance): + if not instance.id: + return "Not yet set or saved." + return instance.tag.db_data + + def tagtype(self, instance): + if not instance.id: + return "Not yet set or saved." + return instance.tag.db_tagtype class AttributeInline(admin.TabularInline):