From adfa2d7328dedbf409b512f0d55e4ee85cea8dca Mon Sep 17 00:00:00 2001 From: luxagraf Date: Sat, 12 Nov 2022 11:00:36 -0600 Subject: bdgt: added view to quickly add source --- app/budget/templates/budget/base.html | 1 + app/budget/templates/budget/create_cat_form.html | 26 ++++++++++++++++++++++++ app/budget/urls.py | 5 +++++ app/budget/views.py | 9 +++++++- 4 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 app/budget/templates/budget/create_cat_form.html (limited to 'app/budget') 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 @@ {% 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 %} +
{% csrf_token %} + {% for field in form %} +
+ {{ field.errors }} + {% if field.name == 'status'%} + {{ field }} + {% else %} + {{ field.label_tag }} {{ field }} + {% endif %} + {% if field.help_text %} +

{{ field.help_text|safe }}

+ {% endif %} +
+{% endfor %} +
+ +
+
+ {% 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 @@ -5,6 +5,11 @@ from . import views app_name = "luxbudget" urlpatterns = [ + path( + 'cat', + views.LuxSourceModelFormView.as_view(), + name='createcatview' + ), path( 'record', views.PurchaseModelFormView.as_view(), 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 -- cgit v1.2.3-70-g09d2