From 4bc7197ef987b0cfd3b5103781c6a65cc2a778b3 Mon Sep 17 00:00:00 2001 From: Henry Doupe Date: Tue, 15 Aug 2017 15:50:49 -0400 Subject: [PATCH 1/5] remove commit reference --- deploy/taxbrain_server/celery_tasks.py | 26 +++++++++++------------ templates/dynamic/elasticity_results.html | 4 ++-- templates/taxbrain/results.html | 2 +- webapp/apps/btax/helpers.py | 3 +-- webapp/apps/btax/views.py | 2 +- webapp/apps/dynamic/compute.py | 2 +- webapp/apps/dynamic/views.py | 10 ++++----- webapp/apps/pages/views.py | 6 ++---- webapp/apps/taxbrain/compute.py | 2 +- webapp/apps/taxbrain/helpers.py | 2 +- webapp/apps/taxbrain/views.py | 2 +- 11 files changed, 29 insertions(+), 32 deletions(-) diff --git a/deploy/taxbrain_server/celery_tasks.py b/deploy/taxbrain_server/celery_tasks.py index 8463bb2d..cee15a6d 100644 --- a/deploy/taxbrain_server/celery_tasks.py +++ b/deploy/taxbrain_server/celery_tasks.py @@ -99,8 +99,8 @@ def dropq_task(year, user_mods, first_budget_year, beh_params, tax_data): #Add taxcalc version to results vinfo = taxcalc._version.get_versions() - results['taxcalc_version'] = vinfo['version'] + '.' + vinfo['full'][:6] - results['dropq_version'] = vinfo['version'] + '.' + vinfo['full'][:6] + results['taxcalc_version'] = vinfo['version'] + results['dropq_version'] = vinfo['version'] json_res = json.dumps(results) return json_res @@ -141,8 +141,8 @@ def elasticity_gdp_task_async(year, user_mods, first_budget_year, elast_params): results = {'elasticity_gdp': gdp_elast_i} #Add taxcalc version to results vinfo = taxcalc._version.get_versions() - results['taxcalc_version'] = vinfo['version'] + '.' + vinfo['full'][:6] - results['dropq_version'] = vinfo['version'] + '.' + vinfo['full'][:6] + results['taxcalc_version'] = vinfo['version'] + results['dropq_version'] = vinfo['version'] json_res = json.dumps(results) return json_res @@ -163,12 +163,12 @@ def ogusa_async(user_mods, ogusa_params, guid): diff_table = taxcalc.dropq.format_macro_results(diff_data) results = {'df_ogusa': diff_table} vinfo = taxcalc._version.get_versions() - results['taxcalc_version'] = vinfo['version'] + '.' + vinfo['full'][:6] - results['dropq_version'] = vinfo['version'] + '.' + vinfo['full'][:6] + results['taxcalc_version'] = vinfo['version'] + results['dropq_version'] = vinfo['version'] #ogusa uses different version convention ogvinfo = ogusa._version.get_versions() - ogusa_version = ".".join([ogvinfo['version'], ogvinfo['full-revisionid'][:6]]) + ogusa_version = ogvinfo['version'] results['ogusa_version'] = ogusa_version json_res = json.dumps(results) return json_res @@ -181,10 +181,10 @@ def btax_async(user_mods): results.update(runner_json_tables(**user_mods)) #Add taxcalc version to results vinfo = taxcalc._version.get_versions() - results['taxcalc_version'] = vinfo['version'] + '.' + vinfo['full'][:6] - results['dropq_version'] = vinfo['version'] + '.' + vinfo['full'][:6] + results['taxcalc_version'] = vinfo['version'] + results['dropq_version'] = vinfo['version'] binfo = btax._version.get_versions() - results['btax_version'] = binfo['version'] + '.' + binfo['full-revisionid'][:6] + results['btax_version'] = binfo['version'] return json.dumps(results) @@ -200,13 +200,13 @@ def example_async(): #Add version to results vinfo = taxcalc._version.get_versions() - results['taxcalc_version'] = vinfo['version'] + '.' + vinfo['full'][:6] + results['taxcalc_version'] = vinfo['version'] dqvinfo = taxcalc.dropq._version.get_versions() - results['dropq_version'] = vinfo['version'] + '.' + dqvinfo['full'][:6] + results['dropq_version'] = vinfo['version'] #ogusa uses different version convention ogvinfo = ogusa._version.get_versions() - ogusa_version = ".".join([ogvinfo['version'], ogvinfo['full-revisionid'][:6]]) + ogusa_version = ogvinfo['version'] results['ogusa_version'] = ogusa_version json_res = json.dumps(results) return json_res diff --git a/templates/dynamic/elasticity_results.html b/templates/dynamic/elasticity_results.html index 566fed3a..6b409fa4 100644 --- a/templates/dynamic/elasticity_results.html +++ b/templates/dynamic/elasticity_results.html @@ -38,7 +38,7 @@

Code Build

- +

{% flatblock "elasticity_results_header" %}

@@ -59,7 +59,7 @@

{% flatblock "elasticity_results_header" %}

-

These results were generated on {{ created_on|date:"D, M jS Y \a\t g:iA" }} using version {{ unique_url.taxcalc_vers }} TaxBrain. (ID: 10045)

+

These results were generated on {{ created_on|date:"D, M jS Y \a\t g:iA" }} using version {{ unique_url.taxcalc_vers }} TaxBrain.

The microsimulation upon which this dynamic simulation was based can be found here

Edit Parameters diff --git a/templates/taxbrain/results.html b/templates/taxbrain/results.html index 063c7eab..12571e0f 100644 --- a/templates/taxbrain/results.html +++ b/templates/taxbrain/results.html @@ -47,7 +47,7 @@

{% flatblock "taxbrain_static_results_header" %}

{% flatblock "taxbrain_pe_results_header" %}

{% endif %} -

These results were generated on {{ created_on|date:"D, M jS Y \a\t g:iA" }} using version {{ unique_url.taxcalc_vers }} TaxBrain. (ID: 10045)

+

These results were generated on {{ created_on|date:"D, M jS Y \a\t g:iA" }} using version {{ unique_url.taxcalc_vers }} TaxBrain.

{% if quick_calc %}

This calculation used only 2% of the available data and only calculated revenues for one year instead of ten. For the full results, click here

