Skip to content

Commit

Permalink
Merge pull request #48 from LCOGT/more_release_fixes
Browse files Browse the repository at this point in the history
More release fixes
  • Loading branch information
eheinrich committed Jul 3, 2019
2 parents b1e4103 + eb1faa8 commit bd0eecf
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
10 changes: 7 additions & 3 deletions observation_portal/blocks/viewsets.py
Expand Up @@ -8,8 +8,9 @@

from observation_portal.observations.models import Observation
from observation_portal.blocks.filters import PondBlockFilter
from observation_portal.blocks.conversion import (convert_pond_blocks_to_observations,
convert_observations_to_pond_blocks)
from observation_portal.blocks.conversion import (
convert_pond_blocks_to_observations, convert_observations_to_pond_blocks, PondBlockError
)
from observation_portal.observations.serializers import ScheduleSerializer
from observation_portal.common.mixins import ListAsDictMixin

Expand Down Expand Up @@ -44,7 +45,10 @@ def perform_create(self, serializer):
serializer.save(submitter=self.request.user, submitter_id=self.request.user.id)

def create(self, request, *args, **kwargs):
observations = convert_pond_blocks_to_observations(request.data)
try:
observations = convert_pond_blocks_to_observations(request.data)
except PondBlockError as e:
return Response({'error': str(e)}, 400)
request._full_data = observations
return super().create(request, *args, **kwargs)

Expand Down
25 changes: 13 additions & 12 deletions observation_portal/requestgroups/request_utils.py
Expand Up @@ -6,6 +6,7 @@
from observation_portal.common.configdb import configdb
from observation_portal.common.telescope_states import TelescopeStates, filter_telescope_states_by_intervals
from observation_portal.common.rise_set_utils import get_rise_set_target, get_filtered_rise_set_intervals_by_site
from observation_portal.requestgroups.target_helpers import TARGET_TYPE_HELPER_MAP

# TODO: Use configuration types from configdb

Expand Down Expand Up @@ -73,20 +74,20 @@ def date_range_from_interval(start_time, end_time, dt=timedelta(minutes=15)):

def get_airmasses_for_request_at_sites(request_dict):
# TODO: Change to work with multiple instrument types and multiple constraints and multiple targets
data = {'airmass_data': {}}
instrument_type = request_dict['configurations'][0]['instrument_type']
constraints = request_dict['configurations'][0]['constraints']

site_data = configdb.get_sites_with_instrument_type_and_location(
instrument_type=instrument_type,
site_code=request_dict['location'].get('site'),
enclosure_code=request_dict['location'].get('enclosure'),
telescope_code=request_dict['location'].get('telescope')
)

rs_target = get_rise_set_target(request_dict['configurations'][0]['target'])

data = {'airmass_data': {}}
if request_dict['configurations'][0]['target']['type'].upper() not in ['SATELLITE', 'HOUR_ANGLE']:
target = request_dict['configurations'][0]['target']
target_type = str(target.get('type', '')).upper()

if target_type in ['ICRS', 'ORBITAL_ELEMENTS'] and TARGET_TYPE_HELPER_MAP[target_type](target).is_valid():
site_data = configdb.get_sites_with_instrument_type_and_location(
instrument_type=instrument_type,
site_code=request_dict['location'].get('site'),
enclosure_code=request_dict['location'].get('enclosure'),
telescope_code=request_dict['location'].get('telescope')
)
rs_target = get_rise_set_target(target)
for site_id, site_details in site_data.items():
night_times = []
site_lat = Angle(degrees=site_details['latitude'])
Expand Down
8 changes: 4 additions & 4 deletions static/js/components/requestgroup.vue
Expand Up @@ -227,11 +227,11 @@
}
that.available_instruments = allowed_instruments;
that.update();
}).done(function() {
if (QueryString().requestgroupid) {
that.fetchRequestGroup(QueryString().requestgroupid);
}
});
}).done(function() {
if (QueryString().requestgroupid) {
that.fetchRequestGroup(QueryString().requestgroupid);
}
});
},
computed: {
Expand Down

0 comments on commit bd0eecf

Please sign in to comment.