Making expireable a abstract model

This commit is contained in:
2020-10-04 22:11:37 +02:00
parent 76b514e1e6
commit cfbe54a4e5
3 changed files with 57 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
from django.utils import timezone
from django.db import models
from django.core.validators import MaxValueValidator, MinValueValidator
@@ -55,7 +56,14 @@ class Submittable(models.Model):
class Expireable(models.Model):
"""
Base class for things that can expire, i.e. VouchersAv
Base class for things that can expire, i.e. Vouchers
"""
class Meta:
abstract = True
created_when = models.DateTimeField(auto_now_add=True)
expires_when = models.DateTimeField()
expires_when = models.DateTimeField()
@property
def is_expired(self):
return timezone.now() > self.expires_when