diff options
author | luxagraf <sng@luxagraf.net> | 2022-11-12 11:00:36 -0600 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2022-11-12 11:00:36 -0600 |
commit | adfa2d7328dedbf409b512f0d55e4ee85cea8dca (patch) | |
tree | f622467d005822d91335515fc8d90e57d140a7e8 /app | |
parent | 78233f53e2f2d24dd647ce98d534fc2d25d8a84b (diff) |
bdgt: added view to quickly add source
Diffstat (limited to 'app')
-rw-r--r-- | app/budget/templates/budget/base.html | 1 | ||||
-rw-r--r-- | app/budget/templates/budget/create_cat_form.html | 26 | ||||
-rw-r--r-- | app/budget/urls.py | 5 | ||||
-rw-r--r-- | app/budget/views.py | 9 |
4 files changed, 40 insertions, 1 deletions
diff --git a/app/budget/templates/budget/base.html b/app/budget/templates/budget/base.html index 355c911..9d6bfd0 100644 --- a/app/budget/templates/budget/base.html +++ b/app/budget/templates/budget/base.html @@ -24,6 +24,7 @@ <body> <nav> <span class="nav-item"><a href="{% url 'luxbudget:list' %}">Home</a></span> + <span class="nav-item"><a href="{% url 'luxbudget:createcatview' %}">Add Cat</a></span> </nav> {% block content %} {% endblock %} diff --git a/app/budget/templates/budget/create_cat_form.html b/app/budget/templates/budget/create_cat_form.html new file mode 100644 index 0000000..03e996a --- /dev/null +++ b/app/budget/templates/budget/create_cat_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:createcatview' %}" 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 index 92fc184..ef7852f 100644 --- a/app/budget/urls.py +++ b/app/budget/urls.py @@ -6,6 +6,11 @@ app_name = "luxbudget" urlpatterns = [ path( + 'cat', + views.LuxSourceModelFormView.as_view(), + name='createcatview' + ), + path( 'record', views.PurchaseModelFormView.as_view(), name='createview' diff --git a/app/budget/views.py b/app/budget/views.py index 906450c..4a2ab74 100644 --- a/app/budget/views.py +++ b/app/budget/views.py @@ -3,7 +3,14 @@ from django.shortcuts import render from django.views.generic.edit import CreateView, UpdateView from django.utils import timezone from utils.views import PaginatedListView -from .models import LuxPurchase +from .models import LuxPurchase, LuxSource + +class LuxSourceModelFormView(CreateView): + model = LuxSource + fields = ['name'] + success_url = '/spending/' + template_name = 'budget/create_cat_form.html' + class PurchaseModelFormView(CreateView): model = LuxPurchase |