From 645a2ac1c586bb4612b08f0fffca14f6b7e8bafa Mon Sep 17 00:00:00 2001 From: James Gordon Date: Sun, 24 Sep 2017 16:43:20 -0500 Subject: [PATCH] When merging person, coerce preserved Candidacy to OCDCandidacyProxy instance. --- calaccess_processed/models/proxies/opencivicdata/people.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/calaccess_processed/models/proxies/opencivicdata/people.py b/calaccess_processed/models/proxies/opencivicdata/people.py index 26bd5b26..77903b79 100644 --- a/calaccess_processed/models/proxies/opencivicdata/people.py +++ b/calaccess_processed/models/proxies/opencivicdata/people.py @@ -12,8 +12,8 @@ PersonIdentifier, PersonName, ) -from .base import OCDProxyModelMixin from postgres_copy import CopyQuerySet +from .base import OCDProxyModelMixin class OCDPersonManager(models.Manager): @@ -71,6 +71,7 @@ def merge(self, persons): Return the merged Person object. """ + from calaccess_processed.models import OCDCandidacyProxy # each person will be merged into this one keep = persons.pop(0) @@ -111,6 +112,8 @@ def merge(self, persons): else: cand_to_keep = cands.latest('filed_date') + cand_to_keep.__class__ = OCDCandidacyProxy + # loop over all the other candidacies in the group for cand_to_discard in cands.exclude(id=cand_to_keep.id).all(): # assuming there's nothing else to preserve in extras