Set title to be article's title

This commit is contained in:
Grégory Soutadé 2012-08-28 10:42:33 +02:00
parent c393ea7197
commit f7969e6134
5 changed files with 16 additions and 7 deletions

View File

@ -12,6 +12,14 @@ class Post(Index):
post_elem = post_nodes[0]
post_elem.parentNode.removeChild(post_elem)
title_nodes = dom.getElementsByTagName("title")
# Set title to be title's post
for node in title_nodes:
if node.hasChildNodes():
node.removeChild(node.childNodes[0])
node.appendChild(dom.createTextNode(post.title))
def generate(self, blog, src, output):
from dynastie.models import Post, Blog

View File

@ -243,12 +243,12 @@ class Post(models.Model):
if os.path.exists(filename):
os.unlink(filename)
filename = output + '/post/'
filename = b.output_path + '/post/'
filename = filename + self.creation_date.strftime("%Y") + '/' + self.creation_date.strftime("%m") + '/'
if len(os.listdir(filename)) == 0:
os.rmdir(filename)
filename = output + '/post/'
filename = b.output_path + '/post/'
filename = filename + self.creation_date.strftime("%Y") + '/'
if len(os.listdir(filename)) == 0:
os.rmdir(filename)
@ -263,12 +263,12 @@ class Comment(models.Model):
@receiver(post_init, sender=Blog)
def delete_blog_signal(sender, **kwargs):
sender.create_paths()
kwargs['instance'].create_paths()
@receiver(post_delete, sender=Blog)
def delete_blog_signal(sender, **kwargs):
sender.remove()
kwargs['instance'].remove()
@receiver(post_delete, sender=Post)
def delete_post_signal(sender, **kwargs):
sender.remove()
kwargs['instance'].remove()

View File

@ -142,7 +142,7 @@ def edit_category(request, category_id):
name = category.name
form = CategoryForm(request.POST, instance=category) # A form bound to the POST data
if form.is_valid(): # All validation rules pass
if category.name != name:
if form['name'] != name:
category.remove()
form.save()
else:
@ -298,8 +298,9 @@ def edit_post(request, post_id):
if 'edit' in request.POST:
form = PostForm(request.POST, instance=post) # A form bound to the POST data
if form.is_valid(): # All validation rules pass
if title != form.title:
if title != form['title']:
post.remove()
post.createPost(form['content'])
form.save()
# Process the data in form.cleaned_data
# ...