~hristoast/mousikofidi

e4f07a7114a0f148778c7d5949616129111f80f0 — Hristos N. Triantafillou 9 months ago 26dd7b8
Clean up the settings page

Now it's a table layout with one submit button, using one form element
instead of two separate ones.
2 files changed, 36 insertions(+), 27 deletions(-)

M mousikofidi/templates/settings.html
M test_mousikofidi.py
M mousikofidi/templates/settings.html => mousikofidi/templates/settings.html +35 -19
@@ 8,25 8,41 @@
    <p>This will always override the "Light" theme setting here!</p>
  </div>

  <form class="center" id="theme-picker" action="{{ url_for('.settings_edit') }}" method="post">
    <label>{% if icons %}<i class="fas fa-palette"></i> {% endif %}Select your theme:
      <select class="center" name="theme">
        {% for t in themes %}
          <option value="{{ t.name }}"{% if t.name in theme %} selected{% endif %}>{{ t.proper }}</option>
        {% endfor %}
      </select>
      <input style="margin:0 auto; margin-top:10px;" class="center" type="submit" value="Submit">
    </label>
  </form>
  <form class="center" id="settings" action="{{ url_for('.settings_edit') }}" method="post">
    <table style="margin: 0 auto;">
      <thead>
        <tr></tr>
      </thead>
      <tbody>

  <form class="center" id="icons-toggle" action="{{ url_for('.settings_edit') }}" method="post">
    <label>{% if icons %}<i class="fas fa-icons"></i> {% endif %}Enable or disable icons:
      <select class="center" name="icons">
        <option value="disabled"{% if not icons %} selected{% endif %}>Disabled</option>
        <option value="enabled"{% if icons %} selected{% endif %}>Enabled</option>
      </select>
      <input style="margin:0 auto; margin-top:10px;" class="center" type="submit" value="Submit">
    </label>
  </form>
        <tr>
          <td>
            <label>{% if icons %}<i class="fas fa-palette"></i> {% endif %}Theme selection</label>
          </td>
          <td>
            <select class="center" name="theme">
              {% for t in themes %}
                <option value="{{ t.name }}"{% if t.name in theme %} selected{% endif %}>{{ t.proper }}</option>
              {% endfor %}
            </select>
          </td>
        </tr>

        <tr>
          <td>
            <label>{% if icons %}<i class="fas fa-icons"></i> {% endif %}Enable or disable icons
            </label>
          </td>
          <td>
            <select class="center" name="icons">
              <option value="disabled"{% if not icons %} selected{% endif %}>Disabled</option>
              <option value="enabled"{% if icons %} selected{% endif %}>Enabled</option>
            </select>
          </td>
        </tr>

      </tbody>
    </table>
    <input style="margin:0 auto; margin-top:10px;" class="center" type="submit" value="Submit">
  </form>
{% endblock %}

M test_mousikofidi.py => test_mousikofidi.py +1 -8
@@ 3997,20 3997,13 @@ def test_settings(client):
    assert rv.status == "200 OK"
    assert (
        bytes(
            '<form class="center" id="theme-picker" action="/settings/edit" method="post">',
            '<form class="center" id="settings" action="/settings/edit" method="post">',
            "utf8",
        )
        in rv.data
    )
    assert bytes('<option value="dark" selected>Dark</option>', "utf8") in rv.data
    assert (
        bytes(
            '<form class="center" id="icons-toggle" action="/settings/edit" method="post">',
            "utf8",
        )
        in rv.data
    )
    assert (
        bytes('<option value="disabled" selected>Disabled</option>', "utf8") in rv.data
    )