diff options
Diffstat (limited to 'src/lib/Server/Hostbase/hostbase')
19 files changed, 66 insertions, 22 deletions
diff --git a/src/lib/Server/Hostbase/hostbase/models.py b/src/lib/Server/Hostbase/hostbase/models.py index 3216944ea..613701685 100644 --- a/src/lib/Server/Hostbase/hostbase/models.py +++ b/src/lib/Server/Hostbase/hostbase/models.py @@ -65,8 +65,8 @@ class Host(models.Model): class Interface(models.Model): TYPE_CHOICES = ( - ('eth', 'ethernet'), ('wl', 'wireless'), ('myr', 'myr'), - ('mgmt', 'mgmt'), ('tape', 'tape'), ('fe', 'fe') + ('eth', 'ethernet'), ('wl', 'wireless'), ('virtual', 'virtual'), ('myr', 'myr'), + ('mgmt', 'mgmt'), ('tape', 'tape'), ('fe', 'fe'), ('ge', 'ge') ) host = models.ForeignKey(Host, edit_inline=models.TABULAR, num_in_admin=2) mac_addr = models.CharField(maxlength=32, core=True) diff --git a/src/lib/Server/Hostbase/hostbase/views.py b/src/lib/Server/Hostbase/hostbase/views.py index 3807b8283..b88083c94 100644 --- a/src/lib/Server/Hostbase/hostbase/views.py +++ b/src/lib/Server/Hostbase/hostbase/views.py @@ -52,7 +52,7 @@ dispatch = {'mac_addr':'i.mac_addr LIKE \'%%%%%s%%%%\'', ## t.TYPE_CHOICES = Interface.TYPE_CHOICES ## t.failures = False ## return HttpResponse(str(t)) - + def search(request): """Search for hosts in the database If more than one field is entered, logical AND is used @@ -92,12 +92,15 @@ def search(request): cursor.execute(querystring) results = cursor.fetchall() - return render_to_response('results.html', {'hosts': results}) + return render_to_response('results.html', + {'hosts': results, + 'logged_in': request.session.get('_auth_user_id', False)}) else: return render_to_response('search.html', {'TYPE_CHOICES': Interface.TYPE_CHOICES, 'DNS_CHOICES': Name.DNS_CHOICES, - 'yesno': [(1, 'yes'), (0, 'no')]}) + 'yesno': [(1, 'yes'), (0, 'no')], + 'logged_in': request.session.get('_auth_user_id', False)}) def look(request, host_id): @@ -108,7 +111,8 @@ def look(request, host_id): interfaces.append([interface, interface.ip_set.all()]) return render_to_response('host.html', {'host': host, - 'interfaces': interfaces}) + 'interfaces': interfaces, + 'logged_in': request.session.get('_auth_user_id', False)}) def dns(request, host_id): host = Host.objects.get(id=host_id) @@ -127,7 +131,9 @@ def dns(request, host_id): {'host': host, 'info': info, 'cnames': cnames, - 'mxs': mxs}) + 'mxs': mxs, + 'logged_in': request.session.get('_auth_user_id', False)}) + def gethostdata(host_id, dnsdata=False): """Grabs the necessary data about a host @@ -308,7 +314,8 @@ def edit(request, host_id): return HttpResponseRedirect('/hostbase/%s/' % host.id) else: return render_to_response('errors.html', - {'failures': validate(request, False, host_id)}) + {'failures': validate(request, False, host_id), + 'logged_in': request.session.get('_auth_user_id', False)}) else: host = Host.objects.get(id=host_id) interfaces = [] @@ -317,7 +324,8 @@ def edit(request, host_id): return render_to_response('edit.html', {'host': host, 'interfaces': interfaces, - 'TYPE_CHOICES': Interface.TYPE_CHOICES}) + 'TYPE_CHOICES': Interface.TYPE_CHOICES, + 'logged_in': request.session.get('_auth_user_id', False)}) def confirm(request, item, item_id, host_id=None, name_id=None, zone_id=None): """Asks if the user is sure he/she wants to remove an item""" @@ -412,7 +420,8 @@ def confirm(request, item, item_id, host_id=None, name_id=None, zone_id=None): 'zonemx': zonemx, 'nameserver': nameserver, 'address': address, - 'zone_id': zone_id}) + 'zone_id': zone_id, + 'logged_in': request.session.get('_auth_user_id', False)}) def dnsedit(request, host_id): """Edits specific DNS information @@ -483,7 +492,8 @@ def dnsedit(request, host_id): 'mxs': mxs, 'request': request, 'interfaces': interfaces, - 'DNS_CHOICES': Name.DNS_CHOICES}) + 'DNS_CHOICES': Name.DNS_CHOICES, + 'logged_in': request.session.get('_auth_user_id', False)}) def new(request): """Function for creating a new host in hostbase @@ -492,7 +502,8 @@ def new(request): try: Host.objects.get(hostname=request.POST['hostname'].lower()) return render_to_response('errors.html', - {'failures': ['%s already exists in hostbase' % request.POST['hostname']]}) + {'failures': ['%s already exists in hostbase' % request.POST['hostname']], + 'logged_in': request.session.get('_auth_user_id', False)}) except: pass if not validate(request, True): @@ -512,7 +523,9 @@ def new(request): host.save() else: return render_to_response('errors.html', - {'failures': validate(request, True)}) + {'failures': validate(request, True), + 'logged_in': request.session.get('_auth_user_id', False)}) + if request.POST['mac_addr_new']: new_inter = Interface(host=host, mac_addr=request.POST['mac_addr_new'], @@ -638,7 +651,8 @@ def new(request): 'NETGROUP_CHOICES': Host.NETGROUP_CHOICES, 'CLASS_CHOICES': Host.CLASS_CHOICES, 'SUPPORT_CHOICES': Host.SUPPORT_CHOICES, - 'WHATAMI_CHOICES': Host.WHATAMI_CHOICES}) + 'WHATAMI_CHOICES': Host.WHATAMI_CHOICES, + 'logged_in': request.session.get('_auth_user_id', False)}) def remove(request, host_id): host = Host.objects.get(id=host_id) @@ -659,7 +673,8 @@ def remove(request, host_id): interfaces.append([interface, interface.ip_set.all()]) return render_to_response('remove.html', {'host': host, - 'interfaces': interfaces}) + 'interfaces': interfaces, + 'logged_in': request.session.get('_auth_user_id', False)}) def validate(request, new=False, host_id=None): """Function for checking form data""" @@ -753,7 +768,8 @@ def validate(request, new=False, host_id=None): def zones(request): zones = Zone.objects.all() return render_to_response('zones.html', - {'zones': zones}) + {'zones': zones, + 'logged_in': request.session.get('_auth_user_id', False)}) def zoneview(request, zone_id): zone = Zone.objects.get(id=zone_id) @@ -761,7 +777,8 @@ def zoneview(request, zone_id): {'zone': zone, 'nameservers': zone.nameservers.all(), 'mxs': zone.mxs.all(), - 'addresses': zone.addresses.all() + 'addresses': zone.addresses.all(), + 'logged_in': request.session.get('_auth_user_id', False) }) def zoneedit(request, zone_id): @@ -819,7 +836,8 @@ def zoneedit(request, zone_id): {'zone': zone, 'nameservers': zone.nameservers.all(), 'mxs': zone.mxs.all(), - 'addresses': zone.addresses.all() + 'addresses': zone.addresses.all(), + 'logged_in': request.session.get('_auth_user_id', False) }) def zonenew(request): @@ -827,7 +845,9 @@ def zonenew(request): try: Zone.objects.get(zone=request.POST['zone']) return render_to_response('errors.html', - {'failures': ['%s already exists in database' % request.POST['zone']]}) + {'failures': ['%s already exists in database' % request.POST['zone']], + 'logged_in': request.session.get('_auth_user_id', False)}) + except: zone = Zone(zone=request.POST['zone']) for attrib in zoneattribs: @@ -859,7 +879,8 @@ def zonenew(request): return render_to_response('zonenew.html', {'nameservers': range(0,4), 'mxs': range(0,2), - 'addresses': range(0,2) + 'addresses': range(0,2), + 'logged_in': request.session.get('_auth_user_id', False) }) if settings.CFG_TYPE == 'environ': diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/confirm.html b/src/lib/Server/Hostbase/hostbase/webtemplates/confirm.html index f1f90939e..bc3e7f447 100644 --- a/src/lib/Server/Hostbase/hostbase/webtemplates/confirm.html +++ b/src/lib/Server/Hostbase/hostbase/webtemplates/confirm.html @@ -9,6 +9,7 @@ {% block sidebar %} {% include "navbar" %} +{% include "logout" %} {% endblock %} {% block content %} diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/dns.html b/src/lib/Server/Hostbase/hostbase/webtemplates/dns.html index 1db012852..5d5a31b95 100644 --- a/src/lib/Server/Hostbase/hostbase/webtemplates/dns.html +++ b/src/lib/Server/Hostbase/hostbase/webtemplates/dns.html @@ -14,6 +14,7 @@ <li><a href="/hostbase/{{ host.id }}/edit/" class="sidebar">edit host info</a></li> <li><a href="edit/" class="sidebar">edit dns info</a></li> </ul> +{% include "logout" %} {% endblock %} {% block content %} diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/dnsedit.html b/src/lib/Server/Hostbase/hostbase/webtemplates/dnsedit.html index 1d6245e81..0385daa86 100644 --- a/src/lib/Server/Hostbase/hostbase/webtemplates/dnsedit.html +++ b/src/lib/Server/Hostbase/hostbase/webtemplates/dnsedit.html @@ -14,6 +14,7 @@ <li><a href="/hostbase/{{ host.id }}/edit/" class="sidebar">edit host info</a></li> <li><a href="edit/" class="sidebar">edit dns info</a></li> </ul> +{% include "logout" %} {% endblock %} {% block content %} diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/edit.html b/src/lib/Server/Hostbase/hostbase/webtemplates/edit.html index 0785b64e8..49e054e8a 100644 --- a/src/lib/Server/Hostbase/hostbase/webtemplates/edit.html +++ b/src/lib/Server/Hostbase/hostbase/webtemplates/edit.html @@ -14,6 +14,7 @@ <li><a href="/hostbase/{{ host.id }}/dns/" class="sidebar">detailed dns info</a></li> <li><a href="/hostbase/{{ host.id }}/dns/edit/" class="sidebar">edit dns info</a></li> </ul> +{% include "logout" %} {% endblock %} {% block content %} diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/errors.html b/src/lib/Server/Hostbase/hostbase/webtemplates/errors.html index d321c529f..724bf9c34 100644 --- a/src/lib/Server/Hostbase/hostbase/webtemplates/errors.html +++ b/src/lib/Server/Hostbase/hostbase/webtemplates/errors.html @@ -9,6 +9,7 @@ {% block sidebar %} {% include "navbar" %} +{% include "logout" %} {% endblock %} {% block content %} diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/host.html b/src/lib/Server/Hostbase/hostbase/webtemplates/host.html index 088befe88..2f557cf73 100644 --- a/src/lib/Server/Hostbase/hostbase/webtemplates/host.html +++ b/src/lib/Server/Hostbase/hostbase/webtemplates/host.html @@ -14,6 +14,7 @@ <li><a href="edit/" class="sidebar">edit host info</a></li> <li><a href="dns/edit/" class="sidebar">edit dns info</a></li> </ul> +{% include "logout" %} {% endblock %} {% block content %} diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/login.html b/src/lib/Server/Hostbase/hostbase/webtemplates/login.html index 5a5650d22..e46ccc086 100644 --- a/src/lib/Server/Hostbase/hostbase/webtemplates/login.html +++ b/src/lib/Server/Hostbase/hostbase/webtemplates/login.html @@ -21,7 +21,11 @@ <input name="password" type="password"> <br /> <input type="submit" value="Login"> + {% if next %} <input type="hidden" name="next" value="{{ next }}" /> + {% else %} + <input type="hidden" name="next" value="/hostbase/" /> + {% endif %} </form> {% endif %} diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/logout b/src/lib/Server/Hostbase/hostbase/webtemplates/logout new file mode 100644 index 000000000..9fa46236f --- /dev/null +++ b/src/lib/Server/Hostbase/hostbase/webtemplates/logout @@ -0,0 +1,5 @@ +{% if logged_in %} +<p> <a href="/logout/" class="sidebar">logout</a> +{% else %} +<p> <a href="/login/" class="sidebar">login</a> +{% endif %}
\ No newline at end of file diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/navbar b/src/lib/Server/Hostbase/hostbase/webtemplates/navbar index 32ef99177..6efcee7a1 100644 --- a/src/lib/Server/Hostbase/hostbase/webtemplates/navbar +++ b/src/lib/Server/Hostbase/hostbase/webtemplates/navbar @@ -1,4 +1,4 @@ <a href="/hostbase/" class="sidebar">new search</a><br> <a href="/hostbase/new" class="sidebar">add a new host</a><br> -<a href="/hostbase/zones" class="sidebar">zone file information</a> +<a href="/hostbase/zones" class="sidebar">zone file information</a><br> diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/new.html b/src/lib/Server/Hostbase/hostbase/webtemplates/new.html index bcec42404..c965d5af4 100644 --- a/src/lib/Server/Hostbase/hostbase/webtemplates/new.html +++ b/src/lib/Server/Hostbase/hostbase/webtemplates/new.html @@ -9,6 +9,7 @@ {% block sidebar %} <a href="/hostbase/" class="sidebar">search hostbase</a> +{% include "logout" %} {% endblock %} {% block content %} diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/remove.html b/src/lib/Server/Hostbase/hostbase/webtemplates/remove.html index 19c73b4f9..6dfe5aa18 100644 --- a/src/lib/Server/Hostbase/hostbase/webtemplates/remove.html +++ b/src/lib/Server/Hostbase/hostbase/webtemplates/remove.html @@ -14,6 +14,7 @@ <li><a href="edit/" class="sidebar">edit host info</a></li> <li><a href="dns/edit/" class="sidebar">edit dns info</a></li> </ul> +{% include "logout" %} {% endblock %} {% block content %} diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/results.html b/src/lib/Server/Hostbase/hostbase/webtemplates/results.html index 584453f98..43cb78f67 100644 --- a/src/lib/Server/Hostbase/hostbase/webtemplates/results.html +++ b/src/lib/Server/Hostbase/hostbase/webtemplates/results.html @@ -9,6 +9,7 @@ {% block sidebar %} {% include "navbar" %} +{% include "logout" %} {% endblock %} {% block content %} diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/search.html b/src/lib/Server/Hostbase/hostbase/webtemplates/search.html index 31f9d5184..1c869f0d7 100644 --- a/src/lib/Server/Hostbase/hostbase/webtemplates/search.html +++ b/src/lib/Server/Hostbase/hostbase/webtemplates/search.html @@ -10,7 +10,8 @@ {% block sidebar %} <a href="/hostbase/new" class="sidebar">add a new host</a><br> -<a href="/hostbase/zones" class="sidebar">zone file information</a> +<a href="/hostbase/zones" class="sidebar">zone file information</a><br> +{% include "logout" %} {% endblock %} {% block content %} diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/zoneedit.html b/src/lib/Server/Hostbase/hostbase/webtemplates/zoneedit.html index c86268614..d1cf08f17 100644 --- a/src/lib/Server/Hostbase/hostbase/webtemplates/zoneedit.html +++ b/src/lib/Server/Hostbase/hostbase/webtemplates/zoneedit.html @@ -14,6 +14,7 @@ <li><a href="/hostbase/zones/{{ zone.id }}/" class="sidebar">view zone</a><br> </li> </ul> +{% include "logout" %} {% endblock %} {% block content %} diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/zonenew.html b/src/lib/Server/Hostbase/hostbase/webtemplates/zonenew.html index 12ea3e484..b3d12f9f8 100644 --- a/src/lib/Server/Hostbase/hostbase/webtemplates/zonenew.html +++ b/src/lib/Server/Hostbase/hostbase/webtemplates/zonenew.html @@ -10,6 +10,7 @@ {% block sidebar %} {% include "navbar" %} +{% include "logout" %} {% endblock %} {% block content %} diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/zones.html b/src/lib/Server/Hostbase/hostbase/webtemplates/zones.html index dcf9a3431..b8808f8a8 100644 --- a/src/lib/Server/Hostbase/hostbase/webtemplates/zones.html +++ b/src/lib/Server/Hostbase/hostbase/webtemplates/zones.html @@ -10,6 +10,7 @@ {% block sidebar %} {% include "navbar" %} +{% include "logout" %} {% endblock %} {% block content %} diff --git a/src/lib/Server/Hostbase/hostbase/webtemplates/zoneview.html b/src/lib/Server/Hostbase/hostbase/webtemplates/zoneview.html index 712ec98bc..e4a3a3fde 100644 --- a/src/lib/Server/Hostbase/hostbase/webtemplates/zoneview.html +++ b/src/lib/Server/Hostbase/hostbase/webtemplates/zoneview.html @@ -14,6 +14,7 @@ <li><a href="/hostbase/zones/{{ zone.id }}/edit/" class="sidebar">edit zone</a><br> </li> </ul> +{% include "logout" %} {% endblock %} {% block content %} |