Migra formularios de gastos/ingresos/cuentas/etc al parcial comun
Sustituye {{ form.as_p }} (o el bucle for field in form repetido a
mano en expense_form.html) por {% include "expenses/_form_fields.html" %}
y anade class="app-form" al <form> en:
- categories/form.html, categories/list.html (alta de categoria)
- expenses/account_form.html
- expenses/expense_form.html
- expenses/income_form.html
- expenses/tag_form.html
- fuel/create.html
- goals/form.html
- registration/login.html
De paso:
- categories/list.html: se corrige indentacion de la tabla y las
etiquetas <a> de "Editar"/"Eliminar" (estaban dentro de una celda
sin problema funcional, solo desalineadas) y se anade una <th> vacia
para la columna de acciones.
- goals/form.html: el bloque title y el <h1> tenian "Nuevo objetivo"
fijo aunque la vista goal_edit ya pasa title="Editar objetivo" en el
contexto; ahora la plantilla usa {{ title }}, asi que el formulario
de edicion deja de decir "Nuevo objetivo" por error.
No se toca la logica de las vistas ni los formularios en forms.py.
This commit is contained in:
parent
d70d0e4239
commit
581eb202c7
@ -7,9 +7,9 @@
|
||||
{% block content %}
|
||||
<h2>Editar categoría</h2>
|
||||
|
||||
<form method="post">
|
||||
<form method="post" class="app-form">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
{% include "expenses/_form_fields.html" %}
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn-primary">Guardar</button>
|
||||
<a class="btn btn-secondary" href="{% url 'category_list' %}">Cancelar</a>
|
||||
|
||||
@ -9,9 +9,9 @@
|
||||
<h1>Mis categorías</h1>
|
||||
|
||||
<h3>Nueva categoría</h3>
|
||||
<form method="post">
|
||||
<form method="post" class="app-form">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
{% include "expenses/_form_fields.html" %}
|
||||
<button type="submit" class="btn btn-primary">Crear</button>
|
||||
</form>
|
||||
|
||||
@ -24,6 +24,7 @@
|
||||
<tr>
|
||||
<th>Categoría</th>
|
||||
<th>Categoría padre</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
@ -10,9 +10,9 @@
|
||||
{% endif %}
|
||||
</h1>
|
||||
|
||||
<form method="post">
|
||||
<form method="post" class="app-form">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
{% include "expenses/_form_fields.html" %}
|
||||
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn-primary">Guardar</button>
|
||||
|
||||
@ -17,34 +17,10 @@
|
||||
{% endif %}
|
||||
</h1>
|
||||
|
||||
<form method="post">
|
||||
<form method="post" class="app-form">
|
||||
{% csrf_token %}
|
||||
|
||||
{% for field in form %}
|
||||
{% if field.name == "tags" %}
|
||||
<div class="form-field">
|
||||
{{ field.label_tag }}
|
||||
<div class="tag-chip-list">
|
||||
{% for checkbox in field %}
|
||||
<label class="tag-chip">
|
||||
{{ checkbox.tag }}
|
||||
<span>{{ checkbox.choice_label }}</span>
|
||||
</label>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% if field.errors %}
|
||||
<div class="form-errors">{{ field.errors }}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% else %}
|
||||
<p>
|
||||
{{ field.label_tag }} {{ field }}
|
||||
{% if field.errors %}
|
||||
<span class="form-errors">{{ field.errors }}</span>
|
||||
{% endif %}
|
||||
</p>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% include "expenses/_form_fields.html" %}
|
||||
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
|
||||
@ -16,9 +16,9 @@
|
||||
{% endif %}
|
||||
</h1>
|
||||
|
||||
<form method="post">
|
||||
<form method="post" class="app-form">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
{% include "expenses/_form_fields.html" %}
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
{% if form.instance.pk %}
|
||||
|
||||
@ -3,9 +3,9 @@
|
||||
{% block content %}
|
||||
<h1>Etiqueta</h1>
|
||||
|
||||
<form method="post">
|
||||
<form method="post" class="app-form">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
{% include "expenses/_form_fields.html" %}
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn-primary">Guardar</button>
|
||||
<a class="btn btn-secondary" href="{% url 'tag_list' %}">Volver</a>
|
||||
|
||||
@ -17,10 +17,10 @@
|
||||
{% endif %}
|
||||
</h1>
|
||||
|
||||
<form method="post">
|
||||
<form method="post" class="app-form">
|
||||
{% csrf_token %}
|
||||
{% if next %}<input type="hidden" name="next" value="{{ next }}">{% endif %}
|
||||
{{ form.as_p }}
|
||||
{% include "expenses/_form_fields.html" %}
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
{% if editing %}
|
||||
|
||||
@ -1,16 +1,16 @@
|
||||
{% extends "expenses/base.html" %}
|
||||
{% block title %}
|
||||
Nuevo objetivo
|
||||
{{ title }}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>
|
||||
Nuevo objetivo
|
||||
{{ title }}
|
||||
</h1>
|
||||
|
||||
<form method="post">
|
||||
<form method="post" class="app-form">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
{% include "expenses/_form_fields.html" %}
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
Guardar
|
||||
|
||||
@ -4,9 +4,9 @@
|
||||
|
||||
<h2>Iniciar sesión</h2>
|
||||
|
||||
<form method="post">
|
||||
<form method="post" class="app-form">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
{% include "expenses/_form_fields.html" %}
|
||||
<button type="submit" class="btn btn-primary">Entrar</button>
|
||||
</form>
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user