Example #1
0
def admin_editpost():
	_article = None
	if request.method == 'POST':
		if request.form.get('act', '')=='editpost':
			_tags = request.form.get('tags', '').replace(u',',',')
			tagslist = set([x.strip() for x in _tags.split(',')])
			try:
				tagslist.remove('')
			except:
				pass
			if tagslist:
				_tags = ','.join(tagslist)
			operatorDB.update_article(request.form.get('id', ''),request.form.get('category', ''),request.form.get('title', ''),request.form.get('content', ''),_tags,request.form.get('password', ''),shorten_content(request.form.get('content', '')))
		post_id = request.form.get('id', '')
		_article = operatorDB.detail_post_by_id(post_id)
	cats = operatorDB.get_all_cat_name()
	tags = operatorDB.get_all_tag_name()
	return render_template('admin/editpost_admin.html',obj=_article,cats=cats,tags=tags,SITE_TITLE=setting.SITE_TITLE,BASE_URL=setting.BASE_URL)
Example #2
0
def admin_editpost():
    _article = None
    if request.method == 'POST':
        post_id = request.form.get('id', '')
        if request.form.get('act', '')=='editpost':
            _post_type = request.form.get('post_type', '')
            if _post_type == '':
                _post_type = 0
            _tags = request.form.get('tags', '').replace(u',',',')
            tagslist = set([x.strip() for x in _tags.split(',')])
            try:
                tagslist.remove('')
            except:
                pass
            if tagslist:
                _tags = ','.join(tagslist)
            imgsrc = re.search("img src=(\S*)", request.form.get('content', ''))
            imgthumbnail = ''
            if imgsrc:
                imgext = re.search("(\.\w*)$", imgsrc.group(1))
                if imgext:
                    logging.error(">>admin_addpost: %s" % imgsrc.group(1)+"_thumbnail"+ imgext.group(1))
                    imgthumbnail = imgsrc.group(1)+"_thumbnail"+ imgext.group(1)
            operatorDB.update_article(request.form.get('id', ''),
                                      request.form.get('category', ''),
                                      request.form.get('title', ''),
                                      request.form.get('content', ''),
                                      _tags,request.form.get('password', ''),
                                      shorten_content(request.form.get('content', '')),
                                      imgthumbnail, _post_type,
                                      request.form.get('editor_title', '')
                                              )
            if _tags!='':
                operatorDB.add_postid_to_tags(_tags.split(','), str(post_id))
            operatorDB.add_postid_to_cat(request.form.get('category', ''),str(post_id))
            
        
        _article = operatorDB.detail_post_by_id(post_id)
        
    cats = operatorDB.get_all_cat_name()
    tags = operatorDB.get_all_tag_name()
    return render_template('admin/editpost_admin.html',obj=_article,cats=cats,tags=tags,SITE_TITLE=setting.SITE_TITLE,BASE_URL=setting.BASE_URL)
Example #3
0
def admin_editpost():
    _article = None
    if request.method == 'POST':
        post_id = request.form.get('id', '')
        if request.form.get('act', '')=='editpost':
            _post_type = request.form.get('post_type', '')
            if _post_type == '':
                _post_type = 0
            _tags = request.form.get('tags', '').replace(u',',',')
            tagslist = set([x.strip() for x in _tags.split(',')])
            try:
                tagslist.remove('')
            except:
                pass
            if tagslist:
                _tags = ','.join(tagslist)
            imgsrc = re.search("img src=(\S*)", request.form.get('content', ''))
            imgthumbnail = ''
            if imgsrc:
                imgext = re.search("(\.\w*)$", imgsrc.group(1))
                if imgext:
                    logging.error(">>admin_addpost: %s" % imgsrc.group(1)+"_thumbnail"+ imgext.group(1))
                    imgthumbnail = imgsrc.group(1)+"_thumbnail"+ imgext.group(1)
            operatorDB.update_article(request.form.get('id', ''),
                                      request.form.get('category', ''),
                                      request.form.get('title', ''),
                                      request.form.get('content', ''),
                                      _tags,request.form.get('password', ''),
                                      shorten_content(request.form.get('content', '')),
                                      imgthumbnail, _post_type,
                                      request.form.get('editor_title', '')
                                              )
            if _tags!='':
                operatorDB.add_postid_to_tags(_tags.split(','), str(post_id))
            operatorDB.add_postid_to_cat(request.form.get('category', ''),str(post_id))
            
        
        _article = operatorDB.detail_post_by_id(post_id)
        
    cats = operatorDB.get_all_cat_name()
    tags = operatorDB.get_all_tag_name()
    return render_template('admin/editpost_admin.html',obj=_article,cats=cats,tags=tags,SITE_TITLE=setting.SITE_TITLE,BASE_URL=setting.BASE_URL)