From 30d6e2c95eaeba816b54b379f05a43b7fb429811 Mon Sep 17 00:00:00 2001 From: Nicolas Margulies Date: Tue, 19 Sep 2023 15:07:30 +0200 Subject: [PATCH] Added trusts to note admin site --- apps/note/admin.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/apps/note/admin.py b/apps/note/admin.py index eb0f0f3c..8d081d90 100644 --- a/apps/note/admin.py +++ b/apps/note/admin.py @@ -7,7 +7,7 @@ from polymorphic.admin import PolymorphicChildModelAdmin, \ PolymorphicChildModelFilter, PolymorphicParentModelAdmin from note_kfet.admin import admin_site -from .models.notes import Alias, Note, NoteClub, NoteSpecial, NoteUser +from .models.notes import Alias, Note, NoteClub, NoteSpecial, NoteUser, Trust from .models.transactions import Transaction, TemplateCategory, TransactionTemplate, \ RecurrentTransaction, MembershipTransaction, SpecialTransaction from .templatetags.pretty_money import pretty_money @@ -21,6 +21,16 @@ class AliasInlines(admin.TabularInline): model = Alias +class TrustInlines(admin.TabularInline): + """ + Define trusts when editing the trusting note + """ + model = Trust + fk_name = "trusting" + extra = 0 + readonly_fields = ("trusted",) + + @admin.register(Note, site=admin_site) class NoteAdmin(PolymorphicParentModelAdmin): """ @@ -92,7 +102,7 @@ class NoteUserAdmin(PolymorphicChildModelAdmin): """ Child for an user note, see NoteAdmin """ - inlines = (AliasInlines,) + inlines = (AliasInlines, TrustInlines) # We can't change user after creation or the balance readonly_fields = ('user', 'balance')