Пример #1
0
    def handle(self, *args, **options):
        try:
            self.stdout.write('Starting import of pelican blog\n')
            from pelican_admin.models import Settings, BlogPost

            if settings.PELICAN_PATH:
                self.stdout.write('Importing settings\n')
                Settings.load_from_path()

                self.stdout.write('Importing blog posts\n')
                BlogPost.load_posts()

            self.stdout.write('Finished importing pelican blog\n')
        except ImportError, e:
            self.stderr.write(e)
Пример #2
0
    def handle(self, *args, **options):
        try:
            self.stdout.write('Starting import of pelican blog\n')
            from pelican_admin.models import Settings, BlogPost

            if settings.PELICAN_PATH:
                self.stdout.write('Importing settings\n')
                Settings.load_from_path()

                self.stdout.write('Importing blog posts\n')
                BlogPost.load_posts()

            self.stdout.write('Finished importing pelican blog\n')
        except ImportError, e:
            self.stderr.write(e)
Пример #3
0
def view_draft(request):
    blog_form = BlogPostAdmin(BlogPost, site)
    form = blog_form.get_form(request)(request.POST)

    form.is_valid()

    remove_later = False

    try:
        blog_post = BlogPost.get_from_meta(
            markup=form.cleaned_data.get('markup'),
            title=form.cleaned_data.get('title'),
            slug=form.cleaned_data.get('slug'))
    except BlogPost.DoesNotExist:
        remove_later = True
        blog_post = BlogPost()

    for key in form.cleaned_data.keys():
        setattr(blog_post, key, form.cleaned_data.get(key))

    blog_post.status = 'draft'
    blog_post.write()

    time.sleep(2)

    if remove_later:
        os.remove(blog_post.file_path)

    return HttpResponseRedirect('/admin/pelican_blog/drafts/%s.html' %
                                blog_post.get_slug())
Пример #4
0
def view_draft(request):
    blog_form = BlogPostAdmin(BlogPost, site)
    form = blog_form.get_form(request)(request.POST)

    form.is_valid()

    remove_later = False

    try:
        blog_post = BlogPost.get_from_meta(
            markup=form.cleaned_data.get('markup'),
            title=form.cleaned_data.get('title'),
            slug=form.cleaned_data.get('slug'))
    except BlogPost.DoesNotExist:
        remove_later = True
        blog_post = BlogPost()

    for key in form.cleaned_data.keys():
        setattr(blog_post, key, form.cleaned_data.get(key))

    blog_post.status = 'draft'
    blog_post.write()

    time.sleep(2)

    if remove_later:
        os.remove(blog_post.file_path)

    return HttpResponseRedirect('/admin/pelican_blog/drafts/%s.html' % blog_post.get_slug())