This commit is contained in:
Flatlogic Bot 2026-01-10 17:02:25 +00:00
parent ba2b261941
commit dd65b220bd
14 changed files with 367 additions and 187 deletions

Binary file not shown.

View File

@ -1,3 +1,13 @@
from django.contrib import admin
from .models import Category, Expense
# Register your models here.
@admin.register(Category)
class CategoryAdmin(admin.ModelAdmin):
list_display = ('name',)
search_fields = ('name',)
@admin.register(Expense)
class ExpenseAdmin(admin.ModelAdmin):
list_display = ('date', 'category', 'amount', 'currency', 'payer')
list_filter = ('date', 'category', 'currency', 'payer')
search_fields = ('description',)

7
core/forms.py Normal file
View File

@ -0,0 +1,7 @@
from django import forms
from .models import Expense
class ExpenseForm(forms.ModelForm):
class Meta:
model = Expense
fields = ['payer', 'amount', 'currency', 'category', 'description', 'date']

View File

@ -0,0 +1,39 @@
# Generated by Django 5.2.7 on 2026-01-10 16:57
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='Category',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=100, unique=True)),
],
options={
'verbose_name_plural': 'Categories',
},
),
migrations.CreateModel(
name='Expense',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('amount', models.DecimalField(decimal_places=2, max_digits=10)),
('currency', models.CharField(choices=[('COP', 'Colombian Pesos'), ('EUR', 'Euros'), ('USD', 'US Dollars')], max_length=3)),
('date', models.DateField()),
('description', models.TextField(blank=True)),
('category', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='core.category')),
('payer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
]

View File

@ -1,3 +1,28 @@
from django.db import models
from django.contrib.auth.models import User
# Create your models here.
class Category(models.Model):
name = models.CharField(max_length=100, unique=True)
def __str__(self):
return self.name
class Meta:
verbose_name_plural = "Categories"
class Expense(models.Model):
CURRENCY_CHOICES = [
('COP', 'Colombian Pesos'),
('EUR', 'Euros'),
('USD', 'US Dollars'),
]
amount = models.DecimalField(max_digits=10, decimal_places=2)
currency = models.CharField(max_length=3, choices=CURRENCY_CHOICES)
category = models.ForeignKey(Category, on_delete=models.PROTECT)
payer = models.ForeignKey(User, on_delete=models.CASCADE)
date = models.DateField()
description = models.TextField(blank=True)
def __str__(self):
return f'{self.amount} {self.currency} - {self.category} - {self.date}'

View File

@ -1,9 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<html lang="es">
<head>
<meta charset="UTF-8">
<title>{% block title %}Knowledge Base{% endblock %}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% block title %}Gastos Familiares{% endblock %}</title>
{% if project_description %}
<meta name="description" content="{{ project_description }}">
<meta property="og:description" content="{{ project_description }}">
@ -13,13 +14,50 @@
<meta property="og:image" content="{{ project_image_url }}">
<meta property="twitter:image" content="{{ project_image_url }}">
{% endif %}
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;700&family=Roboto:wght@400;500&display=swap" rel="stylesheet">
{% load static %}
<link rel="stylesheet" href="{% static 'css/custom.css' %}?v={{ deployment_timestamp }}">
{% block head %}{% endblock %}
</head>
<body>
{% block content %}{% endblock %}
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
<div class="container">
<a class="navbar-brand" href="/">Gastos Familiares</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ms-auto">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="/">Inicio</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/admin/">Admin</a>
</li>
</ul>
</div>
</div>
</nav>
<main>
{% block content %}{% endblock %}
</main>
<footer class="bg-light text-center text-lg-start mt-auto">
<div class="text-center p-3" style="background-color: rgba(0, 0, 0, 0.05);">
© 2026 Copyright:
<a class="text-dark" href="/">Gastos Familiares</a>
</div>
</footer>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>

View File

