Add filters for station and observer in observations
parent
44a3720249
commit
f1e5329e2e
|
@ -21,6 +21,7 @@ from rest_framework import serializers, viewsets
|
|||
|
||||
from network.base.models import (Station, Transmitter, Observation,
|
||||
Satellite, Antenna, Tle, Rig)
|
||||
from network.users.models import User
|
||||
from network.base.forms import StationForm, SatelliteFilterForm
|
||||
from network.base.decorators import admin_required
|
||||
from network.base.helpers import calculate_polar_data, resolve_overlaps
|
||||
|
@ -130,6 +131,8 @@ class ObservationListView(ListView):
|
|||
Optionally filter based on good/bad/unvetted
|
||||
"""
|
||||
norad_cat_id = self.request.GET.get('norad', '')
|
||||
observer = self.request.GET.get('observer', '')
|
||||
station = self.request.GET.get('station', '')
|
||||
bad = self.request.GET.get('bad', '1')
|
||||
if bad == '0':
|
||||
bad = False
|
||||
|
@ -146,11 +149,16 @@ class ObservationListView(ListView):
|
|||
else:
|
||||
unvetted = True
|
||||
|
||||
if norad_cat_id == '':
|
||||
observations = Observation.objects.all()
|
||||
else:
|
||||
observations = Observation.objects.filter(
|
||||
observations = Observation.objects.all()
|
||||
if not norad_cat_id == '':
|
||||
observations = observations.filter(
|
||||
satellite__norad_cat_id=norad_cat_id)
|
||||
if not observer == '':
|
||||
observations = observations.filter(
|
||||
author=observer)
|
||||
if not station == '':
|
||||
observations = observations.filter(
|
||||
ground_station_id=station)
|
||||
|
||||
if not bad:
|
||||
observations = observations.exclude(vetted_status='no_data')
|
||||
|
@ -166,12 +174,20 @@ class ObservationListView(ListView):
|
|||
"""
|
||||
context = super(ObservationListView, self).get_context_data(**kwargs)
|
||||
context['satellites'] = Satellite.objects.all()
|
||||
context['authors'] = User.objects.all()
|
||||
context['stations'] = Station.objects.all()
|
||||
norad_cat_id = self.request.GET.get('norad', None)
|
||||
observer = self.request.GET.get('observer', None)
|
||||
station = self.request.GET.get('station', None)
|
||||
context['bad'] = self.request.GET.get('bad', '1')
|
||||
context['good'] = self.request.GET.get('good', '1')
|
||||
context['unvetted'] = self.request.GET.get('unvetted', '1')
|
||||
if norad_cat_id is not None and norad_cat_id != '':
|
||||
context['norad'] = int(norad_cat_id)
|
||||
if observer is not None and observer != '':
|
||||
context['observer_id'] = int(observer)
|
||||
if station is not None and station != '':
|
||||
context['station_id'] = int(station)
|
||||
if 'scheduled' in self.request.session:
|
||||
context['scheduled'] = self.request.session['scheduled']
|
||||
try:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
$(document).ready(function() {
|
||||
'use strict';
|
||||
|
||||
$('#satellite-filter').submit(function () {
|
||||
$('#observation-filter').submit(function () {
|
||||
var the_form = $(this);
|
||||
|
||||
the_form.find('input[type="checkbox"]').each( function () {
|
||||
|
@ -19,14 +19,20 @@ $(document).ready(function() {
|
|||
});
|
||||
|
||||
$('.filter-section input[type=checkbox]').change(function() {
|
||||
$('#satellite-filter').submit();
|
||||
$('#observation-filter').submit();
|
||||
});
|
||||
|
||||
// Satellite Filters
|
||||
$('#satellite-selection').bind('keyup change', function() {
|
||||
$('#satellite-filter').submit();
|
||||
$('#observation-filter').submit();
|
||||
});
|
||||
if ($('#satellite-selection').val()) {
|
||||
$('#observer-selection').bind('keyup change', function() {
|
||||
$('#observation-filter').submit();
|
||||
});
|
||||
$('#station-selection').bind('keyup change', function() {
|
||||
$('#observation-filter').submit();
|
||||
});
|
||||
if ($('#satellite-selection').val() || $('#observer-selection').val() || $('#station-selection').val()) {
|
||||
|
||||
$('#collapseFilters').show();
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
<div class="collapse{% if norad %} in{% endif %}" id="collapseFilters">
|
||||
<div class="filter-section">
|
||||
<form id="satellite-filter" class="form-inline" methon="get" action="{% url 'base:observations_list' %}">
|
||||
<form id="observation-filter" class="form-inline" methon="get" action="{% url 'base:observations_list' %}">
|
||||
<div class="form-group">
|
||||
<h4>Data:</h4>
|
||||
<div class="btn-group" data-toggle="buttons">
|
||||
|
@ -46,6 +46,26 @@
|
|||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<h4>Observer:</h4>
|
||||
<select class="form-control" name="observer" autocomplete="off" id="observer-selection">
|
||||
<option value="" selected>All</option>
|
||||
{% for author in authors %}
|
||||
<option data-author="{{ author.id }}" value="{{ author.id }}"
|
||||
{% ifequal author.id observer_id %}selected{% endifequal %}>
|
||||
{{ author.displayname }}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<h4>Station:</h4>
|
||||
<select class="form-control" name="station" autocomplete="off" id="station-selection">
|
||||
<option value="" selected>All</option>
|
||||
{% for station in stations %}
|
||||
<option data-station="{{ station }}" value="{{ station.id }}"
|
||||
{% ifequal station.id station_id %}selected{% endifequal %}>
|
||||
{{ station.id }} - {{ station.name }}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue