aboutsummaryrefslogtreecommitdiff
path: root/app/dispatch/models.py
diff options
context:
space:
mode:
authorMitch Riedstra <Mitch@riedstra.us>2017-10-18 15:55:23 -0400
committerMitch Riedstra <Mitch@riedstra.us>2017-10-18 15:55:23 -0400
commit5b2f6041e739be4810709ca49d0538279d3f549d (patch)
tree8aba1c4a2d59e85a873bdcbb3327722b5e876ffa /app/dispatch/models.py
parent2c4f4a6a09feeb333f59cfc6c2d5d6c8e417599f (diff)
downloaddispatch-tracker-5b2f6041e739be4810709ca49d0538279d3f549d.tar.gz
dispatch-tracker-5b2f6041e739be4810709ca49d0538279d3f549d.tar.xz
Added a delivered to field. File uploads work. Load detail view works properly now. File upload names are properly set. You can now delete uploaded files
Diffstat (limited to 'app/dispatch/models.py')
-rw-r--r--app/dispatch/models.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/app/dispatch/models.py b/app/dispatch/models.py
index 13b4e8b..0dd2ac7 100644
--- a/app/dispatch/models.py
+++ b/app/dispatch/models.py
@@ -2,6 +2,8 @@ from django.db import models
from django.conf import settings
from auditlog.registry import auditlog
+import uuid
+
# Create your models here.
class Company(models.Model):
@@ -20,16 +22,26 @@ class Load(models.Model):
user = models.ForeignKey(settings.AUTH_USER_MODEL)
company = models.ForeignKey(Company)
description = models.CharField(max_length=256)
+ delivered_to = models.CharField(max_length=256, default="")
amount = models.DecimalField(max_digits=10,decimal_places=2, default="0")
def __str__(self):
return "{c}, {d} ( {a} )".format(c=self.company, d=self.description, a=self.amount)
+
+
+
+# This is used to set the upload path of the document for Paperwork Objects
+def paperwork_user_directory_path(instance, filename):
+ # We don't want the UUID to be too long, just enough so there aren't any
+ # filename conflicts
+ return 'paperwork/{:d}/'.format(instance.load.pk) + \
+ str(uuid.uuid4())[0:9] + filename
+
class Paperwork(models.Model):
load = models.ForeignKey(Load, on_delete=models.CASCADE)
description = models.CharField(max_length=256)
- filename = models.CharField(max_length=256)
- document = models.FileField(upload_to='paperwork/')
+ document = models.FileField(upload_to=paperwork_user_directory_path)
def __str__(self):
return "%s" % self.load
@@ -37,5 +49,6 @@ class Paperwork(models.Model):
+
auditlog.register(Company)
auditlog.register(Load)