Skip to content

Commit

Permalink
When merging person, coerce preserved Candidacy to OCDCandidacyProxy …
Browse files Browse the repository at this point in the history
…instance.
  • Loading branch information
gordonje committed Sep 24, 2017
1 parent 5fc98fe commit 645a2ac
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion calaccess_processed/models/proxies/opencivicdata/people.py
Expand Up @@ -12,8 +12,8 @@
PersonIdentifier,
PersonName,
)
from .base import OCDProxyModelMixin
from postgres_copy import CopyQuerySet
from .base import OCDProxyModelMixin


class OCDPersonManager(models.Manager):
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 645a2ac

Please sign in to comment.