* Fixed calendars "required" fields not being honored

* Fixed open nebula "volatile" disks
This commit is contained in:
Adolfo Gómez García 2017-03-07 10:26:47 +01:00
parent f78c755f12
commit 330973ac30
3 changed files with 40 additions and 11 deletions

View File

@ -38,7 +38,7 @@ from defusedxml import minidom
# Python bindings for OpenNebula
from .common import sanitizeName
__updated__ = '2017-03-06'
__updated__ = '2017-03-07'
logger = logging.getLogger(__name__)
@ -142,7 +142,10 @@ def remove(api, templateId):
for dsk in template.getElementsByTagName('DISK'):
imgIds = dsk.getElementsByTagName('IMAGE_ID')
if len(imgIds) == 0:
node = dsk.getElementsByTagName('IMAGE')[0].childNodes[0]
try:
node = dsk.getElementsByTagName('IMAGE')[0].childNodes[0]
except IndexError:
continue
imgId = imgs[node.data]
else:
node = imgIds[0].childNodes[0]
@ -189,7 +192,10 @@ def checkPublished(api, templateId):
for dsk in template.getElementsByTagName('DISK'):
imgIds = dsk.getElementsByTagName('IMAGE_ID')
if len(imgIds) == 0:
node = dsk.getElementsByTagName('IMAGE')[0].childNodes[0]
try:
node = dsk.getElementsByTagName('IMAGE')[0].childNodes[0]
except IndexError:
continue
imgId = imgs[node.data]
else:
node = imgIds[0].childNodes[0]

View File

@ -20,7 +20,7 @@ gui.calendars.link = ->
'YEARLY': [gettext('year'), gettext('years'), gettext('Yearly')]
'WEEKDAYS': ['', '', gettext('Weekdays')]
dunitDct =
dunitDct =
'MINUTES': gettext('Minutes')
'HOURS': gettext('Hours')
'DAYS': gettext('Days')
@ -58,7 +58,7 @@ gui.calendars.link = ->
else if fld == "duration"
return data + " " + dunitDct[record.duration_unit]
return fld
newEditFnc = (rules, forEdit) ->
days = (w.substr(0, 3) for w in weekDays)
sortFnc = (a, b) ->
@ -197,7 +197,7 @@ gui.calendars.link = ->
else
now = Math.floor(new Date().getTime() / 1000)
fillDateTime '#id-rule-start', now
#
@ -240,8 +240,31 @@ gui.calendars.link = ->
updateSummary modalId
)
$form = $(modalId + " form")
$form.validate
debug: false
ignore: ':hidden:not("select"):not(".modal_field_data")'
errorClass: "text-danger"
validClass: "has-success"
focusInvalid: true
highlight: (element) ->
group = $(element).closest(".form-group")
group.addClass "has-error"
return
showErrors: (errorMap, errorList) ->
this.defaultShowErrors()
success: (element) ->
$(element).closest(".form-group").removeClass "has-error"
$(element).remove()
return
# Save
$(modalId + " .button-accept").click ->
return unless $form.valid()
data = readFields modalId
closeAndRefresh = () ->
@ -290,7 +313,7 @@ gui.calendars.link = ->
icon: 'calendars'
callback: renderer
container: "rules-placeholder"
rowSelect: "single"
rowSelect: "multi"
buttons: [
"new"
"edit"

View File

@ -6,14 +6,14 @@
<div class="form-group">
<label for="id-rule-name" class="col-sm-3 control-label" data-toggle="tooltip" data-title="{% trans 'Name of this rule'%}">{% trans 'Name' %}</label>
<div class="col-sm-9">
<input id="id-rule-name" name="rule_name" type="text" class="form-control" placeholder="{% trans 'Rule name' %}" autofocus required>
<input id="id-rule-name" name="rule_name" type="text" class="form-control" placeholder="{% trans 'Rule name' %}" autofocus required="true">
</div>
</div>
<div class="form-group">
<label for="id-rule-comments" class="col-sm-3 control-label" data-toggle="tooltip" data-title="{% trans 'Comments for this rule'%}">{% trans 'Comments' %}</label>
<div class="col-sm-9">
<input id="id-rule-comments" name="rule_comments" type="text" class="form-control" placeholder="{% trans 'Rule comments' %}" autofocus required>
<input id="id-rule-comments" name="rule_comments" type="text" class="form-control" placeholder="{% trans 'Rule comments' %}" autofocus>
</div>
</div>
</fieldset>
@ -55,7 +55,7 @@
<label for="id-rule-start" class="col-sm-3 control-label" data-toggle="tooltip" data-title="{% trans 'Starting date for repeating'%}">{% trans 'Starts' %}</label>
<div class="col-sm-9">
<div class="input-group date">
<input type="date" required placeholder="starting date for rule" id="id-rule-start" name="rule_start_date" class="form-control modal_field_data " aria-required="true"><span class="input-group-addon"><i class="glyphicon glyphicon-th"></i></span>
<input type="date" required placeholder="starting date for rule" id="id-rule-start" name="rule_start_date" class="form-control modal_field_data"><span class="input-group-addon"><i class="glyphicon glyphicon-th"></i></span>
</div>
</div>
</div>
@ -64,7 +64,7 @@
<label for="id-rule-end" class="col-sm-3 control-label" data-toggle="tooltip" data-title="{% trans 'End date'%}">{% trans 'Ends' %}</label>
<div class="col-sm-9">
<div class="input-group date">
<input type="date" required placeholder="Never" id="id-rule-end" name="rule_end_date" clear="true" class="form-control modal_field_data " aria-required="true"><span class="input-group-addon"><i class="glyphicon glyphicon-th"></i></span>
<input type="date" placeholder="Never" id="id-rule-end" name="rule_end_date" clear="true" class="form-control modal_field_data"><span class="input-group-addon"><i class="glyphicon glyphicon-th"></i></span>
</div>
</div>
</div>