Skip to content

Commit

Permalink
Only store model param fields specified by the user
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Doupe committed Feb 22, 2018
1 parent 5f7be9a commit dabbf14
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion webapp/apps/dynamic/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ def get_tax_result(self):

NONPARAM_FIELDS = set(["job_ids", "jobs_not_ready", "first_year",
"tax_result", "raw_input_fields", "input_fields",
"creation_date", "id"])
"creation_date", "id", "raw_input_fields",
"input_fields"])

def set_fields(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion webapp/apps/taxbrain/behaviors.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def set_fields(self, upstream_obj, nonparam_fields=None):
self.raw_input_fields = {}
for field in self._meta.fields:
if (getattr(self, field.attname, None) and
field not in nonparam_fields):
field.name not in nonparam_fields):
self.raw_input_fields[field.name] = getattr(self, field.attname)

param_formatters.amt_fixup(self.raw_input_fields)
Expand Down
3 changes: 2 additions & 1 deletion webapp/apps/taxbrain/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,8 @@ def get_tax_result(self):

NONPARAM_FIELDS = set(["job_ids", "jobs_not_ready", "first_year", "quick_calc",
"tax_result", "raw_input_fields", "input_fields",
"json_text", "error_text", "creation_date", "id"])
"json_text", "error_text", "creation_date", "id",
"raw_input_fields", "input_fields"])

def set_fields(self):
"""
Expand Down
6 changes: 4 additions & 2 deletions webapp/apps/taxbrain/param_formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,10 @@ def parse_fields(param_dict, default_params):
# '3': False
# value_from_datadict unpacks this data:
# https://github.com/django/django/blob/1.9/django/forms/widgets.py#L582-L589
if prepped == 1:
values = meta_param.param_meta["cpi_inflated"]
if prepped is 1:
# no need to pass this to upstream model since they will be
# filled in
continue
else:
values = CPI_WIDGET.value_from_datadict(
{meta_param.param_name: str(prepped)},
Expand Down
1 change: 0 additions & 1 deletion webapp/apps/test_assets/test_param_formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ def test_parse_fields(default_params_Policy):
"_STD_joint": [15000.0,"<"],
"_ID_BenefitCap_Switch_statelocal": [True, False, "<", True, True],
"_ID_Charity_c_cpi": True,
"_ID_Medical_c_cpi": True,
"_SS_Earnings_c_cpi": True
}
assert act == exp
Expand Down

0 comments on commit dabbf14

Please sign in to comment.