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 %}
|
{% block content %}
|
||||||
<h2>Editar categoría</h2>
|
<h2>Editar categoría</h2>
|
||||||
|
|
||||||
<form method="post">
|
<form method="post" class="app-form">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{ form.as_p }}
|
{% include "expenses/_form_fields.html" %}
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<button type="submit" class="btn btn-primary">Guardar</button>
|
<button type="submit" class="btn btn-primary">Guardar</button>
|
||||||
<a class="btn btn-secondary" href="{% url 'category_list' %}">Cancelar</a>
|
<a class="btn btn-secondary" href="{% url 'category_list' %}">Cancelar</a>
|
||||||
|
|||||||
@ -8,26 +8,27 @@
|
|||||||
|
|
||||||
<h1>Mis categorías</h1>
|
<h1>Mis categorías</h1>
|
||||||
|
|
||||||
<h3> Nueva categoría</h3>
|
<h3>Nueva categoría</h3>
|
||||||
<form method="post">
|
<form method="post" class="app-form">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{ form.as_p }}
|
{% include "expenses/_form_fields.html" %}
|
||||||
<button type="submit" class="btn btn-primary">Crear</button>
|
<button type="submit" class="btn btn-primary">Crear</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<h3>Listado</h3>
|
<h3>Listado</h3>
|
||||||
<div class="table-wrap">
|
<div class="table-wrap">
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Categoría</th>
|
<th>Categoría</th>
|
||||||
<th>Categoría padre</th>
|
<th>Categoría padre</th>
|
||||||
</tr>
|
<th></th>
|
||||||
</thead>
|
</tr>
|
||||||
<tbody>
|
</thead>
|
||||||
{% for category in categories %}
|
<tbody>
|
||||||
|
{% for category in categories %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ category.name }}</td>
|
<td>{{ category.name }}</td>
|
||||||
<td>{% if category.parent %}{{ category.parent.name }}{% endif %}</td>
|
<td>{% if category.parent %}{{ category.parent.name }}{% endif %}</td>
|
||||||
@ -36,9 +37,9 @@
|
|||||||
<a href="{% url 'category_delete' category.id %}" class="danger">Eliminar</a>
|
<a href="{% url 'category_delete' category.id %}" class="danger">Eliminar</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@ -10,9 +10,9 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
<form method="post">
|
<form method="post" class="app-form">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{ form.as_p }}
|
{% include "expenses/_form_fields.html" %}
|
||||||
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<button type="submit" class="btn btn-primary">Guardar</button>
|
<button type="submit" class="btn btn-primary">Guardar</button>
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
Nuevo gasto
|
Nuevo gasto
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>
|
<h1>
|
||||||
{% if form.instance.pk %}
|
{% if form.instance.pk %}
|
||||||
@ -17,34 +17,10 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
<form method="post">
|
<form method="post" class="app-form">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
|
||||||
{% for field in form %}
|
{% include "expenses/_form_fields.html" %}
|
||||||
{% 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 %}
|
|
||||||
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<button type="submit" class="btn btn-primary">
|
<button type="submit" class="btn btn-primary">
|
||||||
|
|||||||
@ -16,9 +16,9 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
<form method="post">
|
<form method="post" class="app-form">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{ form.as_p }}
|
{% include "expenses/_form_fields.html" %}
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<button type="submit" class="btn btn-primary">
|
<button type="submit" class="btn btn-primary">
|
||||||
{% if form.instance.pk %}
|
{% if form.instance.pk %}
|
||||||
|
|||||||
@ -3,9 +3,9 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>Etiqueta</h1>
|
<h1>Etiqueta</h1>
|
||||||
|
|
||||||
<form method="post">
|
<form method="post" class="app-form">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{ form.as_p }}
|
{% include "expenses/_form_fields.html" %}
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<button type="submit" class="btn btn-primary">Guardar</button>
|
<button type="submit" class="btn btn-primary">Guardar</button>
|
||||||
<a class="btn btn-secondary" href="{% url 'tag_list' %}">Volver</a>
|
<a class="btn btn-secondary" href="{% url 'tag_list' %}">Volver</a>
|
||||||
|
|||||||
@ -17,10 +17,10 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
<form method="post">
|
<form method="post" class="app-form">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{% if next %}<input type="hidden" name="next" value="{{ next }}">{% endif %}
|
{% if next %}<input type="hidden" name="next" value="{{ next }}">{% endif %}
|
||||||
{{ form.as_p }}
|
{% include "expenses/_form_fields.html" %}
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<button type="submit" class="btn btn-primary">
|
<button type="submit" class="btn btn-primary">
|
||||||
{% if editing %}
|
{% if editing %}
|
||||||
|
|||||||
@ -1,16 +1,16 @@
|
|||||||
{% extends "expenses/base.html" %}
|
{% extends "expenses/base.html" %}
|
||||||
{% block title %}
|
{% block title %}
|
||||||
Nuevo objetivo
|
{{ title }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>
|
<h1>
|
||||||
Nuevo objetivo
|
{{ title }}
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
<form method="post">
|
<form method="post" class="app-form">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{ form.as_p }}
|
{% include "expenses/_form_fields.html" %}
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<button type="submit" class="btn btn-primary">
|
<button type="submit" class="btn btn-primary">
|
||||||
Guardar
|
Guardar
|
||||||
|
|||||||
@ -4,9 +4,9 @@
|
|||||||
|
|
||||||
<h2>Iniciar sesión</h2>
|
<h2>Iniciar sesión</h2>
|
||||||
|
|
||||||
<form method="post">
|
<form method="post" class="app-form">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{ form.as_p }}
|
{% include "expenses/_form_fields.html" %}
|
||||||
<button type="submit" class="btn btn-primary">Entrar</button>
|
<button type="submit" class="btn btn-primary">Entrar</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user