Update views using class based views
Updated views for transaction Invoice form temporarily removed
This commit is contained in:
parent
41499f1329
commit
757ce1f45f
7 changed files with 57 additions and 81 deletions
|
@ -6,6 +6,7 @@ from django.core.files.storage import Storage
|
|||
from django.core.validators import FileExtensionValidator
|
||||
from django.db import models
|
||||
from django.forms import ModelForm
|
||||
from django.urls import reverse
|
||||
from django.utils.translation import gettext as _
|
||||
|
||||
|
||||
|
@ -27,7 +28,7 @@ class Category(models.Model):
|
|||
|
||||
|
||||
class CategoryForm(ModelForm):
|
||||
template_name = "main/form.html"
|
||||
template_name = "main/form/base.html"
|
||||
|
||||
class Meta:
|
||||
model = Category
|
||||
|
@ -62,6 +63,9 @@ class Transaction(models.Model):
|
|||
def __str__(self):
|
||||
return f"{self.date} – {self.name}"
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse("transaction", kwargs={"pk": self.pk})
|
||||
|
||||
@property
|
||||
def invoices(self):
|
||||
return Invoice.objects.filter(transaction=self)
|
||||
|
@ -77,7 +81,7 @@ class Transaction(models.Model):
|
|||
|
||||
|
||||
class TransactionForm(ModelForm):
|
||||
template_name = "main/form.html"
|
||||
template_name = "main/form/base.html"
|
||||
|
||||
class Meta:
|
||||
model = Transaction
|
||||
|
@ -123,7 +127,7 @@ class Invoice(models.Model):
|
|||
|
||||
|
||||
class InvoiceForm(ModelForm):
|
||||
template_name = "main/form.html"
|
||||
template_name = "main/form/base.html"
|
||||
prefix = "invoice"
|
||||
|
||||
class Meta:
|
||||
|
@ -263,7 +267,7 @@ class Snapshot(models.Model):
|
|||
|
||||
|
||||
class SnapshotForm(ModelForm):
|
||||
template_name = "main/form.html"
|
||||
template_name = "main/form/base.html"
|
||||
|
||||
class Meta:
|
||||
model = Snapshot
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue