Added valid property to VoucherModel.
This commit is contained in:
		@@ -15,6 +15,7 @@ from django.contrib.auth.models import User
 | 
			
		||||
from django.db.models.signals import post_save
 | 
			
		||||
from django.dispatch import receiver
 | 
			
		||||
from django.core.validators import MaxValueValidator, MinValueValidator
 | 
			
		||||
from django.utils import timezone
 | 
			
		||||
from easy_thumbnails.fields import ThumbnailerImageField
 | 
			
		||||
from easy_thumbnails.files import get_thumbnailer
 | 
			
		||||
from taggit.managers import TaggableManager
 | 
			
		||||
@@ -106,6 +107,10 @@ class Voucher(models.Model):
 | 
			
		||||
    created_when = models.DateTimeField(auto_now_add=True)
 | 
			
		||||
    expires_when = models.DateTimeField()
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    def valid(self):
 | 
			
		||||
        return timezone.now() <= self.expires_when
 | 
			
		||||
 | 
			
		||||
    def __str__(self):
 | 
			
		||||
        return "Voucher " + str(self.pk)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user