Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

…o draft
  • Loading branch information...
commit 224fa0488011a350f8b3ec7d792e349e0cfbc896 1 parent a423fb5
Yaroslav Shirokov authored

Showing 2 changed files with 6 additions and 6 deletions. Show diff stats Hide diff stats

  1. +1 2  posts/meta/meta.yaml
  2. +5 4 src/util/article.py
3  posts/meta/meta.yaml
@@ -2,6 +2,5 @@
2 2 author:
3 3 email: user@example.com
4 4 name: Example User
5   -date: '2009-03-30T19:31:25'
6 5 name: Meta-blogging
7   -status: published
  6 +status: draft
9 src/util/article.py
@@ -25,11 +25,12 @@ def name(self):
25 25 def date(self):
26 26 from dateutil.parser import parser
27 27 from datetime import datetime
28   - if not self.meta.has_key('date'):
29   - self.meta.date = datetime.fromtimestamp(
30   - os.stat(os.path.join(settings.POST_ROOT, self.slug)).st_mtime).isoformat()
  28 + date = (self.meta.has_key('date') and parser().parse(self.meta.date)) or \
  29 + datetime.fromtimestamp(os.stat(os.path.join(settings.POST_ROOT, self.slug)).st_mtime).isoformat()
  30 + if not self.meta.has_key('date') and self.meta.get('status', '*no-status*') == 'published':
  31 + self.meta.date = date
31 32 self.save()
32   - return parser().parse(self.meta.date)
  33 + return date
33 34
34 35 @property
35 36 def compiled(self):

0 comments on commit 224fa04

Please sign in to comment.
Something went wrong with that request. Please try again.