From 2fdfacc4d79ccedda199999ab217bad7f29c1174 Mon Sep 17 00:00:00 2001 From: Thomas Steen Rasmussen Date: Mon, 30 May 2016 19:49:32 +0200 Subject: [PATCH] switch to using a filefield to save the invoice pdf --- shop/management/commands/invoice-worker.py | 4 ++-- shop/models.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/shop/management/commands/invoice-worker.py b/shop/management/commands/invoice-worker.py index 933793d2..b2210507 100644 --- a/shop/management/commands/invoice-worker.py +++ b/shop/management/commands/invoice-worker.py @@ -43,8 +43,8 @@ class Command(BaseCommand): self.stdout.write('ERROR: Unable to generate PDF file for invoice #%s' % invoice.pk) continue - # update invoice object - invoice.pdf_generated=True + # update invoice object with the file + invoice.pdf.save(invoice.filename, File(pdffile)) invoice.save() ### check if we need to send out any invoices diff --git a/shop/models.py b/shop/models.py index 5467e644..74c8899d 100644 --- a/shop/models.py +++ b/shop/models.py @@ -255,7 +255,7 @@ class EpayPayment(CreatedUpdatedModel, UUIDModel): class Invoice(CreatedUpdatedModel): order = models.OneToOneField('shop.Order') - pdf_generated = models.BooleanField(default=False) + pdf = models.FileField(null=True, blank=True) sent_to_customer = models.BooleanField(default=False) def __str__(self):