Changeset 04dab8e
- Timestamp:
- 05/26/11 01:17:37 (2 years ago)
- Branches:
- master
- Children:
- 05b0395
- Parents:
- 9caef77
- git-author:
- Tomas Edwardsson <tommi@…> (05/26/11 01:17:37)
- git-committer:
- Tomas Edwardsson <tommi@…> (05/26/11 01:17:37)
- Location:
- adagios
- Files:
-
- 4 edited
-
configurator/views.py (modified) (2 diffs)
-
media/css/style.css (modified) (1 diff)
-
templates/configurator/addhost.html (modified) (1 diff)
-
urls.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
adagios/configurator/views.py
r9caef77 r04dab8e 3 3 from django.http import HttpResponse, HttpResponseServerError 4 4 from django.utils import simplejson 5 6 # For API methods 7 import json 8 import xml.marshal.generic 5 9 6 10 from doit import * … … 118 122 data = '' 119 123 if ext == 'xml': 120 import xml.marshal.generic121 124 data = xml.marshal.generic.dumps(c['host']) 125 mime_type = 'text/xml' 122 126 elif ext == 'html': 123 127 return render_to_response('configurator/api/host.html', c) 124 128 elif ext == 'json': 125 import json129 126 130 data = json.dumps(c['host']) 131 mime_type = 'application/json' 127 132 else: 128 133 return HttpResponseServerError("fle") 129 return HttpResponse(data, mimetype= 'application/javascript')134 return HttpResponse(data, mimetype=mime_type) 130 135 131 136 return NotImplementedError 132 137 133 def api_ dnslookup(request, host_name=None):138 def api_gethostbyname(request, host_name=None): 134 139 import socket 135 140 136 raise NotImplementedError 141 host = '' 142 try: 143 host = socket.gethostbyname(host_name) 144 except: 145 pass 146 147 return HttpResponse(json.dumps({'host': host}), mimetype='application/json') 137 148 138 149 -
adagios/media/css/style.css
r9caef77 r04dab8e 40 40 height: 62px; 41 41 } 42 43 #addhost .label { 44 font-weight: bold; 45 width: 180px; 46 float: left; 47 } -
adagios/templates/configurator/addhost.html
r9caef77 r04dab8e 5 5 6 6 {% block sidebar %} {% endblock %} 7 {% block content %} 7 8 {% block javascript %} 9 10 $(document).ready(function() { 11 $('#hostname').focus(); 12 }); 8 13 9 14 {% endblock %} 15 16 17 {% block content %} 18 <div id="addhost"> 19 <form action="#" method="POST"> 20 <span class="label">Hostname</span> <input id="hostname" type="text" name="hostname" /><br/> 21 <span class="label">Description</span> <input id="description" type="text" name="description" /><br/> 22 <span class="label">IP Address</span> <input id="ipaddress" type="text" name="ipaddress" /><br/> 23 </form> 24 </div> 25 26 <script type="text/javascript"> 27 $('#hostname').blur(function() { 28 if ($('#ipaddress').val() == "") { 29 $.getJSON("/adagios/api/gethostbyname/" + $('#hostname').val(), function(json) { 30 $('#ipaddress').val(json.host); 31 }); 32 } 33 }); 34 35 36 </script> 37 {% endblock %} -
adagios/urls.py
r9caef77 r04dab8e 10 10 (r'^$', 'configurator.views.home'), 11 11 (r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}), 12 (r'^adagios/api/host/(?P<host_name>.*)\.(?P<ext>.+)$', 'configurator.views.api_host'), 12 (r'^adagios/api/host/(?P<host_name>.*)\.(?P<ext>.+)$', 'configurator.views.api_host'), 13 (r'^adagios/api/gethostbyname/(?P<host_name>.*)$', 'configurator.views.api_gethostbyname'), 13 14 (r'^adagios/$', 'configurator.views.index'), 14 15 (r'^adagios/addhost$', 'configurator.views.addhost'),
Note: See TracChangeset
for help on using the changeset viewer.
