1
0
Fork 0

Change results filtering of observations

environments/production/deployments/317
Alfredos-Panagiotis Damkalis 2019-03-06 21:00:08 +02:00
parent d1483e3805
commit 9dc764e6ac
4 changed files with 35 additions and 70 deletions

View File

@ -147,24 +147,11 @@ class ObservationListView(ListView):
failed = False
else:
failed = True
waterfall = self.request.GET.get('waterfall', '0')
if waterfall == '1':
waterfall = False
else:
waterfall = True
audio = self.request.GET.get('audio', '0')
if audio == '1':
audio = False
else:
audio = True
data = self.request.GET.get('data', '0')
if data == '1':
data = False
else:
data = True
results = self.request.GET.getlist('results')
if False in (bad, good, unvetted, future, failed,
waterfall, audio, data):
if False in (bad, good, unvetted, future, failed):
self.filtered = True
if results:
self.filtered = True
observations = Observation.objects.all()
@ -199,12 +186,19 @@ class ObservationListView(ListView):
observations = observations.exclude(vetted_status='unknown', end__lte=now())
if not future:
observations = observations.exclude(vetted_status='unknown', end__gt=now())
if not waterfall:
observations = observations.exclude(waterfall='')
if not audio:
observations = observations.exclude(archived=False, payload='')
if not data:
observations = observations.exclude(demoddata__payload_demod__isnull=True)
if results:
if 'w0' in results:
observations = observations.filter(waterfall='')
elif 'w1' in results:
observations = observations.exclude(waterfall='')
if 'a0' in results:
observations = observations.exclude(archived=True).filter(payload='')
elif 'a1' in results:
observations = observations.exclude(archived=False, payload='')
if 'd0' in results:
observations = observations.filter(demoddata__payload_demod__isnull=True)
elif 'd1' in results:
observations = observations.exclude(demoddata__payload_demod__isnull=True)
return observations
def get_context_data(self, **kwargs):
@ -227,9 +221,7 @@ class ObservationListView(ListView):
context['good'] = self.request.GET.get('good', '1')
context['unvetted'] = self.request.GET.get('unvetted', '1')
context['failed'] = self.request.GET.get('failed', '1')
context['waterfall'] = self.request.GET.get('waterfall', '0')
context['audio'] = self.request.GET.get('audio', '0')
context['data'] = self.request.GET.get('data', '0')
context['results'] = self.request.GET.getlist('results')
context['filtered'] = self.filtered
if norad_cat_id is not None and norad_cat_id != '':
context['norad'] = int(norad_cat_id)

View File

@ -40,8 +40,7 @@
}
}
#status-selector,
#results-selector {
#status-selector {
display: block;
}

View File

@ -29,17 +29,6 @@ $(document).ready(function() {
}
});
$('.filter-section #results-selector label').click(function() {
var checkbox = $(this);
var input = checkbox.find('input[type="checkbox"]');
if (input.prop('checked')) {
checkbox.addClass('btn-inactive');
} else {
checkbox.removeClass('btn-inactive');
}
});
// Check if filters should be displayed
if (window.location.hash == '#collapseFilters') {
$('#collapseFilters').hide();

View File

@ -142,37 +142,22 @@
{% endfor %}
</select>
</div>
<div class="form-group status-filter col-md-3">
<label for="results-selector">Results</label>
<div id="results-selector" class="btn-group" data-toggle="buttons">
<label class="btn btn-default btn-sm {% if waterfall == '1' %}active{% else %}btn-inactive{% endif %}"
aria-expanded="true"
aria-controls="waterfall"
data-toggle="tooltip"
data-placement="bottom"
title="Waterfall">
<input type="checkbox" name="waterfall" value="1" {% if waterfall == '1' %}checked{% endif %} autocomplete="off">
<span class="glyphicon glyphicon-picture" aria-hidden="true"></span>
</label>
<label class="btn btn-default btn-sm {% if audio == '1' %}active{% else %}btn-inactive{% endif %}"
aria-expanded="true"
aria-controls="audio"
data-toggle="tooltip"
data-placement="bottom"
title="Audio">
<input type="checkbox" name="audio" value="1" {% if audio == '1' %}checked{% endif %} autocomplete="off">
<span class="glyphicon glyphicon-volume-up" aria-hidden="true"></span>
</label>
<label class="btn btn-default btn-sm {% if data == '1' %}active{% else %}btn-inactive{% endif %}"
aria-expanded="true"
aria-controls="data"
data-toggle="tooltip"
data-placement="bottom"
title="Data">
<input type="checkbox" name="data" value="1" {% if data == '1' %}checked{% endif %} autocomplete="off">
<span class="glyphicon glyphicon-file" aria-hidden="true"></span>
</label>
</div>
<div class="form-group col-md-3">
<label for="results-selection">Results</label>
<select class="form-control selectpicker" name="results" autocomplete="off" id="results-selection" multiple>
<optgroup label="Waterfall" data-icon="glyphicon-picture" data-max-options="1">
<option value="w1" {% if 'w1' in results %}selected{% endif %}>With Waterfall</option>
<option value="w0" {% if 'w0' in results %}selected{% endif %}>Without Waterfall </option>
</optgroup>
<optgroup label="Audio" data-icon="glyphicon-volume-up" data-max-options="1">
<option value="a1" {% if 'a1' in results %}selected{% endif %}>With Audio</option>
<option value="a0" {% if 'a0' in results %}selected{% endif %}>Without Audio</option>
</optgroup>
<optgroup label="Data" data-icon="glyphicon-file" data-max-options="1">
<option value="d1" {% if 'd1' in results %}selected{% endif %}>With Data</option>
<option value="d0" {% if 'd0' in results %}selected{% endif %}>Without Data</option>
</optgroup>
</select>
</div>
<div class="form-group col-sm-3 ">
<label class="control-label">Start Time</label>