diff --git a/webapp/apps/btax/helpers.py b/webapp/apps/btax/helpers.py index 4a2cac26..ac20c52e 100644 --- a/webapp/apps/btax/helpers.py +++ b/webapp/apps/btax/helpers.py @@ -39,7 +39,7 @@ BTAX_VERSION_INFO = btax._version.get_versions() -BTAX_VERSION = ".".join([BTAX_VERSION_INFO['version'], BTAX_VERSION_INFO['full-revisionid'][:6]]) +BTAX_VERSION = BTAX_VERSION_INFO['version'] # @@ -210,4 +210,3 @@ def group_args_to_btax_depr(btax_default_params, asset_yr_str): ) return depr_argument_groups - diff --git a/webapp/apps/btax/views.py b/webapp/apps/btax/views.py index ec38836c..950fde55 100644 --- a/webapp/apps/btax/views.py +++ b/webapp/apps/btax/views.py @@ -55,7 +55,7 @@ BTAX_VERSION_INFO = btax._version.get_versions() -BTAX_VERSION = ".".join([BTAX_VERSION_INFO['version'], BTAX_VERSION_INFO['full-revisionid'][:6]]) +BTAX_VERSION = BTAX_VERSION_INFO['version'] JOB_PROC_TIME_IN_SECONDS = 30 diff --git a/webapp/apps/dynamic/compute.py b/webapp/apps/dynamic/compute.py index eb0ff820..cb394685 100644 --- a/webapp/apps/dynamic/compute.py +++ b/webapp/apps/dynamic/compute.py @@ -11,7 +11,7 @@ from ..constants import START_YEAR dqversion_info = taxcalc._version.get_versions() -dropq_version = ".".join([dqversion_info['version'], dqversion_info['full'][:6]]) +dropq_version = dqversion_info['version'] NUM_BUDGET_YEARS = int(os.environ.get('NUM_BUDGET_YEARS', 10)) #Hard fail on lack of dropq workers dropq_workers = os.environ.get('DROPQ_WORKERS', '') diff --git a/webapp/apps/dynamic/views.py b/webapp/apps/dynamic/views.py index a80d9029..7d6f0eb8 100644 --- a/webapp/apps/dynamic/views.py +++ b/webapp/apps/dynamic/views.py @@ -28,7 +28,7 @@ from django import forms from djqscsv import render_to_csv_response -from .forms import (DynamicInputsModelForm, DynamicBehavioralInputsModelForm, +from .forms import (DynamicInputsModelForm, DynamicBehavioralInputsModelForm, has_field_errors, DynamicElasticityInputsModelForm) from .models import (DynamicSaveInputs, DynamicOutputUrl, DynamicBehaviorSaveInputs, DynamicBehaviorOutputUrl, @@ -60,7 +60,7 @@ tcversion_info = taxcalc._version.get_versions() -taxcalc_version = ".".join([tcversion_info['version'], tcversion_info['full'][:6]]) +taxcalc_version = tcversion_info['version'] version_path = os.path.join(os.path.split(__file__)[0], "ogusa_version.json") with open(version_path, "r") as f: @@ -210,7 +210,7 @@ def dynamic_behavioral(request, pk): # get macrosim data from form worker_data = {k:v for k, v in curr_dict.items() if v not in (u'', None, [])} - #get microsim data + #get microsim data outputsurl = OutputUrl.objects.get(pk=pk) model.micro_sim = outputsurl taxbrain_model = outputsurl.unique_inputs @@ -302,7 +302,7 @@ def dynamic_behavioral(request, pk): def dynamic_elasticities(request, pk): """ - This view handles the dynamic macro elasticities input page and + This view handles the dynamic macro elasticities input page and calls the function that handles the calculation on the inputs. """ @@ -342,7 +342,7 @@ def dynamic_elasticities(request, pk): # get macrosim data from form worker_data = {k:v for k, v in curr_dict.items() if v not in (u'', None, [])} - #get microsim data + #get microsim data outputsurl = OutputUrl.objects.get(pk=pk) model.micro_sim = outputsurl taxbrain_model = outputsurl.unique_inputs diff --git a/webapp/apps/pages/views.py b/webapp/apps/pages/views.py index 24709836..96554c46 100644 --- a/webapp/apps/pages/views.py +++ b/webapp/apps/pages/views.py @@ -17,10 +17,8 @@ BTAX_VERSION_INFO = btax._version.get_versions() TAXCALC_VERSION_INFO = taxcalc._version.get_versions() -BTAX_VERSION = ".".join([BTAX_VERSION_INFO['version'], - BTAX_VERSION_INFO['full-revisionid'][:6]]) -TAXCALC_VERSION = ".".join([TAXCALC_VERSION_INFO['version'], - TAXCALC_VERSION_INFO['full'][:6]]) +BTAX_VERSION = BTAX_VERSION_INFO['version'] +TAXCALC_VERSION = TAXCALC_VERSION_INFO['version'] BLOG_URL = os.environ.get('BLOG_URL', 'www.ospc.org') EMAIL_DEFAULT = '1' diff --git a/webapp/apps/taxbrain/compute.py b/webapp/apps/taxbrain/compute.py index ca7c1991..426de0e9 100644 --- a/webapp/apps/taxbrain/compute.py +++ b/webapp/apps/taxbrain/compute.py @@ -11,7 +11,7 @@ requests_mock.Mocker.TEST_PREFIX = 'dropq' dqversion_info = taxcalc._version.get_versions() -dropq_version = ".".join([dqversion_info['version'], dqversion_info['full'][:6]]) +dropq_version = dqversion_info['version'] NUM_BUDGET_YEARS = int(os.environ.get('NUM_BUDGET_YEARS', 10)) NUM_BUDGET_YEARS_QUICK = int(os.environ.get('NUM_BUDGET_YEARS_QUICK', 1)) #Hard fail on lack of dropq workers diff --git a/webapp/apps/taxbrain/helpers.py b/webapp/apps/taxbrain/helpers.py index cfde88bf..e790086f 100644 --- a/webapp/apps/taxbrain/helpers.py +++ b/webapp/apps/taxbrain/helpers.py @@ -139,7 +139,7 @@ def default_taxcalc_data(cls, start_year, metadata=False): # tcversion_info = taxcalc._version.get_versions() -taxcalc_version = ".".join([tcversion_info['version'], tcversion_info['full'][:6]]) +taxcalc_version = tcversion_info['version'] TAXCALC_COMING_SOON_FIELDS = [] diff --git a/webapp/apps/taxbrain/views.py b/webapp/apps/taxbrain/views.py index 15273d40..d8cd0643 100644 --- a/webapp/apps/taxbrain/views.py +++ b/webapp/apps/taxbrain/views.py @@ -54,7 +54,7 @@ tcversion_info = taxcalc._version.get_versions() -taxcalc_version = ".".join([tcversion_info['version'], tcversion_info['full'][:6]]) +taxcalc_version = tcversion_info['version'] JOB_PROC_TIME_IN_SECONDS = 30 def log_ip(request): From 700c3b7248d4c8cf5713c4775e24210522f85935 Mon Sep 17 00:00:00 2001 From: Henry Doupe Date: Tue, 15 Aug 2017 18:17:56 -0400 Subject: [PATCH 2/5] Links point to correct repo version --- templates/btax/input_form.html | 2 +- templates/btax/results.html | 2 +- templates/dynamic/behavior.html | 2 +- templates/dynamic/dynamic_input_form.html | 4 ++-- templates/dynamic/elasticity.html | 2 +- templates/dynamic/elasticity_results.html | 2 +- templates/dynamic/landing.html | 2 +- templates/dynamic/results.html | 2 +- templates/pages/apps.html | 4 ++-- templates/taxbrain/header.html | 4 ++-- templates/taxbrain/input_file.html | 2 +- templates/taxbrain/input_form.html | 2 +- templates/taxbrain/results.html | 2 +- webapp/apps/dynamic/views.py | 3 ++- 14 files changed, 18 insertions(+), 17 deletions(-) diff --git a/templates/btax/input_form.html b/templates/btax/input_form.html index 63f4c7cd..86c0d9f0 100644 --- a/templates/btax/input_form.html +++ b/templates/btax/input_form.html @@ -38,7 +38,7 @@

About Cost of Capital Calculator

diff --git a/templates/btax/results.html b/templates/btax/results.html index 0c4e0715..465375af 100644 --- a/templates/btax/results.html +++ b/templates/btax/results.html @@ -79,7 +79,7 @@

{% flatblock "ccc_results_header" %}

-

