Add an inline to view and edit organisation emalis
authorMagnus Hagander <magnus@hagander.net>
Wed, 16 Sep 2020 17:56:07 +0000 (19:56 +0200)
committerMagnus Hagander <magnus@hagander.net>
Wed, 16 Sep 2020 17:59:18 +0000 (19:59 +0200)
The ability to do this was lost when we moved to multiple emails per
organisation since it's no longer in the main table, so add it back as
an inline.

pgweb/core/admin.py

index 99e397e34254636a4ca9c0b4828ab8434dace156..f5aadfe06420e6264dd5c8874923f9cea933f271 100644 (file)
@@ -2,6 +2,7 @@ from django import forms
 from django.contrib import admin
 
 from pgweb.core.models import Version, OrganisationType, Organisation
+from pgweb.core.models import OrganisationEmail
 from pgweb.core.models import ImportedRSSFeed, ImportedRSSItem
 from pgweb.core.models import ModerationNotification
 
@@ -15,6 +16,10 @@ class OrganisationAdminForm(forms.ModelForm):
         super(OrganisationAdminForm, self).__init__(*args, **kwargs)
 
 
+class OrganisationEmailInline(admin.TabularInline):
+    model = OrganisationEmail
+
+
 class OrganisationAdmin(admin.ModelAdmin):
     form = OrganisationAdminForm
     list_display = ('name', 'approved', 'lastconfirmed',)
@@ -22,6 +27,9 @@ class OrganisationAdmin(admin.ModelAdmin):
     ordering = ('name', )
     search_fields = ('name', )
     autocomplete_fields = ['managers', ]
+    inlines = [
+        OrganisationEmailInline,
+    ]
 
 
 class VersionAdmin(admin.ModelAdmin):