Skip to content

Commit

Permalink
#515 Fix combining batches error reported on 10/28
Browse files Browse the repository at this point in the history
  • Loading branch information
georgehelman committed Nov 16, 2024
1 parent c65fbe6 commit bd17e35
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions dear_petition/petition/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,25 +283,29 @@ class RecordResource(MultiModelResource):

def dehydrate_jurisdiction(self, record):
jurisdiction = getattr(record, "jurisdiction")
return constants.JURISDICTION_MAP[jurisdiction]
return constants.JURISDICTION_MAP.get(jurisdiction, constants.NOT_AVAILABLE)

def hydrate_jurisdiction(self, field, data):
attribute = field.attribute
hydrated_value = constants.NOT_AVAILABLE
for k, v in constants.JURISDICTION_MAP.items():
if v == data[attribute]:
data[attribute] = k
hydrated_value = k
break

data[attribute] = hydrated_value
return data

def dehydrate_sex(self, record):
sex = getattr(record, "sex")
return constants.SEX_CHOICES[sex]
try:
sex_value = constants.SEX_CHOICES[sex]
except:
sex_value = constants.NOT_AVAILABLE
return sex_value

def hydrate_sex(self, field, data):
attribute = field.attribute
data[attribute] = constants.SEX_MAP[data[attribute]]

data[attribute] = constants.SEX_MAP.get(data[attribute], constants.NOT_AVAILABLE)
return data

def get_export_fields(self):
Expand Down

0 comments on commit bd17e35

Please sign in to comment.