Skip to content

Commit

Permalink
Add Membership to Person in admin
Browse files Browse the repository at this point in the history
  • Loading branch information
VirginiaDooley committed Sep 25, 2023
1 parent 3e4ed6d commit 4257420
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion ynr/apps/people/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,17 @@ def post(self, request, *args, **kwargs):

class MembershipInline(admin.StackedInline):
extra = 0
can_delete = False
model = Membership
fields = ("party", "get_ballot", "deselected")
readonly_fields = ("party", "get_ballot")

@admin.display(description="Ballot")
def get_ballot(self, obj):
return obj.ballot.ballot_paper_id

def has_add_permission(self, request, obj=None):
return False


class PersonImageInlineForm(forms.ModelForm):
Expand Down Expand Up @@ -104,7 +114,7 @@ class PersonAdmin(admin.ModelAdmin):
"image_preview",
"image_filetype",
)
inlines = [PersonImageInline]
inlines = [PersonImageInline, MembershipInline]

def image_preview(self, obj):
person = Person.objects.get(pk=obj.pk)
Expand Down

0 comments on commit 4257420

Please sign in to comment.