summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/budget/admin.py17
-rw-r--r--app/budget/migrations/0001_initial.py36
-rw-r--r--app/budget/migrations/__init__.py0
-rw-r--r--app/budget/models.py31
-rw-r--r--app/budget/templates/budget/base.html34
-rw-r--r--app/budget/templates/budget/create_form.html26
-rw-r--r--app/budget/urls.py24
-rw-r--r--app/budget/views.py13
8 files changed, 181 insertions, 0 deletions
diff --git a/app/budget/admin.py b/app/budget/admin.py
new file mode 100644
index 0000000..fc84fa0
--- /dev/null
+++ b/app/budget/admin.py
@@ -0,0 +1,17 @@
+from django.contrib import admin
+
+from .models import LuxSource, LuxPurchase
+
+
+@admin.register(LuxSource)
+class SourceAdmin(admin.ModelAdmin):
+ list_display = ('name',)
+
+@admin.register(LuxPurchase)
+class PurchaseAdmin(admin.ModelAdmin):
+ list_display = ('source', 'amount', 'category' )
+ search_fields = ['source', 'amount']
+ list_filter = ('category',)
+
+ class Media:
+ js = ('next-prev-links.js',)
diff --git a/app/budget/migrations/0001_initial.py b/app/budget/migrations/0001_initial.py
new file mode 100644
index 0000000..30bd5a1
--- /dev/null
+++ b/app/budget/migrations/0001_initial.py
@@ -0,0 +1,36 @@
+# Generated by Django 4.0.6 on 2022-11-11 17:50
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ initial = True
+
+ dependencies = [
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='LuxSource',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('name', models.CharField(max_length=200)),
+ ('date_recorded', models.DateTimeField(auto_now_add=True)),
+ ],
+ ),
+ migrations.CreateModel(
+ name='LuxPurchase',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('amount', models.IntegerField()),
+ ('category', models.IntegerField(choices=[(0, 'Grocery and Home'), (1, 'Gas'), (2, 'Bus'), (3, 'Lodging'), (4, 'Books'), (5, 'Clothes'), (6, 'Eating Out'), (7, 'Misc')], default=0)),
+ ('date_recorded', models.DateTimeField(auto_now_add=True)),
+ ('source', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='budget.luxsource')),
+ ],
+ options={
+ 'ordering': ('-date_recorded',),
+ },
+ ),
+ ]
diff --git a/app/budget/migrations/__init__.py b/app/budget/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/app/budget/migrations/__init__.py
diff --git a/app/budget/models.py b/app/budget/models.py
new file mode 100644
index 0000000..acf2b69
--- /dev/null
+++ b/app/budget/models.py
@@ -0,0 +1,31 @@
+from django.db import models
+
+class LuxSource(models.Model):
+ name = models.CharField(max_length=200)
+ date_recorded = models.DateTimeField(auto_now_add=True)
+
+ def __str__(self):
+ return self.name
+
+class LuxPurchase(models.Model):
+ amount = models.IntegerField()
+ source = models.ForeignKey(LuxSource, on_delete=models.CASCADE)
+ CATEGORY = (
+ (0, 'Grocery and Home'),
+ (1, 'Gas'),
+ (2, 'Bus'),
+ (3, 'Lodging'),
+ (4, 'Books'),
+ (5, 'Clothes'),
+ (6, 'Eating Out'),
+ (7, 'Misc'),
+ )
+ category = models.IntegerField(choices=CATEGORY, default=0)
+ date_recorded = models.DateTimeField(auto_now_add=True)
+
+ class Meta:
+ ordering = ('-date_recorded',)
+
+ def __str__(self):
+ return self.name
+
diff --git a/app/budget/templates/budget/base.html b/app/budget/templates/budget/base.html
new file mode 100644
index 0000000..e17813a
--- /dev/null
+++ b/app/budget/templates/budget/base.html
@@ -0,0 +1,34 @@
+<html>
+<head>
+ <title>{% block pagetitle %}Luxagraf - Trading{% endblock %}</title>
+ <meta charset="utf-8">
+ <meta http-equiv="x-ua-compatible" content="ie=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ {%block stylesheet%}<link rel="stylesheet"
+ href="/media/trading.css{%comment%}?{% now "u" %}{%endcomment%}"
+ media="screen">{%endblock%}
+ <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
+<style>
+ select {
+ border: 1px solid #dedddd;
+ border-radius: 4px;
+ padding: 2.2rem 0 0.75rem 0.75rem;
+ width: 96%;
+ font-size: 24px;
+ font-size: 1.5rem;
+ }
+</style>
+ {%block extrahead%}{%endblock%}
+</head>
+ </head>
+ <body>
+ <nav>
+ <span class="nav-item"><a href="{% url 'luxtrade:list' %}">Home</a></span>
+ </nav>
+ {% block content %}
+ {% endblock %}
+ </body>
+ {% block js %}
+ {% endblock %}
+</html>
+
diff --git a/app/budget/templates/budget/create_form.html b/app/budget/templates/budget/create_form.html
new file mode 100644
index 0000000..2d38acf
--- /dev/null
+++ b/app/budget/templates/budget/create_form.html
@@ -0,0 +1,26 @@
+{% extends 'budget/base.html' %}
+{% load typogrify_tags %}
+ {% block pagetitle %}Luxagraf - Record Purchase{% endblock %}
+ {% block content %}
+ <form id="id_form" action="{% url 'luxbudget:createview' %}" method="post" class="big">{% csrf_token %}
+ {% for field in form %}
+ <fieldset>
+ {{ field.errors }}
+ {% if field.name == 'status'%}
+ <label class="hide" for="id_status">Status:</label>{{ field }}
+ {% else %}
+ {{ field.label_tag }} {{ field }}
+ {% endif %}
+ {% if field.help_text %}
+ <p class="help">{{ field.help_text|safe }}</p>
+ {% endif %}
+ </fieldset>
+{% endfor %}
+ <div class="flex">
+ <input type="submit" name="post" class="btn" value="record purchase"/>
+ </div>
+ </form>
+ {% endblock %}
+
+ {% block js %}
+ {% endblock %}
diff --git a/app/budget/urls.py b/app/budget/urls.py
new file mode 100644
index 0000000..86c56a2
--- /dev/null
+++ b/app/budget/urls.py
@@ -0,0 +1,24 @@
+from django.urls import path, re_path
+
+from . import views
+
+app_name = "luxbudget"
+
+urlpatterns = [
+ path(
+ 'record',
+ views.PurchaseModelFormView.as_view(),
+ name='createview'
+ ),
+ path(
+ 'purchase/<pk>',
+ views.PurchaseModelFormView.as_view(),
+ name='detail'
+ ),
+ path(
+ '',
+ views.LuxPurchaseListView.as_view(),
+ {'page':1},
+ name='list'
+ ),
+]
diff --git a/app/budget/views.py b/app/budget/views.py
new file mode 100644
index 0000000..3743eaf
--- /dev/null
+++ b/app/budget/views.py
@@ -0,0 +1,13 @@
+from django.shortcuts import render
+from django.views.generic.edit import CreateView, UpdateView
+from utils.views import PaginatedListView
+from .models import LuxPurchase
+
+class PurchaseModelFormView(CreateView):
+ model = LuxPurchase
+ fields = ['amount', 'source', 'category']
+ success_url = '/spending/'
+ template_name = 'budget/create_form.html'
+
+class LuxPurchaseListView(PaginatedListView):
+ pass