Skip to content

Commit

Permalink
Merge pull request #96 from LCOGT/enable_time_critical
Browse files Browse the repository at this point in the history
add Time Critical option in compose page
  • Loading branch information
jnation3406 committed Dec 3, 2019
2 parents cc0933f + b917da9 commit 6f9878c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
12 changes: 7 additions & 5 deletions observation_portal/requestgroups/serializers.py
Expand Up @@ -787,20 +787,22 @@ def validate(self, data):

if time_available <= 0.0:
raise serializers.ValidationError(
_("Proposal {} does not have any time left allocated in semester {} on {} instruments").format(
data['proposal'], tak.semester, tak.instrument_type)
_("Proposal {} does not have any {} time left allocated in semester {} on {} instruments").format(
data['proposal'], data['observation_type'], tak.semester, tak.instrument_type)
)
elif time_available * OVERHEAD_ALLOWANCE < (duration / 3600.0):
raise serializers.ValidationError(
_("Proposal {} does not have enough time allocated in semester {}").format(
data['proposal'], tak.semester)
_("Proposal {} does not have enough {} time allocated in semester {}").format(
data['proposal'], data['observation_type'], tak.semester)
)
# validate the ipp debitting that will take place later
if data['observation_type'] == RequestGroup.NORMAL:
validate_ipp(data, total_duration_dict)
except ObjectDoesNotExist:
raise serializers.ValidationError(
_("You do not have sufficient time allocated on the instrument you're requesting for this proposal.")
_("You do not have sufficient {} time allocated on the instrument you're requesting for this proposal.".format(
data['observation_type']
))
)
except TimeAllocationError as e:
raise serializers.ValidationError(repr(e))
Expand Down
8 changes: 4 additions & 4 deletions observation_portal/requestgroups/test/test_api.py
Expand Up @@ -207,7 +207,7 @@ def test_post_requestgroup_no_time_allocation_for_instrument(self):
bad_data['requests'][0]['configurations'][0]['instrument_configs'][0]['optical_elements']['slit'] = 'slit_6.0as'
response = self.client.post(reverse('api:request_groups-list'), data=bad_data)
self.assertEqual(response.status_code, 400)
self.assertIn('You do not have sufficient time', str(response.content))
self.assertIn('You do not have sufficient NORMAL time', str(response.content))

def test_post_requestgroup_manual_instrument_not_allowed(self):
bad_data = self.generic_payload.copy()
Expand Down Expand Up @@ -246,7 +246,7 @@ def test_post_requestgroup_not_enough_time_allocation_for_instrument(self):
self.time_allocation_1m0_sbig.save()
response = self.client.post(reverse('api:request_groups-list'), data=bad_data)
self.assertEqual(response.status_code, 400)
self.assertIn('does not have enough time allocated', str(response.content))
self.assertIn('does not have enough NORMAL time allocated', str(response.content))

def test_post_requestgroup_not_enough_rr_time_allocation_for_instrument(self):
bad_data = self.generic_payload.copy()
Expand All @@ -257,7 +257,7 @@ def test_post_requestgroup_not_enough_rr_time_allocation_for_instrument(self):
self.time_allocation_1m0_sbig.save()
response = self.client.post(reverse('api:request_groups-list'), data=bad_data)
self.assertEqual(response.status_code, 400)
self.assertIn('does not have enough time allocated', str(response.content))
self.assertIn('does not have enough RAPID_RESPONSE time allocated', str(response.content))

def test_post_requestgroup_rr_future_start_time(self):
bad_data = self.generic_payload.copy()
Expand Down Expand Up @@ -291,7 +291,7 @@ def test_post_requestgroup_not_have_any_time_left(self):
self.time_allocation_1m0_sbig.save()
response = self.client.post(reverse('api:request_groups-list'), data=bad_data)
self.assertEqual(response.status_code, 400)
self.assertIn('does not have any time left allocated', str(response.content))
self.assertIn('does not have any NORMAL time left allocated', str(response.content))

def test_post_requestgroup_time_limit_reached(self):
self.membership.time_limit = 0
Expand Down
7 changes: 5 additions & 2 deletions static/js/components/requestgroup.vue
Expand Up @@ -78,11 +78,14 @@
label="Mode"
field="observation_type" v-on:input="update"
desc="Rapid Response (RR) requests bypass normal scheduling and are executed immediately.
This mode is only available if a proposal was granted RR time."
Time Critical (TC) requests are given a large fixed priority that will beat any
requests that use default queue scheduling.
These modes are only available if a proposal was granted RR or TC time."
:errors="errors.observation_type"
:options="[
{value: 'NORMAL', text: 'Queue scheduled (default)'},
{value:'RAPID_RESPONSE', text: 'Rapid Response'}
{value: 'TIME_CRITICAL', text: 'Time Critical'},
{value: 'RAPID_RESPONSE', text: 'Rapid Response'}
]"
@input="update"
/>
Expand Down

0 comments on commit 6f9878c

Please sign in to comment.