Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Some bugfixes for editing posts.

  • Loading branch information...
commit e0c996b7af90b26b30c04c727a5909629a5c132b 1 parent 308a1e3
@joeyb authored
Showing with 7 additions and 7 deletions.
  1. +2 −2 handlers/admin.py
  2. +5 −5 models/blog.py
View
4 handlers/admin.py
@@ -64,7 +64,7 @@ def get(self, year, month, day, slug):
page = view.Page()
page.render_error(self, 404)
else:
- action_url = "/admin/post/edit%s" % post.get_absolute_url()
+ action_url = post.get_edit_url()
template_values = {
'action': action_url,
@@ -96,7 +96,7 @@ def post(self, year, month, day, slug):
page = view.Page()
page.render_error(self, 404)
else:
- action_url = "/admin/post/edit%s" % post.get_absolute_url()
+ action_url = post.get_edit_url()
post.title = self.request.get('title')
post.body = self.request.get('body')
View
10 models/blog.py
@@ -73,11 +73,11 @@ def test_for_slug_collision(self):
query.filter('pub_date < ', end_date)
query.filter('slug = ', self.slug)
- # Get the number of slug matches
- count = query.count(1)
+ # Get the Post Key that match the given query (if it exists)
+ post = query.get()
# If any slug matches were found then an exception should be raised
- if count == 1:
+ if post and (not self.is_saved() or self.key() != post):
raise SlugConstraintViolation(start_date, self.slug)
def populate_html_fields(self):
@@ -85,9 +85,9 @@ def populate_html_fields(self):
md = markdown.Markdown(extensions=['codehilite'])
# Convert the excerpt and body Markdown into html
- if self.excerpt_html == None and self.excerpt != None:
+ if self.excerpt != None:
self.excerpt_html = md.convert(self.excerpt)
- if self.body_html == None and self.body != None:
+ if self.body != None:
self.body_html = md.convert(self.body)
class SlugConstraintViolation(Exception):
Please sign in to comment.
Something went wrong with that request. Please try again.