Przeglądaj źródła

Eliminar y editar movimientos estilizado

Celestino Rey 1 rok temu
rodzic
commit
09daf7670b

BIN
db.sqlite3


+ 2 - 0
finanzas/urls.py

@@ -3,9 +3,11 @@ from . import views
 
 urlpatterns = [
     path('', views.dashboard, name='dashboard'),
+    # Movimientos
     path('agregar/', views.agregar_movimiento, name='agregar_movimiento'),
     path('movimientos/<int:movimiento_id>/editar/', views.editar_movimiento, name='editar_movimiento'),
     path('movimientos/<int:movimiento_id>/eliminar/', views.eliminar_movimiento, name='eliminar_movimiento'),
+    # Cuentas
     path('cuentas/nueva/', views.agregar_cuenta, name='agregar_cuenta'),
     path('cuentas/', views.listar_cuentas, name='listar_cuentas'),
     path('cuentas/<int:cuenta_id>/editar/', views.editar_cuenta, name='editar_cuenta'),

+ 1 - 1
finanzas/views.py

@@ -7,7 +7,7 @@ from django.contrib.auth.decorators import login_required
 
 @login_required
 def dashboard(request):
-    movimientos = Movimiento.objects.filter(usuario=request.user).order_by('fecha')
+    movimientos = Movimiento.objects.filter(usuario=request.user).order_by('-fecha')
 
     favoritas = Cuenta.objects.filter(favorita='True')
 

+ 23 - 16
templates/editar_cuenta.html

@@ -1,16 +1,23 @@
-<!DOCTYPE html>
-<html lang="es">
-<head>
-    <meta charset="UTF-8">
-    <title>Editar Cuenta</title>
-</head>
-<body>
-    <h1>Editar Cuenta</h1>
-    <form method="post">
-        {% csrf_token %}
-        {{ form.as_p }}
-        <button type="submit">Guardar Cambios</button>
-    </form>
-    <a href="{% url 'listar_cuentas' %}">Volver</a>
-</body>
-</html>
+{% extends "base.html" %}
+
+{% block interface %}
+
+<section id="interface">
+    <div class="board">
+    {% include "_navigation.html" %}
+        <div class="div-form">
+            <h3>Editar Cuenta</h3>
+            <div class="form-group">
+                <form method="post">
+                    {% csrf_token %}
+                    {{ form.as_p }}
+                    <button class="btn btn-success" type="submit">Guardar cambios</button>
+                </form>
+            </div>
+        </div>
+        <div class="botones">
+            <a href="{% url 'listar_cuentas' %}"><button class="btn btn-secondary" type="button">Volver a cuentas</button></a>
+        </div>
+    </div>
+</section>
+{% endblock %}

+ 24 - 16
templates/editar_movimiento.html

@@ -1,16 +1,24 @@
-<!DOCTYPE html>
-<html lang="es">
-<head>
-    <meta charset="UTF-8">
-    <title>Editar Movimiento</title>
-</head>
-<body>
-    <h1>Editar Movimiento</h1>
-    <form method="post">
-        {% csrf_token %}
-        {{ form.as_p }}
-        <button type="submit">Guardar Cambios</button>
-    </form>
-    <a href="{% url 'dashboard' %}">Volver</a>
-</body>
-</html>
+{% extends "base.html" %}
+
+{% block interface %}
+
+<section id="interface">
+    <div class="board">
+        {% include "_navigation.html" %}
+        <div class="div-form">
+            <h1>Editar Movimiento</h1>
+            <div class="form-group">
+
+            <form method="post">
+                {% csrf_token %}
+                {{ form.as_p }}
+                <button class="btn btn-success" type="submit">Guardar cambios</button>
+            </form>
+        </div>
+    </div>
+    <div class="botones">
+        <a href="{% url 'dashboard' %}"><button class="btn btn-secondary" type="button">Volver a movimientos</button></a>
+    </div>
+</div>
+</section>
+{% endblock %}

+ 0 - 16
templates/elimina_movimiento.html

@@ -1,16 +0,0 @@
-<!DOCTYPE html>
-<html lang="es">
-<head>
-    <meta charset="UTF-8">
-    <title>Eliminar Movimiento</title>
-</head>
-<body>
-    <h1>¿Estás seguro de que deseas eliminar este movimiento?</h1>
-    <p>{{ movimiento.fecha }} - {{ movimiento.cuenta_origen.nombre }} → {{ movimiento.cuenta_destino.nombre }}: {{ movimiento.monto }}</p>
-    <form method="post">
-        {% csrf_token %}
-        <button type="submit">Sí, eliminar</button>
-        <a href="{% url 'dashboard' %}">Cancelar</a>
-    </form>
-</body>
-</html>

+ 27 - 21
templates/eliminar_cuenta.html

@@ -1,22 +1,28 @@
-<!DOCTYPE html>
-<html lang="es">
-<head>
-    <meta charset="UTF-8">
-    <title>Eliminar Cuenta</title>
-</head>
-<body>
-    <h1>Eliminar Cuenta</h1>
+{% extends "base.html" %}
 
-    {% if tiene_movimientos %}
-        <p>No puedes eliminar la cuenta <strong>{{ cuenta.nombre }}</strong> porque tiene movimientos asociados.</p>
-        <a href="{% url 'listar_cuentas' %}">Volver</a>
-    {% else %}
-        <p>¿Estás seguro que deseas eliminar la cuenta <strong>{{ cuenta.nombre }}</strong>?</p>
-        <form method="post">
-            {% csrf_token %}
-            <button type="submit">Sí, eliminar</button>
-            <a href="{% url 'listar_cuentas' %}">Cancelar</a>
-        </form>
-    {% endif %}
-</body>
-</html>
+{% block interface %}
+
+<section id="interface">
+    <div class="board">
+    {% include "_navigation.html" %}
+    <div class="div-form">
+        <h1>Eliminar Cuenta</h1>
+
+        {% if tiene_movimientos %}
+            <p>No puedes eliminar la cuenta <strong>{{ cuenta.nombre }}</strong> porque tiene movimientos asociados.</p>
+        {% else %}
+            <p>¿Estás seguro que deseas eliminar la cuenta <strong>{{ cuenta.nombre }}</strong>?</p>
+            <div class="form-group">
+                <form method="post">
+                    {% csrf_token %}
+                    <button type="submit">Sí, eliminar</button>
+                </form>
+            </div>
+        {% endif %}
+        <div class="botones">
+            <a href="{% url 'listar_cuentas' %}"><button class="btn btn-secondary" type="button">Volver</button></a>
+        </div>
+    </div>
+</div>
+</section>
+{% endblock %}

+ 20 - 0
templates/eliminar_movimiento.html

@@ -0,0 +1,20 @@
+{% extends "base.html" %}
+
+{% block interface %}
+
+<section id="interface">
+    <div class="board">
+        {% include "_navigation.html" %}
+        <div class="div-form">
+        <h1>¿Estás seguro de que deseas eliminar este movimiento?</h1>
+        <p>{{ movimiento.fecha }} - {{ movimiento.cuenta_origen.nombre }} → {{ movimiento.cuenta_destino.nombre }}: {{ movimiento.monto }}</p>
+        <div class="form-group">
+            <form method="post">
+                {% csrf_token %}
+                <button  class="btn btn-success" type="submit">Sí, eliminar</button>
+                <a href="{% url 'dashboard' %}"><button class="btn btn-danger" type="button">Cancelar</button></a>
+            </form>
+        </div>
+    </div>
+</section>
+{% endblock %}