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:
JKuijperM 2026-09-03 17:59:28 +02:00
parent d70d0e4239
commit 581eb202c7
9 changed files with 39 additions and 62 deletions

View File

@ -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>

View File

@ -8,10 +8,10 @@
<h1>Mis categorías</h1>
<h3> Nueva categoría</h3>
<form method="post">
<h3>Nueva categoría</h3>
<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>
@ -19,15 +19,16 @@
<h3>Listado</h3>
<div class="table-wrap">
<table>
<thead>
<tr>
<th>Categoría</th>
<th>Categoría padre</th>
</tr>
</thead>
<tbody>
{% for category in categories %}
<table>
<thead>
<tr>
<th>Categoría</th>
<th>Categoría padre</th>
<th></th>
</tr>
</thead>
<tbody>
{% for category in categories %}
<tr>
<td>{{ category.name }}</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>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %}

View File

@ -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>

View File

@ -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">

View File

@ -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 %}

View File

@ -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>

View File

@ -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 %}

View File

@ -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

View File

@ -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>