Skip to content

Commit

Permalink
allow user to set color index #106
Browse files Browse the repository at this point in the history
  • Loading branch information
judymou committed Mar 15, 2018
1 parent 2e4fc56 commit 416888b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
3 changes: 3 additions & 0 deletions lightcurve/static/lightcurve/js/lightcurve.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@ function setupImagePairs() {

data.pairs = JSON.stringify(pairs);

// Manual color index
data.manual_color_index = $('#set-manual-ci').val();

// TODO(ian): POST it all to some endpoint.
$.post('/lightcurve/' + window.lightcurveId + '/save_image_pairs', data, function(result) {
if (result.success) {
Expand Down
23 changes: 15 additions & 8 deletions lightcurve/templates/partials/image_pair_selector.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
<div class="color-index-selector">
<form class="form form-inline">
<label for="select-color-index">Color index</label>
<select id="select-color-index" class="form-control js-select-color-index" style="width: 10em">
<option value="NONE">None</option>
{% for band in ci_bands %}
<option value="{{band}}" {% if lightcurve.ciband == band %}selected{% endif %}>{{band}}</option>
{% endfor %}
</select>
<form class="form">
<div class="form-group">
<label for="set-manual-ci">Manual color index</label>
- this value overrides the computed color index from image pairs.
<input id="set-manual-ci" class="form-control" style="width: 20em" type="number" step="any" value="{{reduction.color_index_manual}}">
</div>
<div class="form-group">
<label for="select-color-index">Color index</label>
<select id="select-color-index" class="form-control js-select-color-index" style="width: 10em">
<option value="NONE">None</option>
{% for band in ci_bands %}
<option value="{{band}}" {% if lightcurve.ciband == band %}selected{% endif %}>{{band}}</option>
{% endfor %}
</select>
</div>
</form>
</div>
<div class="image-pair-selector" style="margin-top:1em">
Expand Down
9 changes: 8 additions & 1 deletion lightcurve/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,15 @@ def apply_photometry_settings(request, lightcurve_id):

def save_image_pairs(request, lightcurve_id):
lc = get_object_or_404(LightCurve, id=lightcurve_id, user=request.user.id)
images = lc.imageanalysis_set.all()
reduction = lc.get_or_create_reduction()
color_index_manual = request.POST.get('manual_color_index')
if color_index_manual:
reduction.color_index_manual = float(color_index_manual)
else:
reduction.color_index_manual = None
reduction.save()

images = lc.imageanalysis_set.all()
ciband = request.POST.get('ciband')
pairs = json.loads(request.POST.get('pairs'))

Expand Down

0 comments on commit 416888b

Please sign in to comment.