From dc4bfcca29b5e062ced730d176c68eef9d5ebcb7 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Fri, 14 May 2021 22:20:49 -0400 Subject: [PATCH] Inline Tool/Task subscriptions in the admin interface --- tasks/admin.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tasks/admin.py b/tasks/admin.py index 2628a1e..f2424f0 100644 --- a/tasks/admin.py +++ b/tasks/admin.py @@ -3,14 +3,24 @@ from markdownx.admin import MarkdownxModelAdmin from .models import Tool, Task, Event, GroupTaskSubscription, GroupToolSubscription -admin.site.register(Tool) + +class GroupTaskSubscriptionInline(admin.TabularInline): + model = GroupTaskSubscription + + +class GroupToolSubscriptionInline(admin.TabularInline): + model = GroupToolSubscription @admin.register(Task) class TaskAdmin(MarkdownxModelAdmin): + inlines = [GroupTaskSubscriptionInline] prepopulated_fields = {"slug": ("name",)} -admin.site.register(GroupTaskSubscription) -admin.site.register(GroupToolSubscription) +@admin.register(Tool) +class ToolAdmin(admin.ModelAdmin): + inlines = [GroupToolSubscriptionInline] + + admin.site.register(Event)