announce status computing methods

This commit is contained in:
Serghei Mihai 2015-01-13 18:43:37 +01:00
parent e0d858ba2b
commit a37431771f
1 changed files with 13 additions and 0 deletions

View File

@ -26,6 +26,19 @@ class Announce(models.Model):
return u'{title} ({id}) at {mtime}'.format(title=self.title,
id=self.id, mtime=self.mtime)
def is_published(self):
if self.publication_time:
if self.expiration_time:
return self.publication_time <= timezone.now() < self.expiration_time
return self.publication_time <= timezone.now()
def is_expired(self):
if self.expiration_time:
return self.expiration_time > timezone.now()
def is_not_published(self):
return not self.publication_time
class Meta:
verbose_name = _('announce')
ordering = ('-mtime',)