Skip to content
This repository has been archived by the owner on Feb 1, 2023. It is now read-only.

Commit

Permalink
Small fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Depado committed May 13, 2015
1 parent 870cd0f commit 253fca5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/models/post.py
Expand Up @@ -23,6 +23,9 @@ class Post(db.Model):
def __init__(self, **kwargs):
super(Post, self).__init__(**kwargs)
self.pub_date = self.pub_date if self.pub_date is not None else datetime.utcnow()
self.set_title_slug()

def set_title_slug(self):
self.title_slug = slugify("{date}-{title}".format(date=str(self.pub_date.date()), title=self.title))

def save(self):
Expand Down
1 change: 1 addition & 0 deletions app/views/post.py
Expand Up @@ -44,6 +44,7 @@ def edit(post_id):

post.title = form.title.data
post.content = form.content.data
post.set_title_slug()
saved = post.save()
if saved:
flash("Successfully saved the post.")
Expand Down

0 comments on commit 253fca5

Please sign in to comment.