Skip to content

Commit

Permalink
Merge pull request #122 from opencivicdata/fix_person_admin
Browse files Browse the repository at this point in the history
allow for saving of persons by fixing up memberships
  • Loading branch information
jamesturk authored Aug 20, 2019
2 parents ff7e3b5 + 03938c5 commit 010cd72
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions opencivicdata/core/admin/person.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -74,9 +76,8 @@ def get_memberships(self, obj):
more = len(memberships) - SHOW_N
if 0 < more:
html.append('And %d more' % more)
return '<br/>'.join(html)
return mark_safe('<br/>'.join(html))

get_memberships.short_description = 'Memberships'
get_memberships.allow_tags = True

list_display = ('name', 'id', 'get_memberships')

0 comments on commit 010cd72

Please sign in to comment.