diff options
author | luxagraf <sng@luxagraf.net> | 2015-11-08 21:25:13 -0500 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2015-11-08 21:25:13 -0500 |
commit | b588a5587c1f9a809509b77b11f4827c6c28f951 (patch) | |
tree | 68f7870ca61f7cad440ac5c1dbb48aac7d4cf139 /app/expenses/models.py | |
parent | 7e8fefe7f3c5aee31c4e7231e5fed21d34ed0cb6 (diff) |
ported expense app to CBVs and cleaner url scheme. Added build script
and new model to track trips because I'm ambitious like that.
Diffstat (limited to 'app/expenses/models.py')
-rw-r--r-- | app/expenses/models.py | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/app/expenses/models.py b/app/expenses/models.py index ef9352f..bca23bf 100644 --- a/app/expenses/models.py +++ b/app/expenses/models.py @@ -1,7 +1,6 @@ from django.db import models +from django.core.urlresolvers import reverse from django.utils import timezone -from django.template.defaultfilters import slugify -import datetime CATS = ( ('1', "Travco"), @@ -13,12 +12,28 @@ CATS = ( ('7', "Misc"), ) + +class Trip(models.Model): + name = models.CharField(max_length=200) + slug = models.SlugField() + start = models.DateTimeField(default=timezone.now, blank=True, null=True) + end = models.DateTimeField(default=timezone.now, blank=True, null=True) + dek = models.TextField(null=True, blank=True) + + def __str__(self): + return self.name + + def get_absolute_url(self): + return reverse("expenses:list_expense", kwargs={"slug": self.slug}) + + class Expense(models.Model): name = models.CharField(max_length=200) amount = models.DecimalField(max_digits=8, decimal_places=2) date = models.DateTimeField(default=timezone.now) notes = models.TextField(null=True, blank=True) category = models.CharField(max_length=2, choices=CATS, default=1) + trip = models.ForeignKey(Trip, null=True) class Meta: ordering = ('-date',) @@ -28,4 +43,3 @@ class Expense(models.Model): def date_month(self): return self.date.strftime("%b %Y") - |