Skip to content

Commit

Permalink
Add endpoint fixes: port number was truncated, multiple endpoints wer…
Browse files Browse the repository at this point in the history
…e not correctly added to related form.
  • Loading branch information
jay7958 committed Jun 13, 2015
1 parent aefdd3b commit d21db12
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
4 changes: 2 additions & 2 deletions dojo/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ def __init__(self, *args, **kwargs):
def clean(self):
from django.core.validators import URLValidator, validate_ipv46_address

port_re = "(:[0-9]{1,4}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])"
port_re = "(:[0-9]{1,5}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])"
cleaned_data = super(EditEndpointForm, self).clean()

if 'host' in cleaned_data:
Expand Down Expand Up @@ -682,7 +682,7 @@ def save(self):
def clean(self):
from django.core.validators import URLValidator, validate_ipv46_address

port_re = "(:[0-9]{1,4}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])"
port_re = "(:[0-9]{1,5}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])"
cleaned_data = super(AddEndpointForm, self).clean()

if 'endpoint' in cleaned_data and 'product' in cleaned_data:
Expand Down
29 changes: 29 additions & 0 deletions dojo/static/dojo/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,35 @@ $(function () {

});

function dismissAddAnotherPopupDojo(win, newId, newRepr) {
// newId and newRepr are expected to have previously been escaped by
// django.utils.html.escape.
newId = html_unescape(newId);
newRepr = html_unescape(newRepr);
var name = windowname_to_id(win.name);
var elem = document.getElementById(name);
var o;
if (elem) {
var elemName = elem.nodeName.toUpperCase();
if (elemName == 'SELECT') {
o = new Option(newRepr, newId);
elem.options[elem.options.length] = o;
o.selected = true;
} else if (elemName == 'INPUT') {
if (elem.className.indexOf('vManyToManyRawIdAdminField') != -1 && elem.value) {
elem.value += ',' + newId;
} else {
elem.value = newId;
}
}
} else {
var toId = name + "_to";
o = new Option(newRepr, newId);
SelectBox.add_to_cache(toId, o);
SelectBox.redisplay(toId);
}
}

function punchcard(element, data, ticks) {
var d1 = data;
var options = {
Expand Down
3 changes: 2 additions & 1 deletion dojo/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4570,8 +4570,9 @@ def add_endpoint(request, pid):
if '_popup' in request.GET:
resp = ''
for endpoint in endpoints:
resp += '<script type="text/javascript">opener.dismissAddAnotherPopup(window, "%s", "%s");</script>' \
resp += '<script type="text/javascript">opener.dismissAddAnotherPopupDojo(window, "%s", "%s");</script>' \
% (escape(endpoint._get_pk_val()), escape(endpoint))
resp += '<script type="text/javascript">window.close();</script>'
return HttpResponse(resp)

return render(request, template, {
Expand Down

0 comments on commit d21db12

Please sign in to comment.