--- a/qrurls/models.py Mon Jul 15 03:13:51 2013 +0300
+++ b/qrurls/models.py Mon Jul 15 03:17:11 2013 +0300
@@ -70,29 +70,23 @@
m, s = divmod(seconds, 60)
h, m = divmod(m, 60)
- return days, "{h}h {m}m {s}s".format(h=h, m=m, s=s)
+ return (self.published < now), days, "{h}h {m}m {s}s".format(h=h, m=m, s=s)
def published_state (self) :
- now = timezone.now()
-
- publish_date = self.published.strftime("%Y-%m-%d")
-
- days, age = self.published_age()
+ date = self.published.strftime("%Y-%m-%d")
+ published, days, age = self.published_age()
- if self.published < now and days :
- return "Published ({date})".format(date=publish_date)
- elif self.published < now :
- return "Published ({age})".format(age=age)
+ if published and days :
+ return "[{date}]".format(date=date)
+ elif published :
+ return "[{age}]".format(age=age)
elif days :
- return "Scheduled ({when})".format(when=publish_date)
+ return "({when})".format(when=date)
else :
- return "Scheduled ({age})".format(age=age)
+ return "({age})".format(age=age)
def __unicode__ (self) :
- days, age = self.published_age()
-
- return u"[{days}d {age}] {url}".format(
+ return u"{published_state} {url}".format(
+ published_state=self.published_state(),
url=self.get_absolute_url(),
- days=days,
- age=age,
)