Skip to content

Commit

Permalink
#1: viewer tests passing
Browse files Browse the repository at this point in the history
  • Loading branch information
mortenwh committed Feb 4, 2019
1 parent 8a15d6c commit c88c01d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
6 changes: 3 additions & 3 deletions geospaas/viewer/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,14 @@ def setUp(self):
'date0': date0,
'date1': date1,
'platform': [source.platform.id],
'instrument': [source.instrument.id]
'instrument': [source.instrument.id],
}
self.invalid_form = {
'polygon': 1,
'date0': date0,
'date1': date1,
'platform': source.platform.id,
'instrument': source.instrument.id
'platform': [source.platform.id],
'instrument': [source.instrument.id],
}

def test_search_form(self):
Expand Down
11 changes: 6 additions & 5 deletions geospaas/viewer/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,17 @@ def render(self, request):
''' Render page based on form data '''
# filter datasets
datasets = self.image_class.objects.all()
import ipdb
ipdb.set_trace()
datasets = datasets.order_by('time_coverage_start')
if self.form.cleaned_data['platform'] is not None:
if self.form.cleaned_data['platform'] is not None and \
len(self.form.cleaned_data['platform'])>0:
src = self.form.cleaned_data['platform']
datasets = datasets.filter(sources__platform__in=src)
if self.form.cleaned_data['instrument'] is not None:
if self.form.cleaned_data['instrument'] is not None and \
len(self.form.cleaned_data['instrument'])>0:
src = self.form.cleaned_data['instrument']
datasets = datasets.filter(sources__instrument__in=src)
if self.form.cleaned_data['parameter'] is not None:
if self.form.cleaned_data['parameter'] is not None and \
len(self.form.cleaned_data['parameter'])>0:
src = self.form.cleaned_data['parameter']
datasets = datasets.filter(parameters__in=src)
t0 = self.form.cleaned_data['date0']
Expand Down

0 comments on commit c88c01d

Please sign in to comment.