Exemple #1
0
 def load_from_data(self,data):
     self.id = data.get('id',0)
     self.root_category_id = data.get('root_category_id',0)
     self.category_id = data.get('category_id',0)
     self.category_id2 = data.get('category_id2',0)
     self.category_id3 = data.get('category_id3',0)
     self.title = data.get('title','')
     self.author = data.get('author','')
     self.source = data.get('source','')
     self.short_description = data.get('short_description','')
     self.description = data.get('description','')
     self.demo_code = data.get('demo_code','')
     self.demo_url = data.get('demo_url','')
     self.dev_view_code = data.get('dev_view_code','')
     self.full_download_url = data.get('full_download_url','')
     self.head_code = data.get('head_code','')
     self.body_code = data.get('body_code','')
     self.compatibility = data.get('compatibility','')
     self.pic = data.get('pic','')
     self.small_pic = data.get('small_pic','')
     self.topic_id = data.get('topic_id',0)
     self.state = data.get('state',0)
     self.isrtdate = func.str_to_datetime(data.get('isrtdate',str(datetime.datetime.now())))
     self.hits = data.get('hits',0)
     self.download = data.get('download',0)
     self.recommend = data.get('recommend',0)
     self.last_hit_date = func.str_to_datetime(data.get('last_hit_date',str(datetime.datetime.now())))
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)