示例#1
0
    def modify_blog(cls, blog_id, title, tag, category, hide, content):
        blog = cls.get(cls.id == blog_id)
        blog.title = title
        if hide == 'False':
            blog.hide = False
        else:
            blog.hide = True
        blog.content_md = content
        blog.content_html = md2html(content)
        blog.save()

        check_tag = Tags.has_tag(tag)
        blogtags = BlogTags.get(BlogTags.blog_id == blog.id)
        if check_tag:
            blogtags.tags_id = check_tag.id
        else:
            tag = Tags.create(tag=tag)
            blogtags.tags_id = tag.id
        blogtags.save()

        check_category = Category.has_category(category)
        blogcategory = BlogCategory.get(BlogCategory.blog_id == blog.id)
        if check_category:
            blogcategory.category_id = check_category.id
        else:
            category = Category.create(category=category)
            blogcategory.category_id = category.id
        blogcategory.save()
示例#2
0
 def create_note(cls, title, tag, hide, content):
     blog = cls.create(
         title=title,
         tag=tag,
         content_md=content
     )
     if hide == 'False':
         blog.hide = False
     else:
         blog.hide = True
     blog.content_html = md2html(content)
     blog.save()
示例#3
0
    def create_new_blog(cls, title, tag, category, hide, content):
        blog = cls.create(title=title,
                          content_md=content)

        if hide == 'False':
            blog.hide = False
        else:
            blog.hide = True
        blog.content_html = md2html(content)
        blog.save()

        check_tag = Tags.has_tag(tag)
        if check_tag:
            BlogTags.create(blog_id=blog.id, tags_id=check_tag.id)
        else:
            tag = Tags.create(tag=tag)
            BlogTags.create(blog_id=blog.id, tags_id=tag.id)

        check_category = Category.has_category(category)
        if check_category:
            BlogCategory.create(blog_id=blog.id, category_id=check_category.id)
        else:
            category = Category.create(category=category)
            BlogCategory.create(blog_id=blog.id, category_id=category.id)