Skip to content

Commit

Permalink
Merge pull request #847 from hdoupe/file_datasource
Browse files Browse the repository at this point in the history
Merged #847
  • Loading branch information
hdoupe authored Mar 14, 2018
2 parents 38bb1b7 + df2e85d commit 93d1bf0
Show file tree
Hide file tree
Showing 10 changed files with 352 additions and 331 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ install:
- export PATH="$HOME/miniconda/bin:$PATH"
- python -c 'import os,sys,fcntl; flags = fcntl.fcntl(sys.stdout, fcntl.F_GETFL); fcntl.fcntl(sys.stdout, fcntl.F_SETFL, flags&~os.O_NONBLOCK);'
- pushd deploy
- conda clean --all -y
- ./install_taxbrain_server.sh
- popd
- source activate aei_dropq
Expand Down
3 changes: 2 additions & 1 deletion RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ Go
[here](https://github.com/OpenSourcePolicyCenter/PolicyBrain/pulls?q=is%3Apr+is%3Aclosed)
for a complete commit history.

Release 1.5.0 on 2018-03-13
Release 1.5.0 on 2018-03-14
----------------------------
**Major Changes**
- None

**Minor Changes**
- [#835](https://github.com/OpenSourcePolicyCenter/PolicyBrain/pull/835/) - Add button to allow CPS as input data source - Sean Wang, Anderson Frailey, and Hank Doupe
- [#842](https://github.com/OpenSourcePolicyCenter/PolicyBrain/pull/842/) - Gray out fields based on data-source selection - Hank Doupe and Sean Wang
- [#847](https://github.com/OpenSourcePolicyCenter/PolicyBrain/pull/847) - Adds data source to file input page, refactors reform submission, and improves tests - Hank Doupe

**Bug Fixes**
- [#844](https://github.com/OpenSourcePolicyCenter/PolicyBrain/pull/842/) - Pass start year to dynamic behavioral - Hank Doupe
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ boto
django-storages
django-htmlmin
pyparsing
python-dateutil
13 changes: 12 additions & 1 deletion static/js/filetb.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,22 @@ $('#id_factor_adjustment, #id_factor_target').focus(function() {

var currentYear = $('#start-year-select').val();
$('#start-year-select').change(function(e) {
$('#current-year-link').attr('href', '/taxbrain/file/?start_year=' + $(this).val());
$('#current-year-link').attr('href', '/taxbrain/file/?start_year=' + $(this).val() + '&data_source=' + $('#data-source-select').val());
$('#current-year-modal').modal('show');
});

$('#current-year-modal').on('hide.bs.modal', function (e) {
$('#start-year-select option').removeAttr("selected");
$('#start-year-select option[value="' + currentYear + '"]').attr("selected", "selected");
});

var dataSource = $('#data-source-select').val();
$('#data-source-select').change(function(e) {
$('#data-source-link').attr('href', '/taxbrain/file/?start_year=' + $('#start-year-select').val() + '&data_source=' + $(this).val());
$('#data-source-modal').modal('show');
});

$('#data-choice-modal').on('hide.bs.modal', function (e) {
$('#data-source option').removeAttr("selected");
$('#data-source option[value="' + dataSource + '"]').attr("selected", "selected");
});
39 changes: 32 additions & 7 deletions templates/taxbrain/input_file.html
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ <h2>Tax-Calculator Code Build</h2>
</div>
</section>
</div>
<form class="inputs-form" method="post" action="/taxbrain/file/?start_year={{start_year}}" enctype="multipart/form-data">
<form class="inputs-form" method="post" action="/taxbrain/file/?start_year={{start_year}}&data_source={{data_source}}" enctype="multipart/form-data">
{% csrf_token %}
<input type="hidden" name="has_errors" value="{{ has_errors }}" />
<input type="hidden" name="start_year" value="{{ start_year }}" />
Expand All @@ -133,13 +133,20 @@ <h2>Tax-Calculator Code Build</h2>
<div class="row">
<div class="col-xs-3">
<div class="inputs-sidebar" data-spy="affix" data-offset-top="435" data-offset-bottom="245">
<label class="">Start Year:
<select id="start-year-select" class="form-control pull-right">
{% for year in start_years %}
<option value="{{year}}" {% if year == start_year %} selected {% endif %}>{{year}}</option>
{% endfor %}
</select>
<label class="">Start Year:
<select id="start-year-select" class="form-control pull-right">
{% for year in start_years %}
<option value="{{year}}" {% if year == start_year %} selected {% endif %}>{{year}}</option>
{% endfor %}
</select>
</label>
<label class=""> Data Source:
<select id="data-source-select" class="form-control pull-right">
{% for data in data_sources %}
<option value="{{data}}" {% if data == data_source %} selected {% endif %}>{{data}}</option>
{% endfor %}
</select>
</label>
<ul class="nav sidebar-nav">
<li class="get-started"><a href="#get-started">Get Started</a></li>
<li><a href="#json-form">Input Form</a></li>
Expand Down Expand Up @@ -200,4 +207,22 @@ <h4 class="modal-title" id="myModalLabel">Change Start Year</h4>
</div>
</div>
</div>
<div class="modal fade" id="data-source-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel">Change Data Source</h4>
</div>
<div class="modal-body">
Warning: This will clear your current inputs.
</div>
<div class="modal-footer">
<a type="button" class="btn btn-default" data-dismiss="modal">Nevermind.</a>
<a type="button" class="btn btn-primary" id="data-source-link">OK, go for it.</a>
</div>
</div>
</div>
</div>

{% endblock %}
2 changes: 2 additions & 0 deletions webapp/apps/taxbrain/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ def set_form(defaults):
class TaxBrainForm(PolicyBrainForm, ModelForm):

def __init__(self, first_year, use_puf_not_cps, *args, **kwargs):
# the start year and the data source form object for later access.
# This should be refactored into `process_model`
if first_year is None:
first_year = START_YEAR
self._first_year = int(first_year)
Expand Down
26 changes: 26 additions & 0 deletions webapp/apps/taxbrain/submit_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from collections import namedtuple

PostMeta = namedtuple(
'PostMeta',
['request',
'personal_inputs',
'json_reform',
'model',
'stop_submission',
'has_errors',
'errors_warnings',
'start_year',
'data_source',
'do_full_calc',
'is_file',
'reform_dict',
'assumptions_dict',
'reform_text',
'assumptions_text',
'submitted_ids',
'max_q_length',
'user',
'url']
)

BadPost = namedtuple('BadPost', ['http_response_404', 'has_errors'])
Loading

0 comments on commit 93d1bf0

Please sign in to comment.