Skip to content
Snippets Groups Projects
Commit 3c305f10 authored by Todd Dembrey's avatar Todd Dembrey
Browse files

Use a mapping to get the key rather than storing the field name in the database

parent 0c9c7b98
No related branches found
No related tags found
No related merge requests found
...@@ -543,10 +543,17 @@ class ApplicationSubmission(WorkflowHelpers, AbstractFormSubmission): ...@@ -543,10 +543,17 @@ class ApplicationSubmission(WorkflowHelpers, AbstractFormSubmission):
return form_data return form_data
@property
def _key_mapping(self):
return {
field.block_type: field.id
for field in self.form_fields
}
def __getattr__(self, item): def __getattr__(self, item):
# fall back to values defined on the data # fall back to values defined on the data
if item in REQUIRED_BLOCK_NAMES: if item in REQUIRED_BLOCK_NAMES:
return self.get_data()[item] return self.get_data()[self._key_mapping[item]]
raise AttributeError('{} has no attribute "{}"'.format(repr(self), item)) raise AttributeError('{} has no attribute "{}"'.format(repr(self), item))
def __str__(self): def __str__(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment