homedjagios for all

Templates

The default theme contains different pages. Some of them are discussed here more to enable people to see how djacios works. However to completely understand the way tempates work you need to read the Dango documentation.

examples:

index.html

The main page for this theme, it is used as base template for all the other pages. Here the general layout is set and the menu block is defined.

Right now the menu uses 4 different access levels. Each person that logs on must have at least one of following permissions:
  • core.add_host: to be able to add hosts to the config
  • core.change_service: to be able to add or remove services from hosts
  • core.delete_host: to be able to remove hosts from the configuration
  • staff: to be able to go into the admin section

This is achieved by checking this in the template like this:

{% if user.is_authenticated %}
    {% if user.is_staff %}
    ...
    {% endif %}
    {% if perms.core.add_host %}
    ...
    {% endif %}
    {% if perms.core.change_service %}
    ...
    {% endif %}
    {% if perms.core.delete_host %}
    ...
    {% endif %}
{% endif %}

Permissions can be set in the admin section of your installation.

home.html

The content for the home page (simple text)

hostadd.html

Extends index.html and adds a simple default form:

{% block content %}
<form method="POST" action="/host/add/">
    <table>
      {{ form }}
    </table>
    <input type='submit' value='add to nagios'>
</form>
{% endblock content %}

The form is defined as:

class HostForm(forms.Form):
    name = forms.CharField(label='Server Name', max_length=50)
    address = forms.CharField(label='Servers Address (dns or IP)', max_length=50)
    template = forms.ModelChoiceField(label='Template', queryset=Host.objects.filter(register=False).order_by('name'))

Table Of Contents

Previous topic

Utils

This Page