Merge "Modify "Interval" field to select format"
This commit is contained in:
commit
d2069fc2b4
|
@ -9,5 +9,6 @@
|
||||||
<script type='text/javascript' src='{{ STATIC_URL }}freezer/js/vendor/moment.js'></script>
|
<script type='text/javascript' src='{{ STATIC_URL }}freezer/js/vendor/moment.js'></script>
|
||||||
<script type='text/javascript' src='{{ STATIC_URL }}freezer/js/vendor/bootstrap-datetimepicker.js'></script>
|
<script type='text/javascript' src='{{ STATIC_URL }}freezer/js/vendor/bootstrap-datetimepicker.js'></script>
|
||||||
<script type='text/javascript' src='{{ STATIC_URL }}freezer/js/freezer.datetimepicker.js'></script>
|
<script type='text/javascript' src='{{ STATIC_URL }}freezer/js/freezer.datetimepicker.js'></script>
|
||||||
|
<script type='text/javascript' src='{{ STATIC_URL }}freezer/js/freezer.jobs.create.infos.js'></script>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -106,18 +106,17 @@ class InfoConfigurationAction(workflows.Action):
|
||||||
label=_("Start Date and Time"),
|
label=_("Start Date and Time"),
|
||||||
required=False)
|
required=False)
|
||||||
|
|
||||||
schedule_interval = forms.CharField(
|
interval_uint = forms.ChoiceField(
|
||||||
label=_("Interval"),
|
label=_("Interval Unit"),
|
||||||
required=False,
|
help_text=_("Set the unit for the Interval"),
|
||||||
help_text=_("""Set the interval in the following format:
|
required=False)
|
||||||
continuous,
|
|
||||||
N weeks,
|
interval_value = forms.IntegerField(
|
||||||
N days,
|
label=_("Interval Value"),
|
||||||
N hours,
|
initial=1,
|
||||||
N minutes,
|
min_value=1,
|
||||||
N seconds,
|
help_text=_("Set the interval value"),
|
||||||
If no start date is provided the job
|
required=False)
|
||||||
will start immediately"""))
|
|
||||||
|
|
||||||
schedule_end_date = forms.CharField(
|
schedule_end_date = forms.CharField(
|
||||||
label=_("End Date and Time"),
|
label=_("End Date and Time"),
|
||||||
|
@ -142,6 +141,17 @@ class InfoConfigurationAction(workflows.Action):
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def populate_interval_uint_choices(self, request, context):
|
||||||
|
return [
|
||||||
|
('', _("Please choose a interval unit")),
|
||||||
|
('continuous', _("Continuous")),
|
||||||
|
('weeks', _("Weeks")),
|
||||||
|
('days', _("Days")),
|
||||||
|
('hours', _("Hours")),
|
||||||
|
('minutes', _("Minutes")),
|
||||||
|
('seconds', _("Seconds")),
|
||||||
|
]
|
||||||
|
|
||||||
def _check_start_datetime(self, cleaned_data):
|
def _check_start_datetime(self, cleaned_data):
|
||||||
if cleaned_data.get('schedule_start_date') and not \
|
if cleaned_data.get('schedule_start_date') and not \
|
||||||
self._validate_iso_format(
|
self._validate_iso_format(
|
||||||
|
@ -151,13 +161,13 @@ class InfoConfigurationAction(workflows.Action):
|
||||||
|
|
||||||
if (cleaned_data.get('schedule_start_date') and
|
if (cleaned_data.get('schedule_start_date') and
|
||||||
cleaned_data.get('schedule_end_date')) and\
|
cleaned_data.get('schedule_end_date')) and\
|
||||||
not cleaned_data.get('schedule_interval'):
|
not cleaned_data.get('schedule_unit'):
|
||||||
msg = _("Please provide this value.")
|
msg = _("Please provide this value.")
|
||||||
self._errors['schedule_interval'] = self.error_class([msg])
|
self._errors['schedule_unit'] = self.error_class([msg])
|
||||||
|
|
||||||
if (cleaned_data.get('schedule_end_date') and
|
if (cleaned_data.get('schedule_end_date') and
|
||||||
not cleaned_data.get('schedule_start_date')) and\
|
not cleaned_data.get('schedule_start_date')) and\
|
||||||
not cleaned_data.get('schedule_interval'):
|
not cleaned_data.get('schedule_unit'):
|
||||||
msg = _("Please provide this value.")
|
msg = _("Please provide this value.")
|
||||||
self._errors['schedule_start_date'] = self.error_class([msg])
|
self._errors['schedule_start_date'] = self.error_class([msg])
|
||||||
|
|
||||||
|
@ -181,7 +191,8 @@ class InfoConfiguration(workflows.Step):
|
||||||
'job_id',
|
'job_id',
|
||||||
'actions',
|
'actions',
|
||||||
'schedule_start_date',
|
'schedule_start_date',
|
||||||
'schedule_interval',
|
'interval_uint',
|
||||||
|
'interval_value',
|
||||||
'schedule_end_date')
|
'schedule_end_date')
|
||||||
|
|
||||||
|
|
||||||
|
@ -198,6 +209,15 @@ class ConfigureJob(workflows.Workflow):
|
||||||
|
|
||||||
def handle(self, request, context):
|
def handle(self, request, context):
|
||||||
try:
|
try:
|
||||||
|
interval_unit = context['interval_uint']
|
||||||
|
if not interval_unit or interval_unit == 'continuous':
|
||||||
|
context['schedule_interval'] = interval_unit
|
||||||
|
else:
|
||||||
|
interval_value = context['interval_value']
|
||||||
|
schedule_interval = "{0} {1}".format(interval_value,
|
||||||
|
interval_unit)
|
||||||
|
|
||||||
|
context['schedule_interval'] = schedule_interval
|
||||||
if context['job_id'] != '':
|
if context['job_id'] != '':
|
||||||
freezer_api.Job(request).update(context['job_id'], context)
|
freezer_api.Job(request).update(context['job_id'], context)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
# (c) Copyright 2014,2015 Hewlett-Packard Development Company, L.P.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*global $*/
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
function showIntervalValue() {
|
||||||
|
$("#id_interval_value").closest(".form-group").show();
|
||||||
|
}
|
||||||
|
|
||||||
|
function hideIntervalValue() {
|
||||||
|
$("#id_interval_value").closest(".form-group").hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#id_interval_uint").change(function () {
|
||||||
|
var $interval_uint = $("#id_interval_uint").val();
|
||||||
|
if ($interval_uint != 'continuous') {
|
||||||
|
showIntervalValue();
|
||||||
|
} else {
|
||||||
|
hideIntervalValue();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$(function () {
|
||||||
|
hideIntervalValue();
|
||||||
|
});
|
Loading…
Reference in New Issue