From e0cce848506f1a75e6096e8270d854b7aa21b406 Mon Sep 17 00:00:00 2001 From: Henry Doupe Date: Wed, 27 Sep 2017 12:06:29 -0400 Subject: [PATCH] Move assumption param checking to views.py --- deploy/taxbrain_server/celery_tasks.py | 4 +--- templates/taxbrain/results.html | 2 +- webapp/apps/dynamic/views.py | 2 +- webapp/apps/taxbrain/compute.py | 4 +--- webapp/apps/taxbrain/models.py | 3 --- webapp/apps/taxbrain/views.py | 18 ++++-------------- 6 files changed, 8 insertions(+), 25 deletions(-) diff --git a/deploy/taxbrain_server/celery_tasks.py b/deploy/taxbrain_server/celery_tasks.py index ef1c2b18..5477ebb2 100644 --- a/deploy/taxbrain_server/celery_tasks.py +++ b/deploy/taxbrain_server/celery_tasks.py @@ -70,7 +70,6 @@ def dropq_task(year, user_mods, first_budget_year, beh_params, tax_data): user_mods[reform_year].pop(key) user_reform = {"policy": user_mods} print('user_reform', user_reform, user_mods) - reform_style = [True if x else False for x in user_reform] if beh_params: for x, y in beh_params.items(): for z in y.keys(): @@ -93,8 +92,7 @@ def dropq_task(year, user_mods, first_budget_year, beh_params, tax_data): 'mX_bin': mX_bin_i, 'df_bin': df_bin_i, 'pdf_bin': pdf_bin_i, 'cdf_bin': cdf_bin_i, 'fiscal_tot_diffs': fiscal_tot_i, 'fiscal_tot_base': fiscal_tot_i_bl, - 'fiscal_tot_ref': fiscal_tot_i_ref, - 'reform_style': reform_style} + 'fiscal_tot_ref': fiscal_tot_i_ref} #Add taxcalc version to results diff --git a/templates/taxbrain/results.html b/templates/taxbrain/results.html index a406dae9..e5875732 100644 --- a/templates/taxbrain/results.html +++ b/templates/taxbrain/results.html @@ -64,7 +64,7 @@

{% flatblock "taxbrain_pe_results_header" %}

Edit Parameters {% endif %} {% if is_micro %} - {% if not assump_file_contents %} + {% if allow_dyn_links %} {% endif %} {% endif %} diff --git a/webapp/apps/dynamic/views.py b/webapp/apps/dynamic/views.py index ea405a5e..0c41f9c4 100644 --- a/webapp/apps/dynamic/views.py +++ b/webapp/apps/dynamic/views.py @@ -772,7 +772,7 @@ def behavior_results(request, pk): return render_to_response('taxbrain/failed.html') if all([job == 'YES' for job in jobs_ready]): - results, reform_style = dropq_compute.dropq_get_results(normalize(job_ids)) + results = dropq_compute.dropq_get_results(normalize(job_ids)) model.tax_result = results model.creation_date = datetime.datetime.now() model.save() diff --git a/webapp/apps/taxbrain/compute.py b/webapp/apps/taxbrain/compute.py index 923ce53a..9af79fa4 100644 --- a/webapp/apps/taxbrain/compute.py +++ b/webapp/apps/taxbrain/compute.py @@ -235,8 +235,6 @@ def dropq_get_results(self, job_ids, job_failure=False): fiscal_tot_base.update(result['fiscal_tot_base']) fiscal_tot_ref.update(result['fiscal_tot_ref']) - reform_style = ans[0].get('reform_style', None) - if ENFORCE_REMOTE_VERSION_CHECK: versions = [r.get('taxcalc_version', None) for r in ans] @@ -266,7 +264,7 @@ def dropq_get_results(self, job_ids, job_failure=False): 'fiscal_tot_base': fiscal_tot_base, 'fiscal_tot_ref': fiscal_tot_ref} - return results, reform_style + return results def elastic_get_results(self, job_ids): ans = [] diff --git a/webapp/apps/taxbrain/models.py b/webapp/apps/taxbrain/models.py index ccdae9f9..74668714 100644 --- a/webapp/apps/taxbrain/models.py +++ b/webapp/apps/taxbrain/models.py @@ -700,9 +700,6 @@ class TaxSaveInputs(models.Model): # Result tax_result = JSONField(default=None, blank=True, null=True) - # Reform style - reform_style = CommaSeparatedField(default=None, blank=True, null=True) - # JSON input text json_text = models.ForeignKey(JSONReformTaxCalculator, null=True, default=None, blank=True) diff --git a/webapp/apps/taxbrain/views.py b/webapp/apps/taxbrain/views.py index e0981f8c..c0c7a114 100644 --- a/webapp/apps/taxbrain/views.py +++ b/webapp/apps/taxbrain/views.py @@ -735,11 +735,6 @@ def get_result_context(model, request, url): first_year = model.first_year quick_calc = model.quick_calc created_on = model.creation_date - if model.reform_style: - rs = [True if x=='True' else False for x in model.reform_style.split(',')] - allow_dyn_links = True if (len(rs) < 2 or rs[1] is False) else False - else: - allow_dyn_links = True if 'fiscal_tots' in output: # Use new key/value pairs for old data output['fiscal_tot_diffs'] = output['fiscal_tots'] @@ -766,9 +761,9 @@ def get_result_context(model, request, url): if (model.json_text is not None and (model.json_text.raw_reform_text or model.json_text.raw_assumption_text)): - reform_file_contents = model.json_text.reform_text + reform_file_contents = model.json_text.raw_reform_text reform_file_contents = reform_file_contents.replace(" "," ") - assump_file_contents = model.json_text.assumption_text + assump_file_contents = model.json_text.raw_assumption_text assump_file_contents = assump_file_contents.replace(" "," ") else: reform_file_contents = False @@ -794,7 +789,7 @@ def get_result_context(model, request, url): 'is_micro': True, 'reform_file_contents': reform_file_contents, 'assump_file_contents': assump_file_contents, - 'allow_dyn_links': allow_dyn_links, + 'allow_dyn_links': True if not assump_file_contents else False, 'results_type': "static" } return context @@ -861,13 +856,8 @@ def output_detail(request, pk): if all([j == 'YES' for j in jobs_ready]): - results, reform_style = dropq_compute.dropq_get_results(normalize(job_ids)) + results = dropq_compute.dropq_get_results(normalize(job_ids)) model.tax_result = results - if reform_style: - rs = ','.join([str(flag) for flag in reform_style]) - else: - rs = '' - model.reform_style = rs model.creation_date = datetime.datetime.now() model.save() context = get_result_context(model, request, url)