2013-08-26 03:35:27 +00:00
|
|
|
from datetime import timedelta, datetime
|
|
|
|
|
|
|
|
from django.db import models
|
|
|
|
|
|
|
|
class Boox(models.Model):
|
|
|
|
"""
|
|
|
|
keeps a record of a file that's been watermarked
|
|
|
|
"""
|
2018-06-08 19:17:39 +00:00
|
|
|
download_link_epub = models.URLField(null=True)
|
|
|
|
download_link_mobi = models.URLField(null=True)
|
2013-08-26 03:35:27 +00:00
|
|
|
referenceid = models.CharField(max_length=32)
|
2018-06-08 19:17:39 +00:00
|
|
|
downloads_remaining = models.PositiveSmallIntegerField(default=0)
|
2013-08-26 03:35:27 +00:00
|
|
|
expirydays = models.PositiveSmallIntegerField()
|
|
|
|
created = models.DateTimeField(auto_now_add=True)
|
2018-06-08 19:17:39 +00:00
|
|
|
|
2013-08-26 03:35:27 +00:00
|
|
|
@property
|
|
|
|
def expired(self):
|
|
|
|
return self.created+timedelta(days=self.expirydays) < datetime.now()
|
2018-06-08 19:17:39 +00:00
|
|
|
|
2013-11-15 04:16:55 +00:00
|
|
|
def download_link(self, format):
|
|
|
|
if format == 'epub':
|
|
|
|
return self.download_link_epub
|
|
|
|
elif format == 'mobi':
|
|
|
|
return self.download_link_mobi
|
2018-06-08 19:17:39 +00:00
|
|
|
return None
|
|
|
|
|