From 5d4849dc21d7aae7e861033ab5aa3bdeb17847c1 Mon Sep 17 00:00:00 2001 From: Ken Raffenetti Date: Wed, 13 Sep 2006 19:13:08 +0000 Subject: more web layout changes git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@2248 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Server/Hostbase/hostbase/views.py | 109 +++++++------- src/lib/Server/Hostbase/hostbase/views.pyc | Bin 19040 -> 0 bytes .../Server/Hostbase/hostbase/webtemplates/dns.html | 167 +++++---------------- .../Hostbase/hostbase/webtemplates/errors.html | 141 +++-------------- .../Hostbase/hostbase/webtemplates/host.html | 11 +- .../Server/Hostbase/hostbase/webtemplates/new.html | 163 ++++---------------- .../Hostbase/hostbase/webtemplates/results.html | 5 + 7 files changed, 160 insertions(+), 436 deletions(-) delete mode 100644 src/lib/Server/Hostbase/hostbase/views.pyc (limited to 'src') diff --git a/src/lib/Server/Hostbase/hostbase/views.py b/src/lib/Server/Hostbase/hostbase/views.py index d2321e364..48e924ddc 100644 --- a/src/lib/Server/Hostbase/hostbase/views.py +++ b/src/lib/Server/Hostbase/hostbase/views.py @@ -103,18 +103,61 @@ def look(request, host_id): host = Host.objects.get(id=host_id) interfaces = [] for interface in host.interface_set.all(): - interfaces.append((interface, interface.ip_set.all())) - comments = [line for line in host.comments.split("\n")] + interfaces.append([interface, interface.ip_set.all()]) return render_to_response('%s/host.html' % templatedir, {'host': host, - 'interfaces': interfaces, - 'comments': comments}) + 'interfaces': interfaces}) def dns(request, host_id): - temp = Template(open('%s/dns.html' % templatedir).read()) - hostdata = gethostdata(host_id, True) - temp = fill(temp, hostdata, True) - return HttpResponse(str(temp)) + host = Host.objects.get(id=host_id) + ips = [] + info = [] + cnames = [] + mxs = [] + for interface in host.interface_set.all(): + ips.extend(interface.ip_set.all()) + for ip in ips: + info.append([ip, ip.name_set.all()]) + for name in ip.name_set.all(): + cnames.extend(name.cname_set.all()) + mxs.append((name.id, name.mxs.all())) + return render_to_response('%s/dns.html' % templatedir, + {'host': host, + 'info': info, + 'cnames': cnames, + 'mxs': mxs}) + +def gethostdata(host_id, dnsdata=False): + """Grabs the necessary data about a host + Replaces a lot of repeated code""" + hostdata = {} + hostdata['ips'] = {} + hostdata['names'] = {} + hostdata['cnames'] = {} + hostdata['mxs'] = {} + hostdata['host'] = Host.objects.get(id=host_id) + hostdata['interfaces'] = hostdata['host'].interface_set.all() + for interface in hostdata['interfaces']: + hostdata['ips'][interface.id] = interface.ip_set.all() + if dnsdata: + for ip in hostdata['ips'][interface.id]: + hostdata['names'][ip.id] = ip.name_set.all() + for name in hostdata['names'][ip.id]: + hostdata['cnames'][name.id] = name.cname_set.all() + hostdata['mxs'][name.id] = name.mxs.all() + return hostdata + +def fill(template, hostdata, dnsdata=False): + """Fills a generic template + Replaces a lot of repeated code""" + if dnsdata: + template.names = hostdata['names'] + template.cnames = hostdata['cnames'] + template.mxs = hostdata['mxs'] + template.host = hostdata['host'] + template.interfaces = hostdata['interfaces'] + template.ips = hostdata['ips'] + return template def edit(request, host_id): """Edit general host information @@ -385,39 +428,6 @@ def dnsedit(request, host_id): temp = fill(temp, hostdata, True) temp.request = request return HttpResponse(str(temp)) - -def gethostdata(host_id, dnsdata=False): - """Grabs the necessary data about a host - Replaces a lot of repeated code""" - hostdata = {} - hostdata['ips'] = {} - hostdata['names'] = {} - hostdata['cnames'] = {} - hostdata['mxs'] = {} - hostdata['host'] = Host.objects.get(id=host_id) - hostdata['interfaces'] = hostdata['host'].interface_set.all() - for interface in hostdata['interfaces']: - hostdata['ips'][interface.id] = interface.ip_set.all() - if dnsdata: - for ip in hostdata['ips'][interface.id]: - hostdata['names'][ip.id] = ip.name_set.all() - for name in hostdata['names'][ip.id]: - hostdata['cnames'][name.id] = name.cname_set.all() - hostdata['mxs'][name.id] = name.mxs.all() - return hostdata - -def fill(template, hostdata, dnsdata=False): - """Fills a generic template - Replaces a lot of repeated code""" - if dnsdata: - template.names = hostdata['names'] - template.cnames = hostdata['cnames'] - template.mxs = hostdata['mxs'] - template.host = hostdata['host'] - template.interfaces = hostdata['interfaces'] - template.ips = hostdata['ips'] - return template - def new(request): """Function for creating a new host in hostbase @@ -435,9 +445,8 @@ def new(request): host.status = 'active' host.save() else: - temp = Template(open('%s/errors.html' % templatedir).read()) - temp.failures = validate(request, True) - return HttpResponse(str(temp)) + return render_to_response('%s/errors.html' % templatedir, + {'failures': validate(request, True)}) if request.POST['mac_addr_new']: new_inter = Interface(host=host, mac_addr=request.POST['mac_addr_new'], @@ -558,13 +567,11 @@ def new(request): host.save() return HttpResponseRedirect('/hostbase/%s/' % host.id) else: - temp = Template(open('%s/new.html' % templatedir).read()) - temp.TYPE_CHOICES = Interface.TYPE_CHOICES - temp.NETGROUP_CHOICES = Host.NETGROUP_CHOICES - temp.CLASS_CHOICES = Host.CLASS_CHOICES - temp.SUPPORT_CHOICES = Host.SUPPORT_CHOICES - temp.failures = False - return HttpResponse(str(temp)) + return render_to_response('%s/new.html' % templatedir, + {'TYPE_CHOICES': Interface.TYPE_CHOICES, + 'NETGROUP_CHOICES': Host.NETGROUP_CHOICES, + 'CLASS_CHOICES': Host.CLASS_CHOICES, + 'SUPPORT_CHOICES': Host.SUPPORT_CHOICES}) def validate(request, new=False, host_id=None): """Function for checking form data""" diff --git a/src/lib/Server/Hostbase/hostbase/views.pyc b/src/lib/Server/Hostbase/hostbase/views.pyc deleted file mode 100644 index 24619902c..000000000 Binary files a/src/lib/Server/Hostbase/hostbase/views.pyc and /dev/null differ diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/dns.html b/src/lib/Server/Hostbase/hostbase/webtemplates/dns.html index a937fb833..79db89e5a 100644 --- a/src/lib/Server/Hostbase/hostbase/webtemplates/dns.html +++ b/src/lib/Server/Hostbase/hostbase/webtemplates/dns.html @@ -1,133 +1,42 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - -
Argonne National Laboratory
- Mathematics - and Computer Science
- - - - - - - - - - - - - - - - - - - - - - - - - -
-
MCS - Home > - -
- - - -
-DNS Information for host "$host.hostname" +{% extends "base.html" %} - #for $interface in $interfaces - #for $ip in $ips[$interface.id] -
  • ip_addr: $ip.ip_addr
  • - #for $name in $names[$ip.id] -
    • name: $name.name
      • - #for $cname in $cnames[$name.id] -
      • cname: $cname.cname
      • - #end for - #for $mx in $mxs[$name.id] -
      • mx: $mx.priority $mx.mx
      • - #end for +{% block pagebanner %} +
        +

        dns info for {{ host.hostname }}

        +
        +
        +{% endblock %} + +{% block sidebar %} +new search + +{% endblock %} + +{% block content %} + + {% for ip in info %} +
        • ip_addr: {{ ip.0.ip_addr }}
        • + {% for name in ip.1 %} +
          • name: {{ name.name }}
            • + {% for cname in cnames %} + {% ifequal cname.name_id name.id %} +
            • cname: {{ cname.cname }}
            • + {% endifequal %} + {% endfor %} + {% for mx in mxs %} + {% ifequal mx.0 name.id %} + {% for record in mx.1 %} +
            • mx: {{ record.priority }} {{ record.mx }}
            • + {% endfor %} + {% endifequal %} + {% endfor %}
          - #end for + {% endfor %}
        - #end for - #end for -
- - - - - - - - - -

- - - - - - -
U.S. Department of EnergyThe University of ChicagoOffice of Science - Department of Energy
- - - -
Privacy & Security Notice | Contact Us
- - + {% endfor %} +{% endblock %} diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/errors.html b/src/lib/Server/Hostbase/hostbase/webtemplates/errors.html index 83f5cd014..47d32ede4 100644 --- a/src/lib/Server/Hostbase/hostbase/webtemplates/errors.html +++ b/src/lib/Server/Hostbase/hostbase/webtemplates/errors.html @@ -1,126 +1,27 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - -
Argonne National Laboratory
- Mathematics - and Computer Science
- - - - - - - - - - - - - - - - - - - - - - - - - -
-
MCS - Home > - -
- - - -
-#if $failures +{% extends "base.html" %} + +{% block pagebanner %} +
+

Search Results

+
+
+{% endblock %} + +{% block sidebar %} +new search +{% endblock %} + +{% block content %} + +{% if failures %} There were errors in the following fields

-#for $failure in $failures +{% for failure in failures %} -$failure
+{{ failure }}
-#end for -#end if +{% endfor %} +{% endif %}
Press the back button on your browser and edit those field(s) -
- - - - - - - - - -

- - - - - - -
U.S. Department of EnergyThe University of ChicagoOffice of Science - Department of Energy
- - - -
Privacy & Security Notice | Contact Us
- - - +{% endblock %} \ No newline at end of file diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/host.html b/src/lib/Server/Hostbase/hostbase/webtemplates/host.html index 1a89ea6c1..f66c935f2 100644 --- a/src/lib/Server/Hostbase/hostbase/webtemplates/host.html +++ b/src/lib/Server/Hostbase/hostbase/webtemplates/host.html @@ -8,10 +8,11 @@ {% endblock %} {% block sidebar %} +new search {% endblock %} @@ -69,9 +70,7 @@ {% endfor %} comments - {% for line in comments %} - {{ line }}
- {% endfor %} + {{ host.comments|linebreaksbr }}
diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/new.html b/src/lib/Server/Hostbase/hostbase/webtemplates/new.html index bb00e57b0..7ed664368 100644 --- a/src/lib/Server/Hostbase/hostbase/webtemplates/new.html +++ b/src/lib/Server/Hostbase/hostbase/webtemplates/new.html @@ -1,87 +1,19 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - -
Argonne National Laboratory
- Mathematics - and Computer Science
- - - - - - - - - - - - - - - - - - - - - - - - - -
-
MCS - Home > - -
- - @@ -134,18 +66,18 @@ @@ -157,35 +89,6 @@

- - -

- Enter new host information +{% extends "base.html" %} + +{% block pagebanner %} +
+

new host information

+
+
+{% endblock %} + +{% block sidebar %} + +{% endblock %} + +{% block content %}
@@ -96,24 +28,24 @@
netgroup
class
support
csi
expiration_date YYYY-MM-DD

Interface

- #for $choice in $TYPE_CHOICES - $choice[1] - #end for + {% for choice in TYPE_CHOICES %} + {{ choice.1 }} + {% endfor %}
mac_addr
ip_addr

Interface

- #for $choice in $TYPE_CHOICES - $choice[1] - #end for + {% for choice in TYPE_CHOICES %} + {{ choice.1 }} + {% endfor %}
mac_addr
- - - - - - - - - -

- - - - - - -
U.S. Department of EnergyThe University of ChicagoOffice of Science - Department of Energy
- - - -
Privacy & Security Notice | Contact Us
- - + +{% endblock %} diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/results.html b/src/lib/Server/Hostbase/hostbase/webtemplates/results.html index 4413e0527..3db1a8c9b 100644 --- a/src/lib/Server/Hostbase/hostbase/webtemplates/results.html +++ b/src/lib/Server/Hostbase/hostbase/webtemplates/results.html @@ -6,6 +6,11 @@
{% endblock %} + +{% block sidebar %} +new search +{% endblock %} + {% block content %} {% if hosts %} -- cgit v1.2.3-1-g7c22