Skip to content

Commit ceab813

Browse files
Merge pull request #1773 from IFRCGo/fix/project-importer
Increase resiliency of Project importer
2 parents ef2ed76 + 8f2dc62 commit ceab813

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

deployments/forms.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,12 @@ def _parse_integer(integer):
174174

175175
# Not enums, but can be used to avoid multiple queries for foreign key id-s
176176
sectors = {t.title.lower(): t.id for t in Sector.objects.all()}
177+
add_to_sectors = dict() # Add the main words of sectors to the definition:
178+
for s in sectors.keys():
179+
tt = s.replace(' and', '').replace(', ', ',').replace(' ', ',').split(',')
180+
for t in tt:
181+
add_to_sectors[t] = sectors[s]
182+
sectors.update(add_to_sectors)
177183
sector_tags = {t.title.lower(): t.id for t in SectorTag.objects.all()}
178184
disaster_types = {t.name.lower(): t.id for t in DisasterType.objects.all()}
179185

@@ -186,6 +192,11 @@ def _parse_integer(integer):
186192
}) if row[c.DISTRICT].lower() not in ['countrywide', ''] else []
187193
reporting_ns_name = row[c.REPORTING_NS].strip()
188194
country_name = row[c.COUNTRY].strip()
195+
# An often misspelled word cleanup:
196+
if reporting_ns_name == 'Turkey':
197+
reporting_ns_name = 'Türkiye'
198+
if country_name == 'Turkey':
199+
country_name = 'Türkiye'
189200
disaster_type_name = row[c.DISASTER_TYPE].strip()
190201
sector_name = row[c.PRIMARY_SECTOR].strip()
191202
tag_names = list({d.strip() for d in filter(

0 commit comments

Comments
 (0)