def fun_update_article(user, group=None, group_id='-1', article_id=0, article_type='blog', title='', summary='', body='', permission='public', keys=[], classes=[], father_id='-1', father_type='blog', do="post", ref_comments='', isedit='false'): if keys != []: keys = keys_to_list(keys) if article_type == "blog": # write blog start try: AF_Object = Blog(_id=article_id) if str(AF_Object.author_id) != str(user._id): return [1, '无权限操作他人的文章!'] except Exception, e: AF_Object = Blog() AF_Object.author = user AF_Object.env = user article_id = AF_Object._id (user.drafts_lib).add_obj(AF_Object) return fun_update_blog(user=user, blog=AF_Object, title=title, summary=summary, body=body, keys=keys, permission=permission, classes=classes, do=do)
def fun_update_article(user, group=None, group_id='-1', article_id = 0, article_type='blog', title='', summary='', body='', permission='public', keys=[], classes=[], father_id='-1', father_type='blog', do="post", ref_comments='', isedit='false'): if keys != []: keys = keys_to_list(keys) if article_type == "blog": # write blog start try: AF_Object = Blog(_id=article_id) if str(AF_Object.author_id) != str(user._id): return [1, '无权限操作他人的文章!'] except Exception, e: AF_Object = Blog() AF_Object.author = user AF_Object.env = user article_id = AF_Object._id (user.drafts_lib).add_obj(AF_Object) return fun_update_blog(user=user, blog=AF_Object, title=title, summary=summary, body=body, keys=keys, permission=permission, classes=classes, do=do)
if test_auth(limit, A_WRITE) is False: return [1, '您无权修改摘要!'] except Exception, err: logging.error(traceback.format_exc()) logging.error('Catalog not exist, id %s' % group_id) return [1, '未找到知识谱!'] elif article_type == "blog": try: AF_Object = Blog(_id=article_id) isnew = False except Exception, e: logging.error(traceback.format_exc()) logging.error('%s not exist, id %s' % (article_type, article_id)) AF_Object = Blog() AF_Object.author = user AF_Object.env = user article_id = str(AF_Object._id) isnew = True (user.drafts_lib).add_obj(AF_Object) elif article_type == "comment": return [1, '完善中'] elif article_type in Group_Article: # for group isnew = False try: group = BasicGroup(_id=group_id) limit = group.authority_verify(user) except Exception, e: logging.error(traceback.format_exc()) logging.error('Group not exist, id %s' % group_id) return [1, '参数错误,小组不存在!']