Skip to content

Commit 1bef356

Browse files
authored
Merge branch 'dev' into 1109-create-a-basedataservice-class
2 parents 142e95f + d353eaa commit 1bef356

4 files changed

Lines changed: 27 additions & 9 deletions

File tree

poetry.lock

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tom_catalogs/harvesters/mpc.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,12 @@ def query(self, term):
6565
def to_target(self):
6666
target = super().to_target()
6767
result = self.catalog_data[0]['mpc_orb']
68+
if isinstance(result, list):
69+
result = result[0]
6870

6971
target.type = 'NON_SIDEREAL'
7072
target.scheme = 'MPC_COMET'
73+
7174
target.name = result['designation_data']['iau_designation'].replace('(', '').replace(')', '')
7275
extra_desigs = []
7376
if result['designation_data'].get('name', "") != "":

tom_observations/templates/tom_observations/observation_list.html

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,20 @@
3434
<th>Facility</th>
3535
<th>Status</th>
3636
<th>Start</th>
37-
<th>End</th>
3837
<th>Groups</th>
3938
<th>Saved Data</th>
4039
<th>Download All</th>
4140
</tr>
4241
</thead>
4342
<tbody>
44-
{% for observation in filter.qs %}
43+
{% for observation in object_list %}
4544
<tr>
4645
<td><input type="checkbox" name="selected" value="{{observation.id}}"></td>
4746
<td><a class="btn btn-success" href="{% url 'tom_observations:detail' observation.id %}">Details</a></td>
48-
<td><a href="{% url 'tom_targets:detail' observation.target.id %}?tab=observations" title="{{ observation.target.id }}">{{ observation.target.names|join:", " }}</a></td>
47+
<td><a href="{% url 'tom_targets:detail' observation.target.id %}?tab=observations" title="{{ observation.target.id }}">{{ observation.target.name }}</a></td>
4948
<td>{{ observation.facility }}</td>
5049
<td>{{ observation.status }}</td>
5150
<td>{{ observation.scheduled_start }}</td>
52-
<td>{{ observation.scheduled_end }}</td>
5351
<td>{% for o in observation.observationgroup_set.all %}{{ o.name }} {% endfor %}</td>
5452
<td>{{ observation.dataproduct_set.count }}</td>
5553
<td>

tom_observations/views.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from django.contrib.auth.mixins import LoginRequiredMixin
1313
from django.core.management import call_command
1414
from django_filters import (CharFilter, ChoiceFilter, DateTimeFromToRangeFilter, FilterSet, ModelMultipleChoiceFilter,
15-
OrderingFilter)
15+
OrderingFilter, MultipleChoiceFilter)
1616
from django_filters.views import FilterView
1717
from django.shortcuts import redirect
1818
from django.urls import reverse, reverse_lazy
@@ -31,7 +31,7 @@
3131
from tom_observations.cadence import CadenceForm, get_cadence_strategy
3232
from tom_observations.facility import get_service_class, get_service_classes
3333
from tom_observations.facility import BaseManualObservationFacility
34-
from tom_observations.forms import AddExistingObservationForm
34+
from tom_observations.forms import AddExistingObservationForm, facility_choices
3535
from tom_observations.models import ObservationRecord, ObservationGroup, ObservationTemplate, DynamicCadence
3636
from tom_targets.models import Target
3737

@@ -46,10 +46,28 @@ class ObservationFilter(FilterSet):
4646
fields=['scheduled_start', 'scheduled_end', 'status', 'created', 'modified']
4747
)
4848
scheduled_start = DateTimeFromToRangeFilter()
49-
scheduled_end = DateTimeFromToRangeFilter
49+
scheduled_end = DateTimeFromToRangeFilter()
50+
target_id = ModelMultipleChoiceFilter(
51+
queryset=Target.objects.filter(observationrecord__isnull=False).distinct().order_by('name')
52+
)
5053
observationgroup = ModelMultipleChoiceFilter(
5154
label='Observation Groups', queryset=ObservationGroup.objects.all()
5255
)
56+
facility = MultipleChoiceFilter(choices=facility_choices())
57+
58+
def __init__(self, *args, **kwargs):
59+
"""
60+
The "status" filter is populated dynamically via list comprehension here in the __init__ (at runtime).
61+
This is important because the `ObservationRecord` db table doesn't necessarily exist at
62+
Class-interpretation-time
63+
"""
64+
super().__init__(*args, **kwargs)
65+
self.status = MultipleChoiceFilter(
66+
choices=[
67+
(s, s) for s in
68+
ObservationRecord.objects.values_list('status', flat=True).order_by('status').distinct()
69+
]
70+
)
5371

5472
class Meta:
5573
model = ObservationRecord

0 commit comments

Comments
 (0)