These results were generated on {{ created_on|date:"D, M jS Y \a\t g:iA" }}
B-Tax version {{ unique_url.btax_vers }}
Taxcalc version {{ unique_url.taxcalc_vers }}

+

These results were generated on {{ created_on|date:"D, M jS Y \a\t g:iA" }}
B-Tax version {{ unique_url.btax_vers }}
Taxcalc version {{ unique_url.taxcalc_vers }}

Edit Parameters diff --git a/templates/dynamic/behavior.html b/templates/dynamic/behavior.html index e349bbeb..560d9120 100644 --- a/templates/dynamic/behavior.html +++ b/templates/dynamic/behavior.html @@ -35,7 +35,7 @@

About TaxBrain

diff --git a/templates/dynamic/dynamic_input_form.html b/templates/dynamic/dynamic_input_form.html index cbad897a..b90d6f71 100644 --- a/templates/dynamic/dynamic_input_form.html +++ b/templates/dynamic/dynamic_input_form.html @@ -35,8 +35,8 @@

About TaxBrain

diff --git a/templates/dynamic/elasticity.html b/templates/dynamic/elasticity.html index f004b153..4bd02c84 100644 --- a/templates/dynamic/elasticity.html +++ b/templates/dynamic/elasticity.html @@ -35,7 +35,7 @@

About TaxBrain

diff --git a/templates/dynamic/elasticity_results.html b/templates/dynamic/elasticity_results.html index 6b409fa4..9faf7e7f 100644 --- a/templates/dynamic/elasticity_results.html +++ b/templates/dynamic/elasticity_results.html @@ -33,7 +33,7 @@

Our History

diff --git a/templates/dynamic/landing.html b/templates/dynamic/landing.html index 9f3731bb..b14ef3cc 100644 --- a/templates/dynamic/landing.html +++ b/templates/dynamic/landing.html @@ -35,7 +35,7 @@

About TaxBrain

diff --git a/templates/dynamic/results.html b/templates/dynamic/results.html index 5062a7c5..8610d8c6 100644 --- a/templates/dynamic/results.html +++ b/templates/dynamic/results.html @@ -33,7 +33,7 @@

Our History

diff --git a/templates/pages/apps.html b/templates/pages/apps.html index e1a974a4..7b790016 100644 --- a/templates/pages/apps.html +++ b/templates/pages/apps.html @@ -30,8 +30,8 @@

About B-Tax (Cost of Capital)

diff --git a/templates/taxbrain/header.html b/templates/taxbrain/header.html index 71f848d6..b2c79110 100644 --- a/templates/taxbrain/header.html +++ b/templates/taxbrain/header.html @@ -37,7 +37,7 @@

About Cost of Capital Calculator

@@ -51,7 +51,7 @@

Our History

diff --git a/templates/taxbrain/input_file.html b/templates/taxbrain/input_file.html index 7b01a581..6cc5aff8 100644 --- a/templates/taxbrain/input_file.html +++ b/templates/taxbrain/input_file.html @@ -38,7 +38,7 @@

About TaxBrain

diff --git a/templates/taxbrain/input_form.html b/templates/taxbrain/input_form.html index 8f891f5e..dd98e9ad 100644 --- a/templates/taxbrain/input_form.html +++ b/templates/taxbrain/input_form.html @@ -39,7 +39,7 @@

About TaxBrain

diff --git a/templates/taxbrain/results.html b/templates/taxbrain/results.html index 12571e0f..1766a459 100644 --- a/templates/taxbrain/results.html +++ b/templates/taxbrain/results.html @@ -47,7 +47,7 @@

{% flatblock "taxbrain_static_results_header" %}

{% flatblock "taxbrain_pe_results_header" %}

{% endif %} -

These results were generated on {{ created_on|date:"D, M jS Y \a\t g:iA" }} using version {{ unique_url.taxcalc_vers }} TaxBrain.

+

These results were generated on {{ created_on|date:"D, M jS Y \a\t g:iA" }} using version {{ unique_url.taxcalc_vers }} TaxBrain.

{% if quick_calc %}

This calculation used only 2% of the available data and only calculated revenues for one year instead of ten. For the full results, click here

diff --git a/webapp/apps/dynamic/views.py b/webapp/apps/dynamic/views.py index 7d6f0eb8..f0ceb844 100644 --- a/webapp/apps/dynamic/views.py +++ b/webapp/apps/dynamic/views.py @@ -506,7 +506,8 @@ def dynamic_landing(request, pk): 'pk': pk, 'is_authenticated': request.user.is_authenticated(), 'include_ogusa': include_ogusa, - 'start_year': request.GET['start_year'] + 'start_year': request.GET['start_year'], + 'taxcalc_version': taxcalc_version } return render_to_response('dynamic/landing.html', init_context) From f3b972ad5f2e40519565a1353262342b4bc1a824 Mon Sep 17 00:00:00 2001 From: Henry Doupe Date: Fri, 15 Sep 2017 14:04:38 -0400 Subject: [PATCH 3/5] Update version links --- templates/btax/input_form.html | 6 +- templates/btax/results.html | 2 +- templates/dynamic/behavior.html | 7 +- templates/dynamic/dynamic_input_form.html | 12 ++- templates/dynamic/elasticity.html | 7 +- templates/dynamic/elasticity_results.html | 13 +-- templates/dynamic/landing.html | 7 +- templates/dynamic/results.html | 12 ++- templates/taxbrain/header.html | 14 ++- templates/taxbrain/input_file.html | 6 +- templates/taxbrain/input_form.html | 6 +- templates/taxbrain/results.html | 2 +- webapp/apps/btax/models.py | 3 + webapp/apps/btax/tests/test_views.py | 2 +- webapp/apps/btax/views.py | 46 ++++++++-- webapp/apps/dynamic/models.py | 7 ++ webapp/apps/dynamic/views.py | 102 ++++++++++++++-------- webapp/apps/formatters.py | 15 ++++ webapp/apps/taxbrain/models.py | 2 + webapp/apps/taxbrain/views.py | 50 ++++++++--- webapp/settings.py | 2 + 21 files changed, 242 insertions(+), 81 deletions(-) diff --git a/templates/btax/input_form.html b/templates/btax/input_form.html index 86c0d9f0..179268ab 100644 --- a/templates/btax/input_form.html +++ b/templates/btax/input_form.html @@ -37,7 +37,11 @@

About Cost of Capital Calculator

{% flatblock "ccc_what_is_ccc_dropdown" %}
-

Code Build

+

PolicyBrain Code Build

+

Version {{ webapp_version }} - GitHub

+
+ diff --git a/templates/btax/results.html b/templates/btax/results.html index 465375af..0a05c50c 100644 --- a/templates/btax/results.html +++ b/templates/btax/results.html @@ -79,7 +79,7 @@

{% flatblock "ccc_results_header" %}

-

These results were generated on {{ created_on|date:"D, M jS Y \a\t g:iA" }}
B-Tax version {{ unique_url.btax_vers }}
Taxcalc version {{ unique_url.taxcalc_vers }}

+

These results were generated by PolicyBrain version {{ webapp_version }} on {{ created_on|date:"D, M jS Y \a\t g:iA" }} UTC using B-Tax version {{ btax_version }}.

Edit Parameters diff --git a/templates/dynamic/behavior.html b/templates/dynamic/behavior.html index 560d9120..ec44fc53 100644 --- a/templates/dynamic/behavior.html +++ b/templates/dynamic/behavior.html @@ -34,12 +34,15 @@

