Exemplo n.º 1
0
def fun_get_comment_by_position(article_id=None,
                                pos=0,
                                article_type="blog",
                                page_cap=10,
                                load_one='no',
                                load_before='no',
                                before_pos=0):
    ''' get comment by position, return [1|0, 'info', first_post, last_pos, len] '''
    ''' info contains a dict{ 'comment':{'0': comment(0) }, 'ref_commet':{'1':comment(0) } } '''
    try:
        if article_type == "blog":
            AF_Object = Blog(_id=article_id)
        elif article_type == "group-topic":
            AF_Object = Topic(_id=article_id)
        elif article_type == 'group-notice':
            AF_Object = Bulletin(_id=article_id)
        elif article_type == 'group-feedback':
            AF_Object = Feedback(_id=article_id)
        elif article_type == "group-doc":
            AF_Object = Blog(_id=article_id)
        else:
            return [1, '不支持当前类型!']
    except Exception, e:
        logging.error(traceback.format_exc())
        logging.error('%s not exist, id %s' % (article_type, article_id))
        return [1, '文章不存在!']
Exemplo n.º 2
0
def fun_get_notice_list(group=None, page=1, page_cap=10):
    pass
    notice_list = group.bulletin_board.load_all()
    notice_list.reverse()
    min_index, max_index = get_index_list_by_page(notice_list,
                                                  page=page,
                                                  page_cap=page_cap)

    #print min_index, max_index
    notice_list_instance = Bulletin.get_instances(
        '_id', notice_list[min_index:max_index])
    #print 'notice_list', notice_list
    #print 'notice list instance ', notice_list_instance
    res_list = []
    for item in notice_list_instance:
        res_list.append({
            'notice_id': str(item._id),
            'notice_title': item.name,
            'notice_author_id': str(item.author_id),
            'notice_author_name': item.author_name
        })

    #print 'notice result ', res_list
    res_list.reverse()
    return res_list, len(notice_list), page
Exemplo n.º 3
0
def fun_get_notice_list(group=None, page=1, page_cap=10):
    pass
    notice_list = group.bulletin_board.load_all()
    notice_list.reverse()
    min_index, max_index = get_index_list_by_page(notice_list, page=page, page_cap=page_cap)
    
    #print min_index, max_index
    notice_list_instance = Bulletin.get_instances('_id', notice_list[min_index:max_index])
    #print 'notice_list', notice_list 
    #print 'notice list instance ', notice_list_instance
    res_list = []
    for item in notice_list_instance:
        res_list.append({'notice_id': str(item._id), 'notice_title': item.name, 
            'notice_author_id': str(item.author_id), 'notice_author_name': item.author_name})
    
    #print 'notice result ', res_list 
    res_list.reverse()
    return res_list, len(notice_list), page    
Exemplo n.º 4
0
                    father_id='-1',
                    father_type='blog',
                    do="post",
                    ref_comments=''):
 # update comment, all comments
 group = None
 if father_type == 'blog':
     try:
         AF_Object = Blog(_id=father_id)
     except Exception, e:
         return [1, '文章不存在!']
 else:
     # for group
     if father_type == 'group-notice':
         try:
             AF_Object = Bulletin(_id=father_id)
             group = BasicGroup(_id=AF_Object.group_id)
             if group.get_member_type(user) is None:
                 return [1, '您不是该小组成员']
         except Exception, e:
             logging.error(traceback.format_exc())
             logging.error('%s not exist, id %s' % (father_type, father_id))
             return [1, '该公告不存在!']
     elif father_type == "group-doc":
         try:
             AF_Object = Blog(_id=father_id)
             group = BasicGroup(_id=AF_Object.group_id)
             if group.get_member_type(user) is None:
                 return [1, '您不是该小组成员']
         except Exception, e:
             logging.error(traceback.format_exc())
Exemplo n.º 5
0

def fun_update_comment(user, 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=''):
    # update comment, all comments 
    group = None
    if father_type == 'blog':
        try:
            AF_Object = Blog(_id=father_id)
        except Exception, e:
            return [1, '文章不存在!']
    else:
        # for group 
        if father_type == 'group-notice':
            try:
                AF_Object = Bulletin(_id=father_id)
                group = BasicGroup(_id=AF_Object.group_id)
                if group.get_member_type(user) is None:
                    return [1, '您不是该小组成员']
            except Exception, e:
                logging.error(traceback.format_exc())
                logging.error('%s not exist, id %s' %(father_type, father_id))
                return [1, '该公告不存在!']
        elif father_type == "group-doc":
            try:
                AF_Object = Blog(_id=father_id)
                group = BasicGroup(_id=AF_Object.group_id)
                if group.get_member_type(user) is None:
                    return [1, '您不是该小组成员']
            except Exception, e:
                logging.error(traceback.format_exc())