<div class="module generic_module edit_settings" id="{{ module.name }}" data-module="{{ module.name }}">

  <h2>{{ module.label }} - Settings</h2>

  <form class="inner" method="post" action="">

    {% if not module.static or module.settings %}
      {% if not module.static %}

        <div class="formrow">
          <label for="id_{{ module.name }}_poll">Poll frequency (seconds)</label>
          <input id="id_{{ module.name }}_poll" name="poll" type="text" value="{{ module.poll }}">
        </div>

        <div class="formrow">
          <label for="id_{{ module.name }}_delay">Delay in loading (seconds)</label>
          <input id="id_{{ module.name }}_delay" name="delay" type="text" value="{{ module.delay }}">
        </div>

      {% endif %}
      {% if module.settings %}

        {% for setting in module.settings %}
          <div class="formrow">
            <label for="id_{{ setting.key }}">{% if setting.link %}<a href="{{ setting.link }}" target="_blank">{% endif %}{{ setting.description }}{% if setting.link %}</a>{% endif %}</label>

            {% if setting.type == 'bool' %}
              <select id="id_{{ setting.key }}" name="{{ setting.key }}">
                <option value="0"{% if setting.value == "0" %} selected="selected"{% endif %}>No</option>
                <option value="1"{% if setting.value == "1" %} selected="selected"{% endif %}>Yes</option>
              </select>
            {% elif setting.type == 'select' %}
              <select id="id_{{ setting.key }}" name="{{ setting.key }}">
                {% for option in setting.options %}
                  <option value="{{ option.value }}"{% if setting.value == option.value %} selected="selected"{% endif %}>{{ option.label }}</option>
                {% endfor %}
              </select>
            {% else %}
              <input id="id_{{ setting.key }}" name="{{ setting.key }}" type="{% if "password" in setting.key %}password{% else %}text{% endif %}" value="{{ setting.value }}">
            {% endif %}
          </div>
        {% endfor %}

      {% endif %}

      <div class="choices">
        <div class="save">Save</div>
        <div class="cancel">Cancel</div>
      </div>

    {% else %}
      <p>This module has no editable settings.</p>

      <div class="choices">
        <div class="cancel">Cancel</div>
      </div>
    {% endif %}

  </form>

</div>
