Skip to content

Commit

Permalink
Merge 4335f8f into 560c6fa
Browse files Browse the repository at this point in the history
  • Loading branch information
ropable committed Aug 25, 2017
2 parents 560c6fa + 4335f8f commit cd49b9d
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions prs2/harvester/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,14 @@ def harvest(self):
actions.append('{} LGA {} was not recognised'.format(datetime.now().isoformat(), app['LOCAL_GOVERNMENT']))

# Add triggers to the new referral.
triggers = [i.strip() for i in app['MRSZONE_TEXT'].split(',')]
if 'MRSZONE_TEXT' in app:
triggers = [i.strip() for i in app['MRSZONE_TEXT'].split(',')]
else:
triggers = []
added_trigger = False
for i in triggers:
if DopTrigger.objects.current().filter(name__istartswith=i).exists():
added_trigger = True
new_ref.dop_triggers.add(DopTrigger.objects.current().get(name__istartswith=i))
# A couple of exceptions for DoP triggers follow (specific -> general trigger).
elif i.startswith('BUSH FOREVER SITE'):
if i.startswith('BUSH FOREVER SITE'):
added_trigger = True
new_ref.dop_triggers.add(DopTrigger.objects.get(name='Bush Forever site'))
elif i.startswith('DPW ESTATE'):
Expand All @@ -228,6 +228,10 @@ def harvest(self):
elif i.find('REGIONAL PARK') > -1:
added_trigger = True
new_ref.dop_triggers.add(DopTrigger.objects.get(name='Regional Park'))
# All other triggers (don't use exists() in case of duplicates).
elif DopTrigger.objects.current().filter(name__istartswith=i).count() == 1:
added_trigger = True
new_ref.dop_triggers.add(DopTrigger.objects.current().get(name__istartswith=i))
# If we didn't link any DoP triggers, link the "No Parks and Wildlife trigger" tag.
if not added_trigger:
new_ref.dop_triggers.add(DopTrigger.objects.get(name='No Parks and Wildlife trigger'))
Expand Down

0 comments on commit cd49b9d

Please sign in to comment.