Skip to content

Commit

Permalink
Make sure no SayIt Speaker is associated with a blacklisted PopIt IDs
Browse files Browse the repository at this point in the history
Even if a PopIt ID was blacklisted, a speech might still end up
being associated with that person because there would still be a
Speaker object with the exact name that's being resolved which
has its person attribute set to a Person with the blacklisted
PopIt ID.

This commit makes sure that any Speaker with a person attribute
with a blacklisted PopIt ID has that person attribute set to None
when the ImportJson object is initialized.

Fixes mysociety/pombola#1740
  • Loading branch information
mhl authored and Duncan Parkes committed Nov 30, 2015
1 parent 32664ad commit 2c19858
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions za_hansard/importers/import_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ def __init__(self, instance=None, commit=True, popit_url=None, popit_id_blacklis
self.ai, _ = ApiInstance.objects.get_or_create(url=popit_url)
self.person_cache = {}
self.popit_id_blacklist = set(popit_id_blacklist or ())
# Make sure that there are no speakers associated with
# blacklisted PopIt IDs:
Speaker.objects.filter(person__popit_id__in=self.popit_id_blacklist) \
.update(person=None)

def set_resolver_for_date(self, date_string='', date=None):
self.resolver = ResolvePopitName(date=date, date_string=date_string)
Expand Down

0 comments on commit 2c19858

Please sign in to comment.