Fix add_post encoding bug + some minor bugs

This commit is contained in:
Grégory Soutadé 2012-09-09 11:57:15 +02:00
parent e99280e21c
commit c60cd7e3f8
3 changed files with 9 additions and 6 deletions

View File

@ -225,7 +225,8 @@ class Post(models.Model):
if os.path.exists(filename):
os.unlink(filename)
f = open(filename, 'wb')
f.write(content)
content = unicode(content)
f.write(content.encode('utf-8'))
f.close()
def remove(self):
@ -244,14 +245,14 @@ class Post(models.Model):
if os.path.exists(filename):
os.unlink(filename)
filename = b.output_path + '/post/'
filename = b.src_path + '/post/'
filename = filename + self.creation_date.strftime("%Y") + '/' + self.creation_date.strftime("%m") + '/'
if len(os.listdir(filename)) == 0:
if os.path.exists(filename) and len(os.listdir(filename)) == 0:
os.rmdir(filename)
filename = b.output_path + '/post/'
filename = filename + self.creation_date.strftime("%Y") + '/'
if len(os.listdir(filename)) == 0:
if os.path.exists(filename) and len(os.listdir(filename)) == 0:
os.rmdir(filename)
class Comment(models.Model):

View File

@ -9,7 +9,9 @@ tinyMCE.init({
theme : "advanced",
plugins : "autolink,lists,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
editor_selector : "mceAdvanced",
encoding : "raw",
entities : "",
entity_encoding : "raw",
// Theme options
theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect,fontselect,fontsizeselect",
theme_advanced_buttons2 : "bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",

View File

@ -24,7 +24,7 @@
{% else %}
<table>
{% for post in posts %}
<tr><td><a href="/post/edit/{{ post.id }}">{{ post.id }}</a></td><td>{{ post.title }}</td><td>{{ post.category.name }}</td><td>{{ post.creation_date }}</td><td>{{ post.published }}</td><td>{{ post.front_page }}</td><td><a href="/post/delete/{{ post.id }}">Delete</a></td></tr>
<tr><td><a href="/post/edit/{{ post.id }}">{{ post.id }}</a></td><td>{{ post.title }}</td><td>{{ post.category.name }}</td><td>{{ post.creation_date }}</td><td>{{ post.modification_date }}</td><td>{{ post.published }}</td><td>{{ post.front_page }}</td><td><a href="/post/delete/{{ post.id }}">Delete</a></td></tr>
{% endfor %}
{% endif %}
</table>