Skip to content

Commit

Permalink
Merge pull request #22759 from dimagi/rn_fix_related_location
Browse files Browse the repository at this point in the history
Add clean method for related locations
  • Loading branch information
emord authored Dec 17, 2018
2 parents 8a3ac07 + 6401c45 commit a2cd6bc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion corehq/apps/locations/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,8 +682,12 @@ def clean(self):
if name.startswith('relation_distance_') and value and value < 0:
raise forms.ValidationError("The distance cannot be a negative value")

def clean_related_locations(self):
# Django uses get by default, but related_locations is actually a list
return self.data.getlist('related_locations')

def save(self):
selected_location_ids = self.cleaned_data['related_locations'].split(',')
selected_location_ids = self.cleaned_data['related_locations']
selected_location_ids = set(list(filter(None, selected_location_ids)))

previous_location_ids = self.related_location_ids
Expand Down

0 comments on commit a2cd6bc

Please sign in to comment.