Skip to content

Commit

Permalink
ignore direct requests without an obs
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon committed Jul 3, 2019
1 parent 8a9c93a commit b1e4103
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions observation_portal/requestgroups/models.py
Expand Up @@ -196,10 +196,11 @@ def as_dict(self, for_observation=False):
ret_dict['configurations'] = [c.as_dict() for c in self.configurations.all()]
if not for_observation:
if self.request_group.observation_type == RequestGroup.DIRECT:
observation = self.observation_set.first()
ret_dict['location'] = {'site': observation.site, 'enclosure': observation.enclosure,
'telescope': observation.telescope}
ret_dict['windows'] = [{'start': observation.start, 'end': observation.end}]
if self.observation_set.count() > 0:
observation = self.observation_set.first()
ret_dict['location'] = {'site': observation.site, 'enclosure': observation.enclosure,
'telescope': observation.telescope}
ret_dict['windows'] = [{'start': observation.start, 'end': observation.end}]
else:
ret_dict['location'] = self.location.as_dict() if hasattr(self, 'location') else {}
ret_dict['windows'] = [w.as_dict() for w in self.windows.all()]
Expand Down

0 comments on commit b1e4103

Please sign in to comment.