diff --git a/ChangeLog b/ChangeLog index cd3e5fc..1a5174a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +v0.3 (27/05/2014) +** User ** + Add draft support + +** Dev ** + +** Bugs ** + + v0.2 (27/04/2014) ** User ** diff --git a/dynastie/forms.py b/dynastie/forms.py index 0860bdb..9cdd355 100755 --- a/dynastie/forms.py +++ b/dynastie/forms.py @@ -38,6 +38,11 @@ class PostForm(ModelForm): super(PostForm, self).__init__(*args, **kwargs) self.fields['category'].choices = [(cat.id, cat.name) for cat in Category.objects.all()] +class DraftForm(PostForm): + class Meta: + model = Draft + exclude = ('title_slug', 'creation_date', 'modification_date', 'author', 'blog', 'tags', 'content_format', 'published') + class CategoryForm(ModelForm): class Meta: model = Category diff --git a/dynastie/models.py b/dynastie/models.py index cc637cb..5d7d5b4 100755 --- a/dynastie/models.py +++ b/dynastie/models.py @@ -253,37 +253,7 @@ class Post(models.Model): self.title_slug = slugify(self.title) super(Post, self).save() - def createPost(self, content, tags): - b = self.blog - output = b.src_path - if not os.path.exists(output + '/_post'): - os.mkdir(output + '/_post') - - filename = output + '/_post/' + str(self.pk) - content = unicode(content) - content = content.encode('utf-8') - modif = True - - if os.path.exists(filename): - f = open(filename, 'rb') - src_md5 = hashlib.md5() - src_md5.update(f.read()) - f.close() - - dst_md5 = hashlib.md5() - dst_md5.update(content) - - if src_md5.digest() == dst_md5.digest(): - modif = False - else: - os.unlink(filename) - - if modif: - f = open(filename, 'wb') - f.write(content) - f.close() - self.modification_date=datetime.now() - + def manageTags(self, tags): tags_list = Tag.objects.filter(blog_id=self.blog.id) my_tags = [] # Create new tags @@ -334,6 +304,38 @@ class Post(models.Model): # print 'Remove ' + t.name_slug self.tags.remove(t) + def createPost(self, content, tags): + b = self.blog + output = b.src_path + if not os.path.exists(output + '/_post'): + os.mkdir(output + '/_post') + + filename = output + '/_post/' + str(self.pk) + content = unicode(content) + content = content.encode('utf-8') + modif = True + + if os.path.exists(filename): + f = open(filename, 'rb') + src_md5 = hashlib.md5() + src_md5.update(f.read()) + f.close() + + dst_md5 = hashlib.md5() + dst_md5.update(content) + + if src_md5.digest() == dst_md5.digest(): + modif = False + else: + os.unlink(filename) + + if modif: + f = open(filename, 'wb') + f.write(content) + f.close() + self.modification_date=datetime.now() + + self.manageTags(tags) self.save() def remove(self): @@ -368,6 +370,53 @@ class Post(models.Model): else: return 'text' +class Draft(Post): + def createDraft(self, content, tags): + b = self.blog + output = b.src_path + if not os.path.exists(output + '/_draft'): + os.mkdir(output + '/_draft') + + filename = output + '/_draft/' + str(self.pk) + content = unicode(content) + content = content.encode('utf-8') + modif = True + + if os.path.exists(filename): + f = open(filename, 'rb') + src_md5 = hashlib.md5() + src_md5.update(f.read()) + f.close() + + dst_md5 = hashlib.md5() + dst_md5.update(content) + + if src_md5.digest() == dst_md5.digest(): + modif = False + else: + os.unlink(filename) + + if modif: + f = open(filename, 'wb') + f.write(content) + f.close() + self.modification_date=datetime.now() + + self.manageTags(tags) + self.save() + + def remove(self): + b = self.blog + + output = b.src_path + filename = output + '/_draft/' + str(self.pk) + if os.path.exists(filename): + os.unlink(filename) + + def save(self): + self.published = False + super(Draft, self).save() + class Comment(models.Model): post = models.ForeignKey(Post) parent = models.ForeignKey('self', null=True, blank=True) diff --git a/dynastie/sites/blog.soutade.fr/_base.html b/dynastie/sites/blog.soutade.fr/_base.html index e7a5b82..fc768b5 100755 --- a/dynastie/sites/blog.soutade.fr/_base.html +++ b/dynastie/sites/blog.soutade.fr/_base.html @@ -14,7 +14,7 @@ - +
diff --git a/dynastie/sites/blog.soutade.fr/_base_post.html b/dynastie/sites/blog.soutade.fr/_base_post.html index 2cb4abc..e262102 100644 --- a/dynastie/sites/blog.soutade.fr/_base_post.html +++ b/dynastie/sites/blog.soutade.fr/_base_post.html @@ -15,7 +15,7 @@ - +
diff --git a/dynastie/sites/blog.soutade.fr/_ljdc.xml b/dynastie/sites/blog.soutade.fr/_ljdc.xml index c704657..699dad3 100644 --- a/dynastie/sites/blog.soutade.fr/_ljdc.xml +++ b/dynastie/sites/blog.soutade.fr/_ljdc.xml @@ -1,5 +1,23 @@ + + 85704348740 +
http://lesjoiesducode.fr/post/85704348740/quand-le-client-reclame-une-feature-hors-cahier-des
+ quand le client réclame une feature hors cahier des charges et qu'on lui renvoie en réponse sa facture impayée + http://i.imgur.com/3minh1d.gif +
+ + 72755714066 +
http://lesjoiesducode.fr/post/72755714066/quand-on-me-demande-si-je-veux-relire-la-doc
+ quand on me demande si je veux relire la doc + http://ljdchost.com/5jFD7OS.gif +
+ + 84217503221 +
http://thecodinglove.com/post/84217503221/when-i-have-a-bad-feeling-about-the-project
+ when I have a bad feeling about the project + http://i.imgur.com/GMU8de2.gif +
84208887361
http://thecodinglove.com/post/84208887361/when-the-intern-modifies-my-code
@@ -160,7 +178,7 @@ 69485497531
http://lesjoiesducode.fr/post/69485497531/quand-les-collegues-se-ramassent-sur-un-projet-sur
quand les collègues se ramassent sur un projet sur lequel je ne travaille pas - http://i.imgur.com/4YwDi.png + http://ljdchost.com/FCpwSIk.gif
68966745060 diff --git a/dynastie/templates/add_post.html b/dynastie/templates/add_post.html index a9321b8..6cf271b 100755 --- a/dynastie/templates/add_post.html +++ b/dynastie/templates/add_post.html @@ -32,7 +32,7 @@ Available tags: {% endif %}
- + {% if editor == "html" %}