About TaxBrain

{% flatblock "taxbrain_what_is_taxbrain_dropdown" %}
-

Code Build

+

PolicyBrain Code Build

+

Version {{ webapp_version }} - GitHub

+
+
+

Tax-Calculator Code Build

Version {{ taxcalc_version }} - GitHub

-
{% csrf_token %} diff --git a/templates/dynamic/dynamic_input_form.html b/templates/dynamic/dynamic_input_form.html index b90d6f71..3ebc8905 100644 --- a/templates/dynamic/dynamic_input_form.html +++ b/templates/dynamic/dynamic_input_form.html @@ -34,13 +34,19 @@

About TaxBrain

{% flatblock "taxbrain_what_is_taxbrain_dropdown" %} + +
+

Tax-Calculator Code Build

+

Version {{ taxcalc_version }} - GitHub

+
- {% csrf_token %} diff --git a/templates/dynamic/elasticity.html b/templates/dynamic/elasticity.html index 4bd02c84..45be2b6c 100644 --- a/templates/dynamic/elasticity.html +++ b/templates/dynamic/elasticity.html @@ -34,12 +34,15 @@

About TaxBrain

{% flatblock "taxbrain_what_is_taxbrain_dropdown" %}
-

Code Build

+

PolicyBrain Code Build

+

Version {{ webapp_version }} - GitHub

+
+
+

Tax-Calculator Code Build

Version {{ taxcalc_version }} - GitHub

- {% csrf_token %} diff --git a/templates/dynamic/elasticity_results.html b/templates/dynamic/elasticity_results.html index 9faf7e7f..da65bf4c 100644 --- a/templates/dynamic/elasticity_results.html +++ b/templates/dynamic/elasticity_results.html @@ -28,16 +28,19 @@

TaxBrain

-

Our History

+

About TaxBrain

{% flatblock "taxbrain_what_is_taxbrain_dropdown" %}
+
+

Tax-Calculator Code Build

+

Version {{ taxcalc_version }} - GitHub

-
@@ -59,7 +62,7 @@

{% flatblock "elasticity_results_header" %}

-

These results were generated on {{ created_on|date:"D, M jS Y \a\t g:iA" }} using version {{ unique_url.taxcalc_vers }} TaxBrain.

+

These results were generated by PolicyBrain version {{ webapp_version }} on {{ created_on|date:"D, M jS Y \a\t g:iA" }} UTC using Tax-Calculator version {{ taxcalc_version }}.

The microsimulation upon which this dynamic simulation was based can be found here

Edit Parameters diff --git a/templates/dynamic/landing.html b/templates/dynamic/landing.html index b14ef3cc..168ce4de 100644 --- a/templates/dynamic/landing.html +++ b/templates/dynamic/landing.html @@ -34,12 +34,15 @@

About TaxBrain

{% flatblock "taxbrain_what_is_taxbrain_dropdown" %}
-

Code Build

+

PolicyBrain Code Build

+

Version {{ webapp_version }} - GitHub

+
+
+

Tax-Calculator Code Build

Version {{ taxcalc_version }} - GitHub

- {% csrf_token %} diff --git a/templates/dynamic/results.html b/templates/dynamic/results.html index 8610d8c6..62968e57 100644 --- a/templates/dynamic/results.html +++ b/templates/dynamic/results.html @@ -28,12 +28,16 @@

TaxBrain

-

Our History

+

About TaxBrain

{% flatblock "taxbrain_what_is_taxbrain_dropdown" %}
+
+

Tax-Calculator Code Build

+

Version {{ taxcalc_version }} - GitHub

@@ -43,7 +47,7 @@

Code Build

{% flatblock "dynamic_results_header" %} {{ tables.result_years.0 }} - {{ tables.result_years | last }}

-

These results were generated on {{ created_on|date:"D, M jS Y \a\t g:iA" }} using version {{ ogusa_version }} of the OGUSA package. (ID: 10045)

+

These results were generated by PolicyBrain version {{ webapp_version }} on {{ created_on|date:"D, M jS Y \a\t g:iA" }} UTC using Version {{ ogusa_version }}

The microsimulation upon which this dynamic simulation was based can be found here

diff --git a/templates/taxbrain/header.html b/templates/taxbrain/header.html index b2c79110..51ee46ac 100644 --- a/templates/taxbrain/header.html +++ b/templates/taxbrain/header.html @@ -36,7 +36,11 @@

About Cost of Capital Calculator

{% flatblock "ccc_what_is_ccc_dropdown" %}
-

Code Build

+

PolicyBrain Code Build

+

Version {{ webapp_version }} - GitHub

+
+ @@ -50,8 +54,12 @@

Our History

{% flatblock "taxbrain_what_is_taxbrain_dropdown" %} +
+

Tax-Calculator Code Build

+

Version {{ taxcalc_version }} - GitHub

diff --git a/templates/taxbrain/input_file.html b/templates/taxbrain/input_file.html index 6cc5aff8..9d156d3a 100644 --- a/templates/taxbrain/input_file.html +++ b/templates/taxbrain/input_file.html @@ -37,7 +37,11 @@

About TaxBrain

{% flatblock "taxbrain_what_is_taxbrain_dropdown" %}
-

Code Build

+

PolicyBrain Code Build

+

Version {{ webapp_version }} - GitHub

+
+
+

Tax-Calculator Code Build

Version {{ taxcalc_version }} - GitHub

diff --git a/templates/taxbrain/input_form.html b/templates/taxbrain/input_form.html index dd98e9ad..fa3459a0 100644 --- a/templates/taxbrain/input_form.html +++ b/templates/taxbrain/input_form.html @@ -38,7 +38,11 @@

About TaxBrain

{% flatblock "taxbrain_what_is_taxbrain_dropdown" %}
-

Code Build

+

PolicyBrain Code Build

+

Version {{ webapp_version }} - GitHub

+
+
+

Tax-Calculator Code Build

Version {{ taxcalc_version }} - GitHub

diff --git a/templates/taxbrain/results.html b/templates/taxbrain/results.html index 1766a459..a406dae9 100644 --- a/templates/taxbrain/results.html +++ b/templates/taxbrain/results.html @@ -47,7 +47,7 @@

{% flatblock "taxbrain_static_results_header" %}

{% flatblock "taxbrain_pe_results_header" %}

{% endif %} -

These results were generated on {{ created_on|date:"D, M jS Y \a\t g:iA" }} using version {{ unique_url.taxcalc_vers }} TaxBrain.

+

These results were generated by PolicyBrain version {{ webapp_version }} on {{ created_on|date:"D, M jS Y \a\t g:iA" }} UTC using Tax-Calculator version {{ taxcalc_version }}.

{% if quick_calc %}

This calculation used only 2% of the available data and only calculated revenues for one year instead of ten. For the full results, click here

diff --git a/webapp/apps/btax/models.py b/webapp/apps/btax/models.py index 058eb175..b35d3ec5 100644 --- a/webapp/apps/btax/models.py +++ b/webapp/apps/btax/models.py @@ -141,6 +141,9 @@ class BTaxOutputUrl(models.Model): uuid = UUIDField(auto=True, default=None, null=True) btax_vers = models.CharField(blank=True, default=None, null=True, max_length=50) taxcalc_vers = models.CharField(blank=True, default=None, null=True, max_length=50) + webapp_vers = models.CharField(blank=True, default=None, null=True, + max_length=50) + def get_absolute_url(self): kwargs = { 'pk': self.pk diff --git a/webapp/apps/btax/tests/test_views.py b/webapp/apps/btax/tests/test_views.py index b25b8078..bb698c29 100644 --- a/webapp/apps/btax/tests/test_views.py +++ b/webapp/apps/btax/tests/test_views.py @@ -26,7 +26,7 @@ class BTaxViewsTests(TestCase): expected_results_tokens = ['cost of capital', 'change from reform', 'baseline', 'reform', 'industry', 'asset', 'accommodation', - 'typically financed', 'were generated on'] + 'typically financed', 'were generated by'] def setUp(self): # Every test needs a client. self.client = Client() diff --git a/webapp/apps/btax/views.py b/webapp/apps/btax/views.py index 950fde55..7d578d2d 100644 --- a/webapp/apps/btax/views.py +++ b/webapp/apps/btax/views.py @@ -44,18 +44,30 @@ convert_val, make_bool) from ..taxbrain.views import (benefit_surtax_fixup, - denormalize, normalize,taxcalc_version as TAXCALC_VERSION) + denormalize, normalize) from .compute import DropqComputeBtax, MockComputeBtax, JobFailError from ..constants import (METTR_TOOLTIP, METR_TOOLTIP, COC_TOOLTIP, DPRC_TOOLTIP, START_YEAR, START_YEARS) +from ..formatters import get_version +from django.conf import settings + dropq_compute = DropqComputeBtax() BTAX_VERSION_INFO = btax._version.get_versions() BTAX_VERSION = BTAX_VERSION_INFO['version'] + +WEBAPP_VERSION = settings.WEBAPP_VERSION + + +tcversion_info = taxcalc._version.get_versions() + +TAXCALC_VERSION = tcversion_info['version'] + + JOB_PROC_TIME_IN_SECONDS = 30 @@ -180,6 +192,11 @@ def btax_results(request): pass else: unique_url.taxcalc_vers = TAXCALC_VERSION + if unique_url.webapp_vers is not None: + pass + else: + unique_url.webapp_vers = WEBAPP_VERSION + unique_url.unique_inputs = model unique_url.model_pk = model.pk cur_dt = datetime.datetime.utcnow() @@ -220,6 +237,7 @@ def btax_results(request): 'params': btax_default_params, 'btax_version': BTAX_VERSION, 'taxcalc_version': TAXCALC_VERSION, + 'webapp_version': WEBAPP_VERSION, 'start_years': START_YEARS, 'start_year': start_year, 'has_errors': has_errors, @@ -258,12 +276,18 @@ def edit_btax_results(request, pk): form_btax_input = make_bool_gds_ads(form_btax_input) hover_notes = hover_args_to_btax_depr() + btax_vers_disp = get_version(url, 'btax_vers', BTAX_VERSION) + webapp_vers_disp = get_version(url, 'webapp_vers', WEBAPP_VERSION) + + context_vers_disp = {'btax_version': btax_vers_disp, + 'webapp_version': webapp_vers_disp} + init_context = { 'form': form_btax_input, 'make_bool': make_bool, 'params': btax_default_params, - 'btax_version': BTAX_VERSION, - 'taxcalc_version': TAXCALC_VERSION, + 'btax_version': btax_vers_disp, + 'webapp_version': webapp_vers_disp, 'start_years': START_YEARS, 'start_year': str(start_year), 'has_errors': has_errors, @@ -300,6 +324,7 @@ def generate_mock_results(request): context.update({ 'btax_version':BTAX_VERSION, 'taxcalc_version': TAXCALC_VERSION, + 'webapp_vers': WEBAPP_VERSION, 'table_json': str(mock_json), 'is_btax': True, }) @@ -320,6 +345,12 @@ def output_detail(request, pk): except: raise Http404 + btax_vers_disp = get_version(url, 'btax_vers', BTAX_VERSION) + webapp_vers_disp = get_version(url, 'webapp_vers', WEBAPP_VERSION) + + context_vers_disp = {'btax_version': btax_vers_disp, + 'webapp_version': webapp_vers_disp} + model = url.unique_inputs if model.tax_result: tables = url.unique_inputs.tax_result[0] @@ -337,13 +368,12 @@ def output_detail(request, pk): context.update({ 'locals': locals(), 'unique_url': url, - 'btax_version': BTAX_VERSION, - 'taxcalc_version': TAXCALC_VERSION, 'table_json': json.dumps(tables), 'created_on': created_on, 'first_year': first_year, 'is_btax': True, }) + context.update(context_vers_disp) return render(request, 'btax/results.html', context) else: @@ -406,6 +436,8 @@ def output_detail(request, pk): else: print "rendering not ready yet" - not_ready_data = {'eta': '100', 'is_btax': True} - return render_to_response('btax/not_ready.html', not_ready_data, + context = {'eta': '100', 'is_btax': True} + context.update(context_vers_disp) + print(context) + return render_to_response('btax/not_ready.html', context, context_instance=RequestContext(request)) diff --git a/webapp/apps/dynamic/models.py b/webapp/apps/dynamic/models.py index c4c11f47..b782c6e6 100644 --- a/webapp/apps/dynamic/models.py +++ b/webapp/apps/dynamic/models.py @@ -143,6 +143,8 @@ class DynamicOutputUrl(models.Model): uuid = UUIDField(auto=True, default=None, null=True) ogusa_vers = models.CharField(blank=True, default=None, null=True, max_length=50) + webapp_vers = models.CharField(blank=True, default=None, null=True, + max_length=50) def get_absolute_url(self): kwargs = { @@ -163,6 +165,8 @@ class DynamicBehaviorOutputUrl(models.Model): uuid = UUIDField(auto=True, default=None, null=True) taxcalc_vers = models.CharField(blank=True, default=None, null=True, max_length=50) + webapp_vers = models.CharField(blank=True, default=None, null=True, + max_length=50) def get_absolute_url(self): kwargs = { @@ -183,6 +187,9 @@ class DynamicElasticityOutputUrl(models.Model): uuid = UUIDField(auto=True, default=None, null=True) taxcalc_vers = models.CharField(blank=True, default=None, null=True, max_length=50) + webapp_vers = models.CharField(blank=True, default=None, null=True, + max_length=50) + def get_absolute_url(self): kwargs = { diff --git a/webapp/apps/dynamic/views.py b/webapp/apps/dynamic/views.py index f0ceb844..65e41b69 100644 --- a/webapp/apps/dynamic/views.py +++ b/webapp/apps/dynamic/views.py @@ -56,18 +56,20 @@ ADJUSTED_TOOLTIP, INCOME_BINS_TOOLTIP, INCOME_DECILES_TOOLTIP, START_YEAR, START_YEARS) -from ..formatters import format_dynamic_params +from ..formatters import format_dynamic_params, get_version tcversion_info = taxcalc._version.get_versions() -taxcalc_version = tcversion_info['version'] +TAXCALC_VERSION = tcversion_info['version'] +# TODO: use import ogusa; ogusa.__version__ version_path = os.path.join(os.path.split(__file__)[0], "ogusa_version.json") with open(version_path, "r") as f: ogversion_info = json.load(f) -ogusa_version = ".".join([ogversion_info['version'], - ogversion_info['full-revisionid'][:6]]) +OGUSA_VERSION = ogversion_info['version'] +from django.conf import settings +WEBAPP_VERSION = settings.WEBAPP_VERSION def dynamic_input(request, pk): """ @@ -134,7 +136,7 @@ def dynamic_input(request, pk): int(start_year), microsim_data, pack_up_user_mods=False) - + # TODO: use OutputUrl class if submitted_ids: model.job_ids = denormalize(submitted_ids) model.guids = denormalize(guids) @@ -166,8 +168,9 @@ def dynamic_input(request, pk): init_context = { 'form': form_personal_exemp, 'params': ogusa_default_params, - 'taxcalc_version': taxcalc_version, - 'ogusa_version': ogusa_version, + 'taxcalc_version': TAXCALC_VERSION, + 'ogusa_version': OGUSA_VERSION, + 'webapp_version': WEBAPP_VERSION, 'start_year': start_year, 'pk': pk, 'is_disabled': disabled_flag, @@ -185,7 +188,6 @@ def dynamic_behavioral(request, pk): This view handles the dynamic behavioral input page and calls the function that handles the calculation on the inputs. """ - if request.method=='POST': # Client is attempting to send inputs, validate as form data fields = dict(request.REQUEST) @@ -262,7 +264,12 @@ def dynamic_behavioral(request, pk): if unique_url.taxcalc_vers != None: pass else: - unique_url.taxcalc_vers = taxcalc_version + unique_url.taxcalc_vers = TAXCALC_VERSION + + if unique_url.webapp_vers != None: + pass + else: + unique_url.webapp_vers = WEBAPP_VERSION unique_url.unique_inputs = model unique_url.model_pk = model.pk @@ -289,7 +296,8 @@ def dynamic_behavioral(request, pk): init_context = { 'form': form_personal_exemp, 'params': behavior_default_params, - 'taxcalc_version': taxcalc_version, + 'taxcalc_version': TAXCALC_VERSION, + 'webapp_version': WEBAPP_VERSION, 'start_year': start_year, 'pk': pk } @@ -396,7 +404,12 @@ def dynamic_elasticities(request, pk): if unique_url.taxcalc_vers != None: pass else: - unique_url.taxcalc_vers = taxcalc_version + unique_url.taxcalc_vers = TAXCALC_VERSION + + if unique_url.webapp_vers != None: + pass + else: + unique_url.webapp_vers = WEBAPP_VERSION unique_url.unique_inputs = model unique_url.model_pk = model.pk @@ -421,7 +434,8 @@ def dynamic_elasticities(request, pk): init_context = { 'form': form_personal_exemp, 'params': elasticity_default_params, - 'taxcalc_version': taxcalc_version, + 'taxcalc_version': TAXCALC_VERSION, + 'webapp_version': WEBAPP_VERSION, 'start_year': start_year, 'pk': pk } @@ -451,10 +465,14 @@ def edit_dynamic_behavioral(request, pk): form_personal_exemp = DynamicBehavioralInputsModelForm(first_year=start_year, instance=model) behavior_default_params = default_behavior_parameters(int(start_year)) + taxcalc_vers_disp = get_version(url, 'taxcalc_vers', TAXCALC_VERSION) + webapp_vers_disp = get_version(url, 'webapp_vers', WEBAPP_VERSION) + init_context = { 'form': form_personal_exemp, 'params': behavior_default_params, - 'taxcalc_version': taxcalc_version, + 'taxcalc_version': taxcalc_vers_disp, + 'webapp_vers_disp': webapp_vers_disp, 'start_year': str(start_year), 'pk': model.micro_sim.pk } @@ -482,11 +500,14 @@ def edit_dynamic_elastic(request, pk): form_personal_exemp = DynamicElasticityInputsModelForm(first_year=start_year, instance=model) elasticity_default_params = default_elasticity_parameters(int(start_year)) + taxcalc_vers_disp = get_version(url, 'taxcalc_vers', TAXCALC_VERSION) + webapp_vers_disp = get_version(url, 'webapp_vers', WEBAPP_VERSION) init_context = { 'form': form_personal_exemp, 'params': elasticity_default_params, - 'taxcalc_version': taxcalc_version, + 'taxcalc_version': taxcalc_vers_disp, + 'webapp_vers': webapp_vers_disp, 'start_year': str(start_year), 'pk': model.micro_sim.pk } @@ -507,8 +528,9 @@ def dynamic_landing(request, pk): 'is_authenticated': request.user.is_authenticated(), 'include_ogusa': include_ogusa, 'start_year': request.GET['start_year'], - 'taxcalc_version': taxcalc_version - } + 'taxcalc_version': TAXCALC_VERSION, + 'webapp_version': WEBAPP_VERSION + } return render_to_response('dynamic/landing.html', init_context) @@ -594,11 +616,11 @@ def elastic_results(request, pk): except: raise Http404 - if url.taxcalc_vers != None: - pass - else: - url.taxcalc_vers = taxcalc_version - url.save() + taxcalc_vers_disp = get_version(url, 'taxcalc_vers', TAXCALC_VERSION) + webapp_vers_disp = get_version(url, 'webapp_vers', WEBAPP_VERSION) + + context_vers_disp = {'taxcalc_version': taxcalc_vers_disp, + 'webapp_version': webapp_vers_disp} model = url.unique_inputs if model.tax_result: @@ -612,7 +634,8 @@ def elastic_results(request, pk): context = { 'locals':locals(), 'unique_url':url, - 'taxcalc_version':taxcalc_version, + 'taxcalc_version':taxcalc_vers_disp, + 'webapp_version':webapp_vers_disp, 'tables':tables, 'created_on':created_on, 'first_year':first_year, @@ -681,7 +704,9 @@ def elastic_results(request, pk): else: print "rendering not ready yet" - return render_to_response('dynamic/not_ready.html', {'eta':'100'}, context_instance=RequestContext(request)) + context = {'eta': '100'} + context.update(context_vers_disp) + return render_to_response('dynamic/not_ready.html', context, context_instance=RequestContext(request)) def ogusa_results(request, pk): @@ -693,12 +718,6 @@ def ogusa_results(request, pk): except: raise Http404 - if url.ogusa_vers != None: - pass - else: - url.ogusa_vers = ogusa_version - url.save() - output = url.unique_inputs.tax_result first_year = url.unique_inputs.first_year created_on = url.unique_inputs.creation_date @@ -706,10 +725,16 @@ def ogusa_results(request, pk): hostname = os.environ.get('BASE_IRI', 'http://www.ospc.org') microsim_url = hostname + "/taxbrain/" + str(url.unique_inputs.micro_sim.pk) + ogusa_vers_disp = get_version(url, 'ogusa_vers', OGUSA_VERSION) + taxcalc_vers_disp = get_version(url, 'taxcalc_vers', TAXCALC_VERSION) + webapp_vers_disp = get_version(url, 'webapp_vers', WEBAPP_VERSION) + context = { 'locals':locals(), 'unique_url':url, - 'ogusa_version':url.ogusa_vers, + 'ogusa_version':ougsa_vers_display, + 'webapp_version': webapp_vers_disp, + 'taxcalc_vers': taxcalc_vers_disp, 'tables':tables, 'created_on':created_on, 'first_year':first_year, @@ -729,11 +754,11 @@ def behavior_results(request, pk): except: raise Http404 - if url.taxcalc_vers != None: - pass - else: - url.taxcalc_vers = taxcalc_version - url.save() + taxcalc_vers_disp = get_version(url, 'taxcalc_vers', TAXCALC_VERSION) + webapp_vers_disp = get_version(url, 'webapp_vers', WEBAPP_VERSION) + + context_vers_disp = {'taxcalc_version': taxcalc_vers_disp, + 'webapp_version': webapp_vers_disp} model = url.unique_inputs @@ -773,7 +798,6 @@ def behavior_results(request, pk): context = { 'locals':locals(), 'unique_url':url, - 'taxcalc_version':taxcalc_version, 'tables': json_table, 'created_on': created_on, 'first_year': first_year, @@ -782,6 +806,7 @@ def behavior_results(request, pk): 'microsim_url': microsim_url, 'results_type': "behavioral" } + context.update(context_vers_disp) return render(request, 'taxbrain/results.html', context) else: @@ -821,10 +846,13 @@ def behavior_results(request, pk): exp_num_minutes = round(exp_num_minutes, 2) exp_num_minutes = exp_num_minutes if exp_num_minutes > 0 else 0 if exp_num_minutes > 0: + print(context) return JsonResponse({'eta': exp_num_minutes}, status=202) else: return JsonResponse({'eta': exp_num_minutes}, status=200) else: print "rendering not ready yet" - return render_to_response('dynamic/not_ready.html', {'eta': '100'}, context_instance=RequestContext(request)) + context = {'eta': '100'} + context.update(context_vers_disp) + return render_to_response('dynamic/not_ready.html', context, context_instance=RequestContext(request)) diff --git a/webapp/apps/formatters.py b/webapp/apps/formatters.py index 6fbf2219..1578da77 100644 --- a/webapp/apps/formatters.py +++ b/webapp/apps/formatters.py @@ -7,3 +7,18 @@ def format_dynamic_params(params): for key in ("growdiff_response", "consumption", "growdiff_baseline"): behavior_params[key] = {} return behavior_params + +def get_version(url_obj, attr_name, current_version): + """ + get formatted python version of library for diplay on web page + """ + # need to chop off the commit reference on older runs + vers_disp = (getattr(url_obj, attr_name) + if getattr(url_obj, attr_name) else current_version) + # only recently start storing webapp version. for older runs display + # the current version. an alternative is to display the first stable + # version if url.webapp_version is None + if len(vers_disp.split('.')) > 3: + vers_disp = '.'.join(vers_disp.split('.')[:-1]) + + return vers_disp diff --git a/webapp/apps/taxbrain/models.py b/webapp/apps/taxbrain/models.py index b8f2f892..5bf55037 100644 --- a/webapp/apps/taxbrain/models.py +++ b/webapp/apps/taxbrain/models.py @@ -732,6 +732,8 @@ class OutputUrl(models.Model): uuid = UUIDField(auto=True, default=None, null=True) taxcalc_vers = models.CharField(blank=True, default=None, null=True, max_length=50) + webapp_vers = models.CharField(blank=True, default=None, null=True, + max_length=50) def get_absolute_url(self): kwargs = { diff --git a/webapp/apps/taxbrain/views.py b/webapp/apps/taxbrain/views.py index d8cd0643..78da5dc0 100644 --- a/webapp/apps/taxbrain/views.py +++ b/webapp/apps/taxbrain/views.py @@ -51,10 +51,15 @@ INCOME_BINS_TOOLTIP, INCOME_DECILES_TOOLTIP, START_YEAR, START_YEARS) +from ..formatters import get_version + +from django.conf import settings +WEBAPP_VERSION = settings.WEBAPP_VERSION tcversion_info = taxcalc._version.get_versions() -taxcalc_version = tcversion_info['version'] +TAXCALC_VERSION = tcversion_info['version'] + JOB_PROC_TIME_IN_SECONDS = 30 def log_ip(request): @@ -187,7 +192,12 @@ def process_model(model, start_year, stored_errors=None, request=None, if unique_url.taxcalc_vers != None: pass else: - unique_url.taxcalc_vers = taxcalc_version + unique_url.taxcalc_vers = TAXCALC_VERSION + + if unique_url.webapp_vers != None: + pass + else: + unique_url.webapp_vers = WEBAPP_VERSION unique_url.unique_inputs = model unique_url.model_pk = model.pk @@ -290,7 +300,12 @@ def file_input(request): if unique_url.taxcalc_vers != None: pass else: - unique_url.taxcalc_vers = taxcalc_version + unique_url.taxcalc_vers = TAXCALC_VERSION + + if unique_url.webapp_vers != None: + pass + else: + unique_url.webapp_vers = WEBAPP_VERSION unique_url.unique_inputs = model unique_url.model_pk = model.pk @@ -313,7 +328,8 @@ def file_input(request): init_context = { 'params': taxcalc_default_params, 'errors': errors, - 'taxcalc_version': taxcalc_version, + 'taxcalc_version': TAXCALC_VERSION, + 'webapp_version': WEBAPP_VERSION, 'start_years': START_YEARS, 'start_year': start_year, 'has_errors': has_errors, @@ -410,7 +426,8 @@ def personal_results(request): init_context = { 'form': form_personal_exemp, 'params': nested_form_parameters(int(start_year)), - 'taxcalc_version': taxcalc_version, + 'taxcalc_version': TAXCALC_VERSION, + 'webapp_version': WEBAPP_VERSION, 'start_years': START_YEARS, 'start_year': start_year, 'has_errors': has_errors, @@ -469,10 +486,14 @@ def edit_personal_results(request, pk): form_personal_exemp = PersonalExemptionForm(first_year=start_year, instance=model) taxcalc_default_params = default_policy(int(start_year)) + taxcalc_vers_disp = get_version(url, 'taxcalc_vers', TAXCALC_VERSION) + webapp_vers_disp = get_version(url, 'webapp_vers', WEBAPP_VERSION) + init_context = { 'form': form_personal_exemp, 'params': nested_form_parameters(int(start_year)), - 'taxcalc_version': taxcalc_version, + 'taxcalc_version': taxcalc_vers_disp, + 'webapp_version': webapp_vers_disp, 'start_years': START_YEARS, 'start_year': str(start_year), 'is_edit_page': True @@ -536,7 +557,6 @@ def get_result_context(model, request, url): context = { 'locals':locals(), 'unique_url':url, - 'taxcalc_version':taxcalc_version, 'tables': json_table, 'created_on': created_on, 'first_year': first_year, @@ -565,8 +585,15 @@ def output_detail(request, pk): raise Http404 model = url.unique_inputs + + taxcalc_vers_disp = get_version(url, 'taxcalc_vers', TAXCALC_VERSION) + webapp_vers_disp = get_version(url, 'webapp_vers', WEBAPP_VERSION) + + context_vers_disp = {'taxcalc_version': taxcalc_vers_disp, + 'webapp_version': webapp_vers_disp} if model.tax_result: context = get_result_context(model, request, url) + context.update(context_vers_disp) context["raw_reform_text"] = model.json_text.raw_reform_text if model.json_text else "" context["raw_assumption_text"] = model.json_text.raw_assumption_text if model.json_text else "" return render(request, 'taxbrain/results.html', context) @@ -615,6 +642,7 @@ def output_detail(request, pk): model.creation_date = datetime.datetime.now() model.save() context = get_result_context(model, request, url) + context.update(context_vers_disp) return render(request, 'taxbrain/results.html', context) else: @@ -633,12 +661,14 @@ def output_detail(request, pk): exp_num_minutes = round(exp_num_minutes, 2) exp_num_minutes = exp_num_minutes if exp_num_minutes > 0 else 0 if exp_num_minutes > 0: - return JsonResponse({'eta': exp_num_minutes}, status=202) + return JsonResponse({'eta': '100'}, status=202) else: - return JsonResponse({'eta': exp_num_minutes}, status=200) + return JsonResponse({'eta': '100'}, status=200) else: - return render_to_response('taxbrain/not_ready.html', {'eta': '100'}, context_instance=RequestContext(request)) + context = {'eta': '100'} + context.update(context_vers_disp) + return render_to_response('taxbrain/not_ready.html', context, context_instance=RequestContext(request)) @permission_required('taxbrain.view_inputs') diff --git a/webapp/settings.py b/webapp/settings.py index 296ba2ac..0f2001c3 100644 --- a/webapp/settings.py +++ b/webapp/settings.py @@ -39,6 +39,8 @@ from django.conf import global_settings +WEBAPP_VERSION = "1.0.2" + TEMPLATE_CONTEXT_PROCESSORS = global_settings.TEMPLATE_CONTEXT_PROCESSORS + ( 'webapp.apps.pages.views.settings_context_processor', 'webapp.context_processors.google_analytics', From a586515131f59e90f2abb5b4e2d4a81f61452069 Mon Sep 17 00:00:00 2001 From: Henry Doupe Date: Mon, 18 Sep 2017 09:20:55 -0400 Subject: [PATCH 4/5] Add migrations files for new webapp_vers variable --- .../0002_btaxoutputurl_webapp_vers.py | 19 ++++++++++++ .../migrations/0015_auto_20170918_1255.py | 29 +++++++++++++++++++ .../migrations/0054_outputurl_webapp_vers.py | 19 ++++++++++++ 3 files changed, 67 insertions(+) create mode 100644 webapp/apps/btax/migrations/0002_btaxoutputurl_webapp_vers.py create mode 100644 webapp/apps/dynamic/migrations/0015_auto_20170918_1255.py create mode 100644 webapp/apps/taxbrain/migrations/0054_outputurl_webapp_vers.py diff --git a/webapp/apps/btax/migrations/0002_btaxoutputurl_webapp_vers.py b/webapp/apps/btax/migrations/0002_btaxoutputurl_webapp_vers.py new file mode 100644 index 00000000..43386b65 --- /dev/null +++ b/webapp/apps/btax/migrations/0002_btaxoutputurl_webapp_vers.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('btax', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='btaxoutputurl', + name='webapp_vers', + field=models.CharField(default=None, max_length=50, null=True, blank=True), + ), + ] diff --git a/webapp/apps/dynamic/migrations/0015_auto_20170918_1255.py b/webapp/apps/dynamic/migrations/0015_auto_20170918_1255.py new file mode 100644 index 00000000..68efb4fd --- /dev/null +++ b/webapp/apps/dynamic/migrations/0015_auto_20170918_1255.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('dynamic', '0014_auto_20170413_2300'), + ] + + operations = [ + migrations.AddField( + model_name='dynamicbehavioroutputurl', + name='webapp_vers', + field=models.CharField(default=None, max_length=50, null=True, blank=True), + ), + migrations.AddField( + model_name='dynamicelasticityoutputurl', + name='webapp_vers', + field=models.CharField(default=None, max_length=50, null=True, blank=True), + ), + migrations.AddField( + model_name='dynamicoutputurl', + name='webapp_vers', + field=models.CharField(default=None, max_length=50, null=True, blank=True), + ), + ] diff --git a/webapp/apps/taxbrain/migrations/0054_outputurl_webapp_vers.py b/webapp/apps/taxbrain/migrations/0054_outputurl_webapp_vers.py new file mode 100644 index 00000000..1465eb75 --- /dev/null +++ b/webapp/apps/taxbrain/migrations/0054_outputurl_webapp_vers.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('taxbrain', '0053_auto_20170725_2141'), + ] + + operations = [ + migrations.AddField( + model_name='outputurl', + name='webapp_vers', + field=models.CharField(default=None, max_length=50, null=True, blank=True), + ), + ] From 369d182cac2b2dd32e7deef3d9058dec8aa5304d Mon Sep 17 00:00:00 2001 From: Henry Doupe Date: Mon, 18 Sep 2017 17:46:36 -0400 Subject: [PATCH 5/5] Fix bugs --- webapp/apps/dynamic/views.py | 6 ++---- webapp/apps/formatters.py | 5 +++-- webapp/apps/taxbrain/views.py | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/webapp/apps/dynamic/views.py b/webapp/apps/dynamic/views.py index 7f6605b3..c365c733 100644 --- a/webapp/apps/dynamic/views.py +++ b/webapp/apps/dynamic/views.py @@ -466,7 +466,7 @@ def edit_dynamic_behavioral(request, pk): 'form': form_personal_exemp, 'params': behavior_default_params, 'taxcalc_version': taxcalc_vers_disp, - 'webapp_vers_disp': webapp_vers_disp, + 'webapp_version': webapp_vers_disp, 'start_year': str(start_year), 'pk': model.micro_sim.pk } @@ -501,7 +501,7 @@ def edit_dynamic_elastic(request, pk): 'form': form_personal_exemp, 'params': elasticity_default_params, 'taxcalc_version': taxcalc_vers_disp, - 'webapp_vers': webapp_vers_disp, + 'webapp_version': webapp_vers_disp, 'start_year': str(start_year), 'pk': model.micro_sim.pk } @@ -755,7 +755,6 @@ def behavior_results(request, pk): 'webapp_version': webapp_vers_disp} model = url.unique_inputs - if model.tax_result: output = model.tax_result @@ -840,7 +839,6 @@ def behavior_results(request, pk): exp_num_minutes = round(exp_num_minutes, 2) exp_num_minutes = exp_num_minutes if exp_num_minutes > 0 else 0 if exp_num_minutes > 0: - print(context) return JsonResponse({'eta': exp_num_minutes}, status=202) else: return JsonResponse({'eta': exp_num_minutes}, status=200) diff --git a/webapp/apps/formatters.py b/webapp/apps/formatters.py index 1578da77..c850dcf0 100644 --- a/webapp/apps/formatters.py +++ b/webapp/apps/formatters.py @@ -13,8 +13,9 @@ def get_version(url_obj, attr_name, current_version): get formatted python version of library for diplay on web page """ # need to chop off the commit reference on older runs - vers_disp = (getattr(url_obj, attr_name) - if getattr(url_obj, attr_name) else current_version) + vers_disp = (getattr(url_obj, attr_name) + if getattr(url_obj, attr_name) is not None + else current_version) # only recently start storing webapp version. for older runs display # the current version. an alternative is to display the first stable # version if url.webapp_version is None diff --git a/webapp/apps/taxbrain/views.py b/webapp/apps/taxbrain/views.py index b01b5c33..59dbb0d1 100644 --- a/webapp/apps/taxbrain/views.py +++ b/webapp/apps/taxbrain/views.py @@ -797,9 +797,9 @@ def output_detail(request, pk): exp_num_minutes = round(exp_num_minutes, 2) exp_num_minutes = exp_num_minutes if exp_num_minutes > 0 else 0 if exp_num_minutes > 0: - return JsonResponse({'eta': '100'}, status=202) + return JsonResponse({'eta': exp_num_minutes}, status=202) else: - return JsonResponse({'eta': '100'}, status=200) + return JsonResponse({'eta': exp_num_minutes}, status=200) else: context = {'eta': '100'}