Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete PR 688 (Adding dynamic CDNs for the widgets) #897

Merged
merged 4 commits into from
Jun 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion conda-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ numba>=0.33.0
pandas>=0.22.0
pillow
pyparsing
bokeh=0.12.7
bokeh>=0.12.7
2 changes: 1 addition & 1 deletion distributed/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RUN conda config --add channels ospc/label/dev
RUN conda config --append channels conda-forge

RUN conda install python=2.7.14 numpy>=1.12.1 pandas>=0.23.0 taxcalc=0.20.1 \
btax=0.2.2 ogusa=0.5.11 matplotlib numba six bokeh=0.12.7 mock xlrd \
btax=0.2.2 ogusa=0.5.11 matplotlib numba six bokeh>=0.12.7 mock xlrd \
sphinx nomkl

RUN pip install -r requirements.txt
Expand Down
4 changes: 2 additions & 2 deletions templates/btax/results.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<link rel='stylesheet' href={{cdn_css|safe}} type="text/css"/>
<script type="text/javascript" src={{cdn_js|safe}}></script>
<link
href="https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.7.min.css"
href={{widget_css|safe}}
rel="stylesheet" type="text/css">
<script src="https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.7.min.js"></script>
<script type="text/javascript" src={{widget_js|safe}}></script>

<style>
.btn {
Expand Down
6 changes: 4 additions & 2 deletions webapp/apps/btax/bubble_plot/bubble_plot_tabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def bubble_plot_tabs(dataframes):
controls_callback.args['c_nc_buttons'] = c_nc_buttons

format_buttons = RadioButtonGroup(labels=['Baseline', 'Reform', 'Change'],
active=0, callback=controls_callback)
active=0, callback=controls_callback)
controls_callback.args['format_buttons'] = format_buttons

interest_buttons = RadioButtonGroup(labels=['METTR', 'METR', 'Cost of Capital', 'Depreciation'],
Expand All @@ -271,5 +271,7 @@ def bubble_plot_tabs(dataframes):
js, div = components(layout)
cdn_js = CDN.js_files[0]
cdn_css = CDN.css_files[0]
widget_js = CDN.js_files[1]
widget_css = CDN.css_files[1]

return js, div, cdn_js, cdn_css
return js, div, cdn_js, cdn_css, widget_js, widget_css
7 changes: 4 additions & 3 deletions webapp/apps/btax/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,6 @@ def output_detail(request, pk):
# try to render table; if failure render not available page
try:
exp_num_minutes = 0.25
JsonResponse({'eta': exp_num_minutes, 'wait_interval': 15000}, status=202)
tax_result = url.unique_inputs.tax_result
tables = json.loads(tax_result)[0]
first_year = url.unique_inputs.first_year
Expand All @@ -370,13 +369,13 @@ def output_detail(request, pk):
"coc": COC_TOOLTIP,
"dprc": DPRC_TOOLTIP,
}
bubble_js, bubble_div, cdn_js, cdn_css = bubble_plot_tabs(tables['dataframes'])
bubble_js, bubble_div, cdn_js, cdn_css, widget_js, widget_css = bubble_plot_tabs(tables['dataframes'])
except Exception as e:
print('Exception rendering pk', pk, e)
traceback.print_exc()
edit_href = '/ccc/edit/{}/?start_year={}'.format(
pk,
model.first_year or START_YEAR # sometimes first_year is None
model.first_year or START_YEAR # sometimes first_year is None
)
print('edit_href', edit_href, pk, model.first_year)
not_avail_context = dict(edit_href=edit_href,
Expand All @@ -398,6 +397,8 @@ def output_detail(request, pk):
'bubble_div': bubble_div,
'cdn_js': cdn_js,
'cdn_css': cdn_css,
'widget_js': widget_js,
'widget_css': widget_css
})
context.update(context_vers_disp)
return render(request, 'btax/results.html', context)
Expand Down