Permalink
Browse files

Better date parsing, and meta post won't get auto-dated and now set t…

…o draft
  • Loading branch information...
1 parent a423fb5 commit 224fa0488011a350f8b3ec7d792e349e0cfbc896 Yaroslav Shirokov committed Apr 4, 2009
Showing with 6 additions and 6 deletions.
  1. +1 −2 posts/meta/meta.yaml
  2. +5 −4 src/util/article.py
View
3 posts/meta/meta.yaml
@@ -2,6 +2,5 @@
author:
email: user@example.com
name: Example User
-date: '2009-03-30T19:31:25'
name: Meta-blogging
-status: published
+status: draft
View
9 src/util/article.py
@@ -25,11 +25,12 @@ def name(self):
def date(self):
from dateutil.parser import parser
from datetime import datetime
- if not self.meta.has_key('date'):
- self.meta.date = datetime.fromtimestamp(
- os.stat(os.path.join(settings.POST_ROOT, self.slug)).st_mtime).isoformat()
+ date = (self.meta.has_key('date') and parser().parse(self.meta.date)) or \
+ datetime.fromtimestamp(os.stat(os.path.join(settings.POST_ROOT, self.slug)).st_mtime).isoformat()
+ if not self.meta.has_key('date') and self.meta.get('status', '*no-status*') == 'published':
+ self.meta.date = date
self.save()
- return parser().parse(self.meta.date)
+ return date
@property
def compiled(self):

0 comments on commit 224fa04

Please sign in to comment.