add /shipping_vouchers endpoint
This commit is contained in:
parent
2f354130da
commit
f11758607e
6 changed files with 123 additions and 5 deletions
|
@ -1,4 +1,5 @@
|
|||
from django.db import models
|
||||
from django.utils import timezone
|
||||
from django_softdelete.models import SoftDeleteModel
|
||||
|
||||
from authentication.models import ExtendedUser
|
||||
|
@ -116,3 +117,20 @@ class Assignment(models.Model):
|
|||
|
||||
def __str__(self):
|
||||
return str(self.issue_thread) + ' assigned to ' + self.assigned_to.username
|
||||
|
||||
|
||||
class ShippingVoucher(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
issue_thread = models.ForeignKey(IssueThread, on_delete=models.CASCADE, related_name='shipping_vouchers', null=True)
|
||||
voucher = models.CharField(max_length=255)
|
||||
type = models.CharField(max_length=255)
|
||||
timestamp = models.DateTimeField(auto_now_add=True)
|
||||
used_at = models.DateTimeField(null=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.voucher + ' (' + self.type + ')'
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
if self.used_at is None and self.issue_thread is not None:
|
||||
self.used_at = timezone.now()
|
||||
super().save(*args, **kwargs)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue