announce status computing methods
This commit is contained in:
parent
e0d858ba2b
commit
a37431771f
|
@ -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',)
|
||||
|
|
Reference in New Issue