Skip to content

Commit

Permalink
[#680] Hacky solutions for Cordaid script
Browse files Browse the repository at this point in the history
  • Loading branch information
KasperBrandt committed Jul 17, 2014
1 parent 7c182eb commit f504bdd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 5 additions & 1 deletion akvo/rsr/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,11 @@ def save(self, *args, **kwargs):
# Set location as primary location if it is the first location
location_target = self.location_target

if location_target.primary_location is None or location_target.primary_location.pk > self.pk:
try:
if location_target.primary_location is None or location_target.primary_location.pk > self.pk:
location_target.primary_location = self
location_target.save()
except:
location_target.primary_location = self
location_target.save()

Expand Down
5 changes: 4 additions & 1 deletion akvo/scripts/cordaid/pre_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ def create_cats_and_benches(business_units):
log(u"Created bench: {id}, {name}", dict(id=new_bench.id, name=name))
else:
log(u"Found existing bench: {id}, {name}", dict(id=new_bench.id, name=name))
data['category'].benchmarknames.add(new_bench)
try:
data['category'].benchmarknames.add(new_bench)
except:
log(u"Did not find bench: {id}, {name}", dict(id=new_bench.id, name=name))


def import_cordaid_benchmarks(csv_file):
Expand Down

0 comments on commit f504bdd

Please sign in to comment.