Revision 36e2db0b
Added by Serghei Mihai over 9 years ago
corbo/models.py | ||
---|---|---|
17 | 17 |
help_text=_('maximum 256 characters')) |
18 | 18 |
text = RichTextField(_('Content')) |
19 | 19 |
publication_time = models.DateTimeField(_('publication time'), blank=True, |
20 |
null=True, default=timezone.now)
|
|
20 |
null=True) |
|
21 | 21 |
expiration_time = models.DateTimeField(_('expiration time'), blank=True, |
22 | 22 |
null=True) |
23 | 23 |
ctime = models.DateTimeField(_('creation time'), auto_now_add=True) |
... | ... | |
28 | 28 |
return u'{title} ({id}) at {mtime}'.format(title=self.title, |
29 | 29 |
id=self.id, mtime=self.mtime) |
30 | 30 |
|
31 |
def is_published(self): |
|
32 |
if self.publication_time: |
|
33 |
if self.expiration_time: |
|
34 |
return self.publication_time <= timezone.now() < self.expiration_time |
|
35 |
return self.publication_time <= timezone.now() |
|
36 |
|
|
37 | 31 |
def is_expired(self): |
38 | 32 |
if self.expiration_time: |
39 |
return self.expiration_time > timezone.now() |
|
33 |
return self.expiration_time < timezone.now() |
|
34 |
return False |
|
40 | 35 |
|
41 |
def is_not_published(self): |
|
42 |
return not self.publication_time |
|
36 |
def is_published(self): |
|
37 |
if self.is_expired(): |
|
38 |
return False |
|
39 |
if self.publication_time: |
|
40 |
return self.publication_time <= timezone.now() |
|
41 |
return False |
|
43 | 42 |
|
44 | 43 |
class Meta: |
45 | 44 |
verbose_name = _('announce') |
Also available in: Unified diff
announce object status methods refactored