def metaWeblog_newPost(blogid, username, password, struct, publish): user = User.objects.get(username__exact=username) if struct.has_key('title') and struct.has_key('description'): post = Entry(title=struct['title'],content = struct['description']) post.author=user if struct.has_key('categories'): catename = struct['categories'][0] cate=Category.objects.get(name__exact=catename) post.category=cate else: post.category_id=1 if struct.has_key('mt_keywords'): post.tags=struct['mt_keywords'] if struct.has_key('wp_slug'): post.slug=struct['wp_slug'] post.save(True) return ""
def quick_post(request): title=request.POST.get('title') content=request.POST.get('content','') tags=request.POST.get('tags','') save=request.POST.get('save') publish=request.POST.get('publish') if not title and not content: return HttpResponse(u"文章标题和内容不能为空!") entry=Entry(title=title,content=content,tags=tags,slug='',allow_comment=True) entry.author=request.user entry.category_id=1 if save: entry.save(False) html=u"<p>文章已保存. <a href='/admin/editpost/%s'>编辑文章</a></p>"%(str(entry.id)) elif publish: entry.save(True) html=u"<p>文章已发布. <a href='%s' target='_blank'>查看文章</a></p>"%(entry.get_absolute_url()) return HttpResponse(html)