@ -1,145 +1,102 @@
{% extends "base.html" %}
{% extends 'base.html' %}
{% block title %}{{ project_name }}{% endblock %}
{% block head %}
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
<style>
:root {
--bg-color-start: #6a11cb;
--bg-color-end: #2575fc;
--text-color: #ffffff;
--card-bg-color: rgba(255, 255, 255, 0.01);
--card-border-color: rgba(255, 255, 255, 0.1);
}
* {
box-sizing: border-box;
}
body {
margin: 0;
font-family: 'Inter', sans-serif;
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
color: var(--text-color);
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
text-align: center;
overflow: hidden;
position: relative;
}
body::before {
content: '';
position: absolute;
inset: 0;
background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'><path d='M-10 10L110 10M10 -10L10 110' stroke-width='1' stroke='rgba(255,255,255,0.05)'/></svg>");
animation: bg-pan 20s linear infinite;
z-index: -1;
}
@keyframes bg-pan {
0% {
background-position: 0% 0%;
}
100% {
background-position: 100% 100%;
}
}
main {
padding: 2rem;
}
.card {
background: var(--card-bg-color);
border: 1px solid var(--card-border-color);
border-radius: 16px;
padding: 2.5rem 2rem;
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
box-shadow: 0 12px 36px rgba(0, 0, 0, 0.25);
}
h1 {
font-size: clamp(2.2rem, 3vw + 1.2rem, 3.2rem);
font-weight: 700;
margin: 0 0 1.2rem;
letter-spacing: -0.02em;
}
p {
margin: 0.5rem 0;
font-size: 1.1rem;
opacity: 0.92;
}
.loader {
margin: 1.5rem auto;
width: 56px;
height: 56px;
border: 4px solid rgba(255, 255, 255, 0.25);
border-top-color: #fff;
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
.runtime code {
background: rgba(0, 0, 0, 0.25);
padding: 0.15rem 0.45rem;
border-radius: 4px;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
border: 0;
}
footer {
position: absolute;
bottom: 1rem;
width: 100%;
text-align: center;
font-size: 0.85rem;
opacity: 0.75;
}
</style>
{% endblock %}
{% block title %}Inicio - Gastos Familiares{% endblock %}
{% block content %}
<main>
<div class="card">
<h1>Analyzing your requirements and generating your app…</h1>
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
<span class="sr-only">Loading…</span>
<div class="container content-section">
<div class="row">
<div class="col-md-4">
<h2>Agregar Nuevo Gasto</h2>
<form method="post">
{% csrf_token %}
<div class="mb-3">
{{ form.payer.label_tag }}
{{ form.payer }}
</div>
<div class="mb-3">
{{ form.amount.label_tag }}
{{ form.amount }}
</div>
<div class="mb-3">
{{ form.currency.label_tag }}
{{ form.currency }}
</div>
<div class="mb-3">
{{ form.category.label_tag }}
{{ form.category }}
</div>
<div class="mb-3">
{{ form.description.label_tag }}
{{ form.description }}
</div>
<div class="mb-3">
{{ form.date.label_tag }}
{{ form.date }}
</div>
<button type="submit" class="btn btn-primary">Agregar Gasto</button>
</form>
</div>
<div class="col-md-8">
<div class="row">
<div class="col-md-6">
<h2>Tus Gastos Recientes</h2>
<form method="get" class="row g-3 align-items-center mb-3">
<div class="col-auto">
<label for="category" class="col-form-label">Filtrar por categoría:</label>
</div>
<div class="col-auto">
<select name="category" id="category" class="form-select">
<option value="">Todas</option>
{% for category in categories %}
<option value="{{ category.id }}" {% if request.GET.category == category.id|stringformat:"s" %}selected{% endif %}>{{ category.name }}</option>
{% endfor %}
</select>
</div>
<div class="col-auto">
<button type="submit" class="btn btn-secondary">Filtrar</button>
</div>
</form>
{% if expenses %}
<ul class="list-group">
{% for expense in expenses %}
<li class="list-group-item d-flex justify-content-between align-items-center">
<div>
<strong>{{ expense.category }}</strong> - {{ expense.description }}
<small class="text-muted">({{ expense.date|date:"d/m/Y" }})</small>
</div>
<span class="badge bg-primary rounded-pill">${{ expense.amount }}</span>
</li>
{% endfor %}
</ul>
{% else %}
<div class="alert alert-info mt-4" role="alert">
Aún no has agregado ningún gasto. ¡Comienza agregando uno!
</div>
{% endif %}
</div>
<div class="col-md-6">
<h2>Análisis de Gastos</h2>
<div class="card">
<div class="card-body">
<h5 class="card-title">Total de Gastos</h5>
<p class="card-text display-6">${{ total_expenses|floatformat:2 }}</p>
</div>
</div>
<h5 class="mt-4">Gastos por Categoría</h5>
<ul class="list-group">
{% for item in category_summary %}
<li class="list-group-item d-flex justify-content-between align-items-center">
{{ item.category__name }}
<span class="badge bg-secondary rounded-pill">${{ item.total|floatformat:2 }}</span>
</li>
{% endfor %}
</ul>
</div>
</div>
</div>
<p class="hint">AppWizzy AI is collecting your requirements and applying the first changes.</p>
<p class="hint">This page will refresh automatically as the plan is implemented.</p>
<p class="runtime">
Runtime: Django <code>{{ django_version }}</code> · Python <code>{{ python_version }}</code>
— UTC <code>{{ current_time|date:"Y-m-d H:i:s" }}</code>
</p>
</div>
</main>
<footer>
Page updated: {{ current_time|date:"Y-m-d H:i:s" }} (UTC)
</footer>
{% endblock %}
</div>
{% endblock %}

View File

@ -1,25 +1,38 @@
import os
import platform
from django import get_version as django_version
from django.shortcuts import render
from django.utils import timezone
from django.shortcuts import render, redirect
from .forms import ExpenseForm
from .models import Expense, Category
from django.db.models import Sum
def home(request):
"""Render the landing screen with loader and environment details."""
host_name = request.get_host().lower()
agent_brand = "AppWizzy" if host_name == "appwizzy.com" else "Flatlogic"
now = timezone.now()
"""Render the landing screen and handle expense form submission."""
if request.method == 'POST':
form = ExpenseForm(request.POST)
if form.is_valid():
form.save()
return redirect('home')
else:
form = ExpenseForm()
expenses = Expense.objects.all()
# Filtering logic
category_id = request.GET.get('category')
if category_id:
expenses = expenses.filter(category_id=category_id)
expenses = expenses.order_by('-date')
# Analysis
total_expenses = expenses.aggregate(Sum('amount'))['amount__sum'] or 0
category_summary = expenses.values('category__name').annotate(total=Sum('amount')).order_by('-total')
categories = Category.objects.all()
return render(request, "core/index.html", {
'form': form,
'expenses': expenses,
'categories': categories,
'total_expenses': total_expenses,
'category_summary': category_summary,
})
context = {
"project_name": "New Style",
"agent_brand": agent_brand,
"django_version": django_version(),
"python_version": platform.python_version(),
"current_time": now,
"host_name": host_name,
"project_description": os.getenv("PROJECT_DESCRIPTION", ""),
"project_image_url": os.getenv("PROJECT_IMAGE_URL", ""),
}
return render(request, "core/index.html", context)

View File

@ -1,4 +1,58 @@
/* Custom styles for the application */
body {
font-family: system-ui, -apple-system, sans-serif;
:root {
--bs-primary: #0D47A1;
--bs-secondary: #42A5F5;
--bs-accent: #FFC107;
--bs-background: #F5F5F5;
--bs-text: #212121;
}
body {
font-family: 'Roboto', sans-serif;
background-color: var(--bs-background);
color: var(--bs-text);
display: flex;
flex-direction: column;
min-height: 100vh;
}
h1, h2, h3, h4, h5, h6, .navbar-brand {
font-family: 'Montserrat', sans-serif;
}
.bg-primary {
background-color: var(--bs-primary) !important;
}
.navbar-brand {
font-weight: 700;
}
.hero-section {
background: linear-gradient(45deg, var(--bs-primary), var(--bs-secondary));
color: white;
padding: 100px 0;
text-align: center;
}
.hero-section h1 {
font-weight: 700;
font-size: 3.5rem;
}
.hero-section .btn-accent {
background-color: var(--bs-accent);
color: var(--bs-text);
font-weight: 700;
padding: 15px 30px;
font-size: 1.2rem;
border-radius: 50px;
transition: transform 0.2s;
}
.hero-section .btn-accent:hover {
transform: scale(1.05);
}
.content-section {
padding: 60px 0;
}

View File

@ -1,21 +1,58 @@
:root {
--bg-color-start: #6a11cb;
--bg-color-end: #2575fc;
--text-color: #ffffff;
--card-bg-color: rgba(255, 255, 255, 0.01);
--card-border-color: rgba(255, 255, 255, 0.1);
--bs-primary: #0D47A1;
--bs-secondary: #42A5F5;
--bs-accent: #FFC107;
--bs-background: #F5F5F5;
--bs-text: #212121;
}
body {
margin: 0;
font-family: 'Inter', sans-serif;
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
color: var(--text-color);
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
text-align: center;
overflow: hidden;
position: relative;
font-family: 'Roboto', sans-serif;
background-color: var(--bs-background);
color: var(--bs-text);
display: flex;
flex-direction: column;
min-height: 100vh;
}
h1, h2, h3, h4, h5, h6, .navbar-brand {
font-family: 'Montserrat', sans-serif;
}
.bg-primary {
background-color: var(--bs-primary) !important;
}
.navbar-brand {
font-weight: 700;
}
.hero-section {
background: linear-gradient(45deg, var(--bs-primary), var(--bs-secondary));
color: white;
padding: 100px 0;
text-align: center;
}
.hero-section h1 {
font-weight: 700;
font-size: 3.5rem;
}
.hero-section .btn-accent {
background-color: var(--bs-accent);
color: var(--bs-text);
font-weight: 700;
padding: 15px 30px;
font-size: 1.2rem;
border-radius: 50px;
transition: transform 0.2s;
}
.hero-section .btn-accent:hover {
transform: scale(1.05);
}
.content-section {
padding: 60px 0;
}