Exemple #1
0
#列表目录到数组
root_dir = r'D:\python\sharejs\vectors\d1'

dirs = os.listdir(root_dir)
print(dirs)

i=0;
#dirs =['blue', 'cantya', 'creative-media', 'green', 'happy-print-shop', 'indeziner-form-templates', 'one-page-cv', 'product-landing-page', 'sindromk', 'violet', 'write-to-santa']
for dir in dirs:
    i+=1
    if i<=100000:
        article = Article()
        article.title = u'矢量素材'
        article.short_description=u'矢量图格式为EPS,含JPG预览图,关键词:'
        article.compatibility = u''
        #article.demo_url = '/vectors/d1/%s/index.html'%dir
        article.root_category_id = 700
        article.category_id = 751
        article.full_download_url = '/vectors/d1/%s/%s.zip'%(dir,dir)
        article.pic = '/vectors/d1/%s/demo.jpg'%dir
        img_description = ''
        for file in os.listdir(root_dir + '\\' + dir):
            if file.endswith('.jpg') and file != 'demo.jpg':
                img_description += '[img]%s[/img]\r\n'%('/vectors/d1/'+dir+'/'+file)
        article.description = img_description
        #article.source = ''
        article_facade = factory.create_article_facade()
        article_facade.post_data(article)
        print(dir + '  finished')
Exemple #2
0
def article_edit(request):
    '文章编辑'
    article_facade = facade.factory.create_article_facade()
    topic_facade = facade.factory.create_topic_facade()
    category_facade = facade.factory.create_category_facade()
    tag_facade = facade.factory.create_tag_facade()

    #如果是提交信息
    if request.method =="POST":
        article = Article()
        id = func.get_int_param_from_post(request,'id')
        article.id=id
        article.title = func.get_str_param_from_post(request,'title')
        article.root_category_id = func.get_int_param_from_post(request,'root_category')
        article.category_id = func.get_int_param_from_post(request,'category1')
        article.category_id2 = func.get_int_param_from_post(request,'category2')
        article.category_id3 = func.get_int_param_from_post(request,'category3')
        article.author = func.get_str_param_from_post(request,'author')
        article.source = func.get_str_param_from_post(request,'source')
        article.short_description = func.get_str_param_from_post(request,'short_description')
        article.description = func.get_str_param_from_post(request,'description')
        article.demo_code = func.get_str_param_from_post(request,'demo_code')
        article.demo_url = func.get_str_param_from_post(request,'demo_url')
        article.dev_view_code = func.get_str_param_from_post(request,'dev_view_code')
        article.full_download_url = func.get_str_param_from_post(request,'full_download_url')
        article.head_code = func.get_str_param_from_post(request,'head_code')
        article.body_code = func.get_str_param_from_post(request,'body_code')
        article.compatibility = func.get_str_param_from_post(request,'compatibility')
        article.pic = func.get_str_param_from_post(request,'pic')
        article.small_pic = func.get_str_param_from_post(request,'small_pic')
        article.recommend = func.get_str_param_from_post(request,'recommend')=='on'
        article.topic_id = func.get_str_param_from_post(request,'topic_id')
        article.state = 0
        article.isrtdate = func.format_date_time(func.str_to_datetime(func.get_str_param_from_post(request,'isrtdate')))
        article.last_hit_date=func.format_date_time(func.str_to_datetime(func.get_str_param_from_post(request,'last_hit_date')))
        article.hits = func.get_int_param_from_post(request,'hits')

        id = article_facade.post_data(article)
        #添加Tags
        tag_facade.insert_tags(id,func.get_str_param_from_post(request,'tags'))

        refer_url = func.get_str_param_from_post(request,'refer_url')
        if not refer_url:
            refer_url = "article_list"

        return HttpResponseRedirect(refer_url)
        

    id = func.get_int_param_from_get(request,'id')
    output = {}

    if id>0:
        article = article_facade.get_data(id)
        article.tags = tag_facade.get_tags_str(id)
        output['article'] = article

    topic_list = topic_facade.get_all_topic()
    root_category_list = category_facade.get_child_category_list(0)
    output['topic_list'] = topic_list
    output['root_category_list'] = root_category_list
    output['refer_url'] = func.get_referer(request,'article_list')
    

    return render_to_response('admin/article_edit.html',output)