notes & templates review

This commit is contained in:
bkfox 2024-02-21 18:57:30 +01:00
parent 722f76767e
commit d9ad3429db
4 changed files with 31 additions and 9 deletions

View File

@ -74,8 +74,9 @@ Usefull context:
<a class="nav-item" href="{% url "profile" %}" target="new"> <a class="nav-item" href="{% url "profile" %}" target="new">
{% translate "Profile" %} {% translate "Profile" %}
</a> </a>
<a class="nav-item" href="{% url 'logout' %}"> <a class="nav-item" href="{% url "logout" %}" title="{% translate "Disconnect" %}"
<i title="{% translate 'disconnect' %}" class="fa fa-power-off"></i> aria-label="{% translate "Disconnect" %}">
<i class="fa fa-power-off"></i>
</a> </a>
{% endif %} {% endif %}
{% endblock %} {% endblock %}

View File

@ -23,7 +23,6 @@
<table> <table>
{{ form.as_table }} {{ form.as_table }}
{% render_honeypot_field "website" %} {% render_honeypot_field "website" %}
</table> </table>
<br/> <br/>
<input type="submit" value="Update" class="button is-success"> <input type="submit" value="Update" class="button is-success">

View File

@ -6,6 +6,7 @@
{{ form.media }} {{ form.media }}
{% endblock %} {% endblock %}
{# FIXME: why disabling application init? #}
{% block init-scripts %} {% block init-scripts %}
{% endblock %} {% endblock %}
@ -16,12 +17,23 @@
<section class="container"> <section class="container">
<div> <div>
<form method="post" enctype="multipart/form-data">{% csrf_token %} <form method="post" enctype="multipart/form-data">{% csrf_token %}
<table> {% csrf_token %}
{{ form.as_table }} {% for field in form %}
{% render_honeypot_field "website" %} <div class="field is-horizontal">
</table> <label class="label">{{ field.label }}</label>
<br/> <div class="control">{{ field }}</div>
<input type="submit" value="Update" class="button is-success"> </div>
{% if field.errors %}
<p class="help is-danger">{{ field.errors }}</p>
{% endif %}
{% if field.help_text %}
<p class="help">{{ field.help_text|safe }}</p>
{% endif %}
{% endfor %}
<div class="has-text-right">
<button type="submit" class="button">{% translate "Update" %}</button>
</div>
</form> </form>
</div> </div>
</section> </section>

View File

@ -3,3 +3,13 @@
- don't forget to add your exported module member name to __all__ ;) - don't forget to add your exported module member name to __all__ ;)
- it is better to put forms inside aircox.forms submodule (as aircox.forms.program subfiles, etc. if the file is to big + reexport in aircox.forms.__init__) - it is better to put forms inside aircox.forms submodule (as aircox.forms.program subfiles, etc. if the file is to big + reexport in aircox.forms.__init__)
- you can eventually regroup urls under "/admin" or sth like this, in order to avoid mixing public and backoffice urls. - you can eventually regroup urls under "/admin" or sth like this, in order to avoid mixing public and backoffice urls.
- you can use fontawesome icons instead of UTF-8 ones (=> Editer sur la page d'émission, etc.): https://fontawesome.com/icons?d=gallery&m=free
- Forms:
- tables should not be used to render forms: either use flexbox or stack vertically labels and inputs. Generally, tables are in used to render data sets in modern web dev.;
- CSS framework partially use Bulma's ones (https://bulma.io/documentation/form/general/ ). You can customize form rendering by iterating over fields (example: aircox/templates/aircox/page_detail.html => comment form; no need for honeypot if user is authenticated)
- you can use template inheritance and inclusion in order to avoid repeating the code over all templates. If required you can just have base template as "page_form.html" that you can even set directly to your view classes if nothing specific is required for the model (on view class => template_name attribute). Less code = less bugs = less maintenance.
- btw some templates *_form extends from different base template.
- also, for submit button, just use class "button" (for color panel coherency). For secondary buttons, there is the css class "secondary" (as in `<button class="button secondary" />`
- you might add an `<hr>` between episode form and playlist editor;
- if you want you can also add comment management;
- you might want to use aria-label too for accessibility (eventually, aria-description). Not mandatory but still is cool to think of accessibility: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA