From 03938c58e6b8906cc3c256dc2d9b2a7a3c2c7b78 Mon Sep 17 00:00:00 2001 From: Forest Gregg Date: Mon, 19 Aug 2019 21:21:47 -0500 Subject: [PATCH] allow for saving of persons by fixing up memberships --- opencivicdata/core/admin/person.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/opencivicdata/core/admin/person.py b/opencivicdata/core/admin/person.py index 38a74b2..61ee6ed 100644 --- a/opencivicdata/core/admin/person.py +++ b/opencivicdata/core/admin/person.py @@ -1,5 +1,6 @@ from django.urls import reverse from django.contrib import admin +from django.utils.safestring import mark_safe from .. import models from .base import (ModelAdmin, ReadOnlyTabularInline, IdentifierInline, ContactDetailInline, OtherNameInline) @@ -29,8 +30,9 @@ class PersonSourceInline(ReadOnlyTabularInline): class MembershipInline(ReadOnlyTabularInline): model = models.Membership - readonly_fields = ('id', 'organization', 'post', 'label', 'role', 'start_date',) - fields = readonly_fields + ('end_date',) + readonly_fields = ('organization', 'post', 'label', 'role', 'start_date',) + fields = ('id',) + readonly_fields + ('end_date',) + exclude = ('id',) extra = 0 can_delete = False @@ -74,9 +76,8 @@ def get_memberships(self, obj): more = len(memberships) - SHOW_N if 0 < more: html.append('And %d more' % more) - return '
'.join(html) + return mark_safe('
'.join(html)) get_memberships.short_description = 'Memberships' - get_memberships.allow_tags = True list_display = ('name', 'id', 'get_memberships')