Skip to content

Commit

Permalink
Merge branch 'master' of github.com:LCOGT/observation-portal into upd…
Browse files Browse the repository at this point in the history
…ate_obs_end
  • Loading branch information
Jon committed Sep 4, 2019
2 parents 64b909a + 2401f3b commit 8c57a74
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
6 changes: 4 additions & 2 deletions observation_portal/observations/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,10 @@ def validate(self, data):

# Also check the guide and acquisition cameras are valid if specified
# But only if the guide mode is set
if (configuration['guiding_config']['mode'] != GuidingConfig.OFF or
configuration['acquisition_config']['mode'] != AcquisitionConfig.OFF):
if (
configuration['guiding_config'].get('mode', GuidingConfig.OFF) != GuidingConfig.OFF or
configuration['acquisition_config'].get('mode', AcquisitionConfig.OFF) != AcquisitionConfig.OFF
):
if not configuration.get('guide_camera_name', ''):
if (
'extra_params' in configuration
Expand Down
2 changes: 1 addition & 1 deletion observation_portal/proposals/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

@dramatiq.actor()
def time_allocation_reminder():
for proposal in Proposal.current_proposals().filter(active=True):
for proposal in Proposal.current_proposals().filter(active=True).distinct():
# Only send an email if we are within 3 months of the end of the semester
# and the proposal has at least one allocation.
if (proposal.current_semester.end - timezone.now()).days <= 93 and \
Expand Down
7 changes: 5 additions & 2 deletions observation_portal/requestgroups/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,14 @@ def validate(self, data):
if plural_type not in available_optical_elements:
raise serializers.ValidationError(_("optical_element of type {} is not available on {} instruments"
.format(oe_type, data['instrument_type'])))
available_elements = [element['code'].lower() for element in available_optical_elements[plural_type]]
if plural_type in available_optical_elements and value.lower() not in available_elements:
available_elements = {element['code'].lower(): element['code'] for element in available_optical_elements[plural_type]}
if plural_type in available_optical_elements and value.lower() not in available_elements.keys():
raise serializers.ValidationError(_("optical element {} of type {} is not available".format(
value, oe_type
)))
else:
instrument_config['optical_elements'][oe_type] = available_elements[value.lower()]


# Also check that any optical element group in configdb is specified in the request unless we are a BIAS or
# DARK or SCRIPT type observation
Expand Down
7 changes: 7 additions & 0 deletions observation_portal/requestgroups/test/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1377,6 +1377,13 @@ def test_invalid_filter_for_instrument(self):
self.assertIn('optical element magic of type filter is not available', str(response.content))
self.assertEqual(response.status_code, 400)

def test_filter_case_is_overridden(self):
bad_data = self.generic_payload.copy()
bad_data['requests'][0]['configurations'][0]['instrument_configs'][0]['optical_elements']['filter'] = 'AiR'
response = self.client.post(reverse('api:request_groups-list'), data=bad_data)
self.assertEqual(response.json()['requests'][0]['configurations'][0]['instrument_configs'][0]['optical_elements']['filter'], 'air')
self.assertEqual(response.status_code, 201)

def test_filter_not_necessary_for_type(self):
good_data = self.generic_payload.copy()

Expand Down
1 change: 1 addition & 0 deletions observation_portal/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@
AWS_SECRET_ACCESS_KEY = os.getenv('AWS_SECRET_ACCESS_KEY', None)
AWS_S3_CUSTOM_DOMAIN = 's3-us-west-2.amazonaws.com/{}'.format(AWS_STORAGE_BUCKET_NAME)
AWS_IS_GZIPPED = True
AWS_LOCATION = os.getenv('MEDIAFILES_DIR', 'media')
AWS_DEFAULT_ACL = None

STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]
Expand Down

0 comments on commit 8c57a74

Please sign in to comment.