コード例 #1
0
    async def post(self):
        user_info=await self.user_info

        json = self.json_body
        type=json['type']
        id=json['id']
        #TO DO
        if type is None:
            self.finish_err()
            return
        if type == 'master':
            user = await self.db.user.get_by_id(id)
            if user is None:
                raise ResourceNotExistError("用户不存在")
            await self.db.user.insert_favor_master(str(user_info['_id']),id)
            await self.db.user.insert_favorMe(id,str(user_info['_id']))
            self.finish_success(result="OK")
        elif type == 'appointment':
            appointment = await self.db.event.get_by_id(id)
            if appointment is None:
                raise ResourceNotExistError("用户不存在")
            await self.db.user.insert_favor_team(str(user_info['_id']),id)
            await self.db.event.insert_like(id,str(user_info['_id']))
            self.finish_success(result="OK")
        elif type == 'event':
            event = await self.db.event.get_by_id(id)
            if event is None:
                raise ResourceNotExistError("用户不存在")
            await self.db.user.insert_favor_event(str(user_info['_id']),id)
            await self.db.event.insert_like(id,str(user_info['_id']))
            self.finish_success(result="OK")
        else:
            self.finish_err()
コード例 #2
0
    async def get(self):
        user_info=await self.user_info
        post_id = self.get_argument('post_id',default=None)
        post_type = self.get_argument('post_type',default=None)
        if post_type == 'post':
            post = await self.db.post.get_by_id(post_id)
        else:
            post = await self.db.event.get_by_id(post_id)

        if post is None:
            raise ResourceNotExistError("卡片/event不存在{0}".format(post_id))
        if post['state'] == 'off':
            raise ResourceNotExistError("卡片/event无效")

        ntime=self.get_timestamp()
        time=float(self.get_argument('time',default=ntime))
        if time == ntime:
            condition = {'commentTime':{'$lt':time},'postId':post_id,'state':'on',"likeUserList.5": {'$exists':1}}
            speciallist= await self.db.comment.get_comment_free(condition,'likeUserList','-',3,0)
        else:
            speciallist=[]
        pagesize=int(self.get_argument('pagesize',default=10))
        condition = {'commentTime':{'$lt':time},'postId':post_id,'state':'on'}
        andlist=[]
        for s in speciallist:
            andlist.append({'commenter':{'$ne':s['commenter']}})
        clist = await self.db.comment.get_comment_free(condition,'commentTime','-',pagesize,0)
        commentlist=speciallist+clist
        for i in range(0,len(commentlist)):
            comment=commentlist[i]
            commenter = await self.db.user.get_by_id(comment['commenter'])
            comment={
                '_id':comment['_id'],
                'commenter':{
                    'user_id':str(commenter['_id']),
                    'realName':commenter['realName'],
                    'avatar':commenter['avatar'],
                    'certificationInfo':commenter['certificationInfo']

                    },
                'postId':comment['postId'],
                'commentTime':comment['commentTime'],
                'content':comment['content'],
                'multiMedia':comment['multiMedia'],
                'replyNum':len(comment['replyList']),
                'likeNum':len(comment['likeUserList']),
                'like':str(user_info['_id']) in comment['likeUserList'],
                'replyList':comment['replyList'],
                'replyNum':len(comment['replyList']),
                'state':comment['state'],
                'isHot':comment in speciallist,
            }
            commentlist[i]=comment
        self.finish_success(result=commentlist)
        
        pass
コード例 #3
0
ファイル: post.py プロジェクト: Chao-Lu/superman
    async def post(self):
        user_info=await self.user_info
            
        jsonObj=self.json_body
        circle_id=jsonObj['post']['belongCircle']
        if 'ptype' in jsonObj.keys():
            ptype=jsonObj['ptype']
        else:
            ptype='normal'
        circle =await self.db.circle.get_by_id(circle_id)
        if circle is None or circle['state'] == 'off':
            raise ResourceNotExistError("circle 无效")
        if circle['state'] == 'news':
            if user_info['userTeam'] == '':
                raise PermissionDeniedError("无权限")
            else:
                userteam = await self.db.userteam.get_by_id(user_info['userTeam'])
                if str(user_info['_id']) not in userteam['teamMember']:
                    raise PermissionDeniedError("无权限")
        if ptype=='affiche' and not await self.is_circleManager(circle_id,str(user_info['_id'])) :
            raise PermissionDeniedError("无权限")
        if ptype == 'affiche':
            isAffiche='yes'
        else:
            isAffiche='no'
        post_src={
            'title':jsonObj['post']['title'],
            'publisher':str(user_info['_id']),
            'content':jsonObj['post']['content'],
            'multiMedia':jsonObj['post']['multiMedia'],
            'likeUserList':[],
            'commentList':[],
            'publishTime':self.get_timestamp(),
            'type':jsonObj['post']['type'],
            'state':'on',
            'pushTime':self.get_timestamp(),
            'belongCircle':circle_id,
            'belongCircleTitle':circle['title'],
            'belongCircleType':circle['type'],
            'isAffiche': isAffiche,
            'location':user_info['university'],
        }

        post_dst=self.db.base.dict_match(post_src,self.db.base.get_post_default())

        post_id= await self.db.post.insert(post_dst)
        
        if post_id is None:
            raise ResourceNotExistError("上传失败")
        await self.db.circle.insert_post(circle_id,str(post_id))
        if ptype=='affiche':
            await self.db.circle.insert_affiche(circle_id,str(post_id))
        self.finish_success(result=post_id)
        pass
コード例 #4
0
ファイル: mode.py プロジェクト: Chao-Lu/superman
    async def get(self):

        user_info = await self.user_info
        mode_id = self.get_argument('mode_id', default=None)
        mode = await self.db.mode.get_by_id(mode_id)
        if mode['type'] != 'vote':
            raise ResourceNotExistError('w')
        if mode['belongActivity'] != '':
            activity = await self.db.circle.get_by_id(mode['belongActivity'])
            activity = {
                '_id': activity['_id'],
                'title': activity['title'],
            }
        else:
            activity = {'_id': '', 'title': ''}
        voteNumMap = mode['function']['voteNumMap']
        for i in range(0, len(mode['function']['optList'])):
            mode['function']['optList'][i]['num'] = voteNumMap[
                mode['function']['optList'][i]['feature']]
        mode = {
            'beginTime': mode['beginTime'],
            'endTime': mode['endTime'],
            'title': mode['title'],
            'avatar': mode['avatar'],
            'content': mode['content'],
            'belongActivity': activity,
            'state': mode['state'],
            'type': mode['type'],
            'joinNum': mode['function']['supportNum'],
            'function': {
                'optList': mode['function']['optList'],
                'typeAB': mode['function']['typeAB'],
            }
        }
        self.finish_success(result=mode)
コード例 #5
0
 async def get(self):
     user_info = await self.user_info
     activity_id = self.get_argument('activity_id', default=None)
     activity = await self.db.circle.get_by_id(activity_id)
     sactivity = {
         'avatar':
         activity['avatar'],
         'title':
         activity['title'],
         'postNum':
         len(activity['postList']),
         'seeNum':
         activity['seeNum'],
         'circleInfo':
         activity['circleInfo'],
         'specialPostNum':
         len(activity['specialPost']),
         #'topPost':[],
         'circleManager':
         await self.is_circleManager(circle_id, str(user_info['_id'])),
         'state':
         activity['state'],
         'location':
         activity['location'],
         'type':
         activity['type'],
     }
     if activity['type'] != 'activity':
         raise ResourceNotExistError()
     await self.db.circle.insert_seenum(activity_id)
     self.finish_success(result=sactivity)
     pass
コード例 #6
0
ファイル: post.py プロジェクト: Chao-Lu/superman
    async def post(self):
        user_info=await self.user_info

        json = self.json_body
        comment= json['comment']
        comment_src={
            'commenter':str(user_info['_id']),
            'postId':json['post_id'],
            'commentTime':self.get_timestamp(),
            'content':comment['content'],
            'multiMedia':comment['multiMedia'],
            'replyList':[],
            'likeUserList':[],
            'state':'on'
        }
        post = await self.db.post.get_by_id(json['post_id'])
        if post is None:
            raise ResourceNotExistError("卡片不存在{0}")
        comment_dst=self.db.base.dict_match(comment_src,self.db.base.get_comment_default())
        comment_id = await self.db.comment.insert(comment_dst)
        
        await self.db.post.insert_comment(json['post_id'],comment_id)



        self.finish_success(result=comment_id)
コード例 #7
0
 async def post(self):
     user_info = await self.user_info
     if await self.is_supervise(str(user_info['_id'])):
         pass
     else:
         raise PermissionDeniedError("无权")
     jsonObj = self.json_body
     post_id = jsonObj['post_id']
     post = await self.db.post.get_by_id(post_id)
     if post['state'] != 'on':
         raise ResourceNotExistError("post 无效")
     postlist = await self.db.post.get_post_free(
         {
             'content': post_id,
             'state': 'ipush'
         }, '_id', '+', 100, 0)
     if len(postlist) > 0:
         self.finish_success(result='OK')
         return
     post_de = self.db.base.get_post_default()
     post_de['state'] = 'ipush'
     post_de['publisher'] = post['publisher']
     post_de['content'] = post_id
     post_de['pushTime'] = self.get_timestamp()
     post_de['isAffiche'] = 'no'
     await self.db.post.update(post_id, {'isPush': 'YES'})
     await self.db.post.insert(post_de)
     self.finish_success(result='OK')
コード例 #8
0
    async def get(self):
        user_info=await self.user_info
        mode_id=self.get_argument('mode_id',default=None)
        mode = await self.db.mode.get_by_id(mode_id)
        if mode['type'] != 'seat':
            raise ResourceNotExistError('w')
        joinMap = mode['function']['joinMap']
        if str(user_info['_id']) in joinMap.keys():
            userBehave=mode['function']['joinMap'][str(user_info['_id'])]
        else:
            await self.db.mode.update(mode_id,{'$set':{'function.joinMap.%s'%(str(user_info['_id'])):{'chooseList':[]}}})
            userBehave={}

        mode={
            'beginTime':mode['beginTime'],
            'endTime':mode['endTime'],
            'title':mode['title'],
            'avatar':mode['avatar'],
            'content':mode['content'],
            'belongActivity':mode['belongActivity'],
            'state':mode['state'],
            'type':mode['type'],
            'joinNum':len(mode['joinList']),
            'function':{
                'seatStateList':mode['function']['seatStateList'],
                'HTmap':mode['function']['HTmap'],
                'hasJoin':str(user_info['_id']) in mode['function']['userList'],
                'userBehave':userBehave,
                'state':mode['state'],
            }
        }
        self.finish_success(result=mode)
コード例 #9
0
    async def post(self):
        user_info=await self.user_info

        json = self.json_body
        comment= json['comment']
        comment_src={
            'commenter':str(user_info['_id']),
            'commentType':json['comment_type'],
            'postId':json['post_id'],
            'commentTime':self.get_timestamp(),
            'content':comment['content'],
            'star':[float(comment['star'][0]),float(comment['star'][1]),float(comment['star'][2])],
            'multiMedia':comment['multiMedia'],
            'replyList':[],
            'likeUserList':[],
            'state':'on',
            'orderId':str(json['order_id']),
        }

        event = await self.db.event.get_by_id(json['post_id'])

        if event is None:
            raise ResourceNotExistError("事件不存在{0}")
        comment_dst=self.db.base.dict_match(comment_src,self.db.base.get_comment_default())
        comment_id = await self.db.comment.insert(comment_dst)
        #将评论和订单关联
        await self.db.order.insert_comment_id(str(json['order_id']),str(comment_id))

        touser_id = ''
        await self.db.event.insert_comment(json['post_id'],comment_id)
        touser_id=event['belongedMaster']
        self.finish_success(result=comment_id)
        '''
コード例 #10
0
ファイル: appointment.py プロジェクト: Chao-Lu/superman
 async def post(self):
     user_info = await self.user_info
     master = await self.db.master.get_by_user(user_info['_id'])
     if master:
         json = self.json_body
         order_id = json['order_id']
         order = await self.db.order.get_by_id(order_id)
         if order is None:
             raise ResourceNotExistError("订单不存在")
         elif order['state'] == 'accpaid':
             #将虚拟币返转给达人
             await self.db.user.add_vcoin_number(user_info['_id'],
                                                 order['price'])
             #完成约见订单
             await self.db.order.update(order_id, {'state': 'to_meet'})
             notice = produce_notice_system_appointment(
                 'order_accept', order['trainee'],
                 {'orderId': str(order_id)})
             notice_id = await self.db.notice.insert(notice)
             trainee = await self.db.user.get_by_id(order['trainee'])
             appointment = await self.db.event.get_by_id(order['belonged'])
             await tpl_send_sigle_sms(
                 1818646, {
                     '#userName#': trainee['realName'],
                     '#masterName#': user_info['realName'],
                     '#appointment_title#': "'%s'" % appointment['title']
                 }, order['realPhone'])
         self.finish_success(result='ok')
     else:
         raise PermissionDeniedError("不是达人")
コード例 #11
0
ファイル: post.py プロジェクト: Chao-Lu/superman
    async def get(self):
        """
            @api {get} /v1.0/post 获取动态详情
            @apiGroup post
            @apiVersion  1.0.0
            @apiDescription 获取动态详情

            @apiPermission all
        
            @apiParam {string} post_id       动态id
        
            @apiSuccess    {Object}    post    动态信息
        
        """
        user_info=await self.user_info
        post_id=self.get_argument('post_id',default=None)
        post = await self.db.post.get_by_id(post_id)
        if post is None:
            raise ResourceNotExistError("卡片不存在{0}".format(post_id))
        if post['state'] == 'off':
            raise ResourceNotExistError("卡片无效")
        post=await self.post_common(post,user_info)
        await self.db.post.insert_seenum(post_id)
        if post['belongCircle']['circle_id'] == '':
            post['circle']={
                'avatar':'',
                'postNum':0,
                'seeNum':0,
            }
        else:
            circle =await self.db.circle.get_by_id(post['belongCircle']['circle_id'])
            if circle !=None:
                post['circle']={
                    'avatar':circle['avatar'],
                    'postNum':len(circle['postList']),
                    'seeNum':circle['seeNum'],
                    'type':circle['type'],
                }
            else:
                post['circle']={
                    'avatar':'',
                    'postNum':0,
                    'seeNum':0,
                }
        self.finish_success(result=post)
        pass
コード例 #12
0
    async def post(self):
        user_info = await self.user_info
        if await self.is_supervise(str(user_info['_id'])):
            pass
        else:
            raise PermissionDeniedError("无权")
        jsonObj = self.json_body
        post_id = jsonObj['post_id']
        post = await self.db.post.get_by_id(post_id)
        if post['state'] != 'on':
            raise ResourceNotExistError("post 无效")
        if post['isSpecial'] != 'no':
            raise ResourceNotExistError("post 已加精")

        await self.db.post.update(post_id, {'isSpecial': 'yes'})
        await self.db.circle.insert_special_post(post['belongCircle'], post_id)
        self.finish_success(result='OK')
コード例 #13
0
 async def post(self):
     user_info=await self.user_info
     jsonObj=self.json_body
     mode_id=jsonObj['mode_id']
     mtype=jsonObj['mtype']
     feature=jsonObj['feature']
     mode = await self.db.mode.get_by_id(mode_id)
     ntime=self.get_timestamp()
     if mode['type'] != 'vote':
         raise ResourceNotExistError('w')
     supportMap = mode['function']['supportMap']
     if mode['function']['typeAB']=='one':
         ntime=self.get_timestamp()
         if ntime > mode['beginTime'] and ntime < mode['endTime'] and str(user_info['_id']) not in mode['joinList']:
             hasVote = False
         else:
             hasVote= True
     else:
         if str(user_info['_id']) in supportMap.keys() and len(supportMap[str(user_info['_id'])]['voteList'])!=0:
             lastTime = supportMap[str(user_info['_id'])]['voteList'][-1]['time']
             ntime=self.get_timestamp()
             if ntime > mode['beginTime'] and ntime < mode['endTime'] and int(ntime/(3600*24))>int(lastTime/(3600*24)):
                 hasVote = False
             else:
                 hasVote=True
         elif str(user_info['_id']) not in supportMap.keys():
             hasVote=False
             await self.db.mode.update(mode_id,{'$set':{'function.supportMap.%s'%(str(user_info['_id'])):{'voteList':[]}}})
         else:
             hasVote=False
     if hasVote == True:
         raise ResourceNotExistError('w')
     else:
         await self.db.mode.update(mode_id,
         {
             '$inc':{
                 'function.voteNumMap.%s'%(feature):1,'function.supportNum':1,
             },
             '$addToSet':{
                 'function.supportMap.%s.voteList'%(str(user_info['_id'])):{'feature':feature,'time':ntime},
                 'joinList':str(user_info['_id'])
             }
         })
     self.finish_success(result='OK')
コード例 #14
0
ファイル: team.py プロジェクト: Chao-Lu/superman
 async def get(self):
     user_info=await self.user_info
     
     team_id    =self.get_argument('like',default=None)
     
     team = await self.db.team.get_by_id(team_id)
     if team is None:
         raise ResourceNotExistError("小组不存在{0}".format(team_id))
     self.finish_success(result=team)
     pass
コード例 #15
0
ファイル: team.py プロジェクト: Chao-Lu/superman
 async def post(self):
     user_info=await self.user_info
     json=self.json_body
     team_id=json['team_id']
     team = await self.db.team.get_by_id(team_id)
     if team is None:
         raise ResourceNotExistError("小组不存在{0}".format(team_id))
     await self.db.user.insert_favor_team((str)user_info['_id'],team_id)
     await self.db.team.insert_member(team_id,(str)user_info['_id'])
     self.finish_success(result='OK')
コード例 #16
0
 async def get(self):
     category_id = self.get_argument("category_id")
     privilege = await self.privilege
     result = await self.db.category.get_category(category_id, privilege)
     question_count = await self.db.question.get_question_count(category_id)
     if result is not None:
         result['question_count'] = question_count
     else:
         raise ResourceNotExistError('没有对应id的目录')
     self.finish_success(result=result)
コード例 #17
0
 async def post(self):
     user_info=await self.user_info
     jsonObj=self.json_body
     mode_id=jsonObj['mode_id']
     mtype=jsonObj['mtype']
     seatNumber=int(jsonObj['seatNumber'])
     mode = await self.db.mode.get_by_id(mode_id)
     if mode['type'] != 'seat':
         raise ResourceNotExistError('w')
     ntime=self.get_timestamp()
     if mode['endTime']<ntime or mode['beginTime']>ntime:
         raise ResourceNotExistError('')
     if str(user_info['_id']) in mode['function']['userList']:
         raise ResourceNotExistError('')
     
     
     joinMap = mode['function']['joinMap']
     if str(user_info['_id']) not in joinMap.keys():
         await self.db.mode.update(mode_id,{'$set':{'function.joinMap.%s'%(str(user_info['_id'])):{'chooseList':[]}}}) 
         
         
     if mtype =='select':
         await self.db.mode.updateS(
         {'_id':ObjectId(mode_id),'function.userList':{'$ne':str(user_info['_id'])},'function.seatStateList.%d'%(seatNumber):0},
         {'$addToSet':{'joinList':str(user_info['_id']),'function.userList':str(user_info['_id']),'function.joinMap.%s.chooseList'%(str(user_info['_id'])):{'seatNumber':seatNumber,'type':mtype,'time':ntime}},'$set':{'function.seatStateList.%d'%(seatNumber):1,'function.seatUserList.%d'%(seatNumber):str(user_info['_id'])}}
         )
         mode = await self.db.mode.get_by_id(mode_id)
         if mode['function']['seatUserList'][seatNumber] == str(user_info['_id']):
             re="OK"
         else:
             re='NO'
     elif mtype =='reselect':
         await self.db.mode.updateS(
         {'_id':ObjectId(mode_id),'function.seatStateList.%d'%(seatNumber):1,'function.seatUserList.%d'%(seatNumber):str(user_info['_id'])},
         {'$addToSet':{'joinList':str(user_info['_id']),'function.joinMap.%s.chooseList'%(str(user_info['_id'])):{'seatNumber':seatNumber,'type':mtype,'time':ntime}},'$pull':{'function.userList':str(user_info['_id'])},'$set':{'function.seatStateList.%d'%(seatNumber):0,'function.seatUserList.%d'%(seatNumber):''}}
         )
         mode = await self.db.mode.get_by_id(mode_id)
         if mode['function']['seatUserList'][seatNumber] == str(user_info['_id']):
             re="NO"
         else:
             re='OK'
     self.finish_success(result=re)
コード例 #18
0
 async def delete(self):
     user_info = await self.user_info
     json = self.json_body
     order_id = json['order_id']
     order = await self.db.order.get_by_id(order_id)
     if order is None:
         raise ResourceNotExistError("订单不存在")
     if order['state'] != 'nonpay':
         raise StateError("该订单不可取消")
     await self.db.order.update(jsonObj['order_id'], {'state': 'off'})
     self.finish_success(result='OK')
     pass
コード例 #19
0
ファイル: team.py プロジェクト: Chao-Lu/superman
 async def delete(self):
     user_info=await self.user_info
     json=self.json_body
     card_id=json['card_id']
     card = await self.db.card.get_by_id(card_id)
     if card is None:
         raise ResourceNotExistError("卡片不存在{0}".format(card_id))
     team_id = card['belongTeam']
     team = await self.db.team.get_by_id(team_id)
     if team is None:
         raise RelateResError("小组不存在")
     if (str)user_info['_id'] not in team['leaderlist']:
         raise PermissionDeniedError("需要有本小组的管理员权限")
コード例 #20
0
ファイル: mode.py プロジェクト: Chao-Lu/superman
    async def post(self):
        user_info = await self.user_info
        mode = self.json_body['mode']
        beginTime = time.mktime(
            time.strptime(mode['beginTime'], '%Y-%m-%d %H:%M:%S'))
        endTime = time.mktime(
            time.strptime(mode['endTime'], '%Y-%m-%d %H:%M:%S'))
        content = mode['content']
        optList = mode['optList']
        typeAB = mode['typeAB']
        title = mode['title']
        avatar = mode['avatar']
        activity_id = mode['activity_id']
        voteNumMap = {}
        if (activity_id != ""):
            activity = await self.db.circle.get_by_id(activity_id)
            if (activity is None or activity['type'] != 'activity'):
                raise ResourceNotExistError("")

        for i in range(0, len(optList)):
            optList[i] = {
                'content': optList[i],
                'feature': self.produce_order_number(),
                'state': 'on'
            }
            voteNumMap[optList[i]['feature']] = 0
        mode_default = self.db.base.get_mode_default('vote')

        mode_default = {
            'beginTime': beginTime,
            'endTime': endTime,
            'title': title,
            'avatar': avatar,
            'content': content,
            'state': 'on',
            'type': 'vote',
            'joinList': [],
            'entryDate': self.get_timestamp(),
            'belongActivity': activity_id,
            'function': {
                'optList': optList,
                'supportMap': {},
                'typeAB': typeAB,
                'supportNum': 0,
                'voteNumMap': voteNumMap,
            }
        }
        mode_id = await self.db.mode.insert(mode_default)
        if (activity_id != ""):
            await self.db.circle.insert_mode(activity_id, str(mode_id))
        self.finish_success(result=mode_id)
コード例 #21
0
 async def put(self):
     user_info = await self.user_info
     json = self.json_body
     master = await self.db.master.get_by_user(user_info['_id'])
     if master:
         order_id = json['order_id']
         order = await self.db.order.get_by_id(order_id)
         if order is None:
             raise ResourceNotExistError("订单不存在")
         elif order['state'] == 'to_meet':
             await self.db.order.update(order_id, {'state': 'to_evaluate'})
         self.finish_success(result='ok')
     else:
         raise PermissionDeniedError("不是达人")
コード例 #22
0
 async def post(self):
     user_info=await self.user_info
     jsonObj = self.json_body
     comment_id= jsonObj['comment_id']
     comment = await self.db.comment.get_by_id(comment_id)
     if comment is None:
         raise ResourceNotExistError("评论不存在{0}".format(comment_id))      
     if str(user_info['_id']) in comment['likeUserList']:
         await self.db.comment.remove_like(comment_id,str(user_info['_id']))
         comment = await self.db.comment.get_by_id(comment_id)
         self.finish_success(result={'state':'unlike','likeNum':len(comment['likeUserList'])})
     else:
         await self.db.comment.insert_like(comment_id,str(user_info['_id']))
         self.finish_success(result={'state':'like','likeNum':len(comment['likeUserList'])})
コード例 #23
0
    async def delete(self):
        user_info = await self.user_info
        if await self.is_supervise(str(user_info['_id'])):
            pass
        else:
            raise PermissionDeniedError("无权")
        jsonObj = self.json_body
        post_id = jsonObj['post_id']
        post = await self.db.post.get_by_id(post_id)
        if post['state'] != 'on':
            raise ResourceNotExistError("post 无效")

        await self.db.circle.remove_top_post(post['belongCircle'], post_id)
        self.finish_success(result='OK')
        pass
コード例 #24
0
 async def get(self):
     user_info=await self.user_info
     mode_id=self.get_argument('mode_id',default=None)
     mode = await self.db.mode.get_by_id(mode_id)
     if mode['type'] != 'vote':
         raise ResourceNotExistError('w')
     supportMap = mode['function']['supportMap']
     if mode['function']['typeAB']=='one':
         ntime=self.get_timestamp()
         if ntime > mode['beginTime'] and ntime < mode['endTime'] and str(user_info['_id']) not in mode['joinList']:
             hasVote = False
         else:
             hasVote= True
     else:
         if str(user_info['_id']) in supportMap.keys() and len(supportMap[str(user_info['_id'])]['voteList'])!=0:
             lastTime = supportMap[str(user_info['_id'])]['voteList'][-1]['time']
             ntime=self.get_timestamp()
             if ntime > mode['beginTime'] and ntime < mode['endTime'] and int(ntime/(3600*24))>int(lastTime/(3600*24)):
                 hasVote = False
             else:
                 hasVote=True
         elif str(user_info['_id']) not in supportMap.keys():
             hasVote=False
             await self.db.mode.update(mode_id,{'$set':{'function.supportMap.%s'%(str(user_info['_id'])):{'voteList':[]}}})
         else:
             hasVote=False
             
     voteNumMap = mode['function']['voteNumMap']
     for i in range(0,len(mode['function']['optList'])):
         mode['function']['optList'][i]['num']=voteNumMap[mode['function']['optList'][i]['feature']]
     mode={
         'beginTime':mode['beginTime'],
         'endTime':mode['endTime'],
         'title':mode['title'],
         'avatar':mode['avatar'],
         'content':mode['content'],
         'belongActivity':mode['belongActivity'],
         'state':mode['state'],
         'type':mode['type'],
         'joinNum':mode['function']['supportNum'],
         'function':{
             'optList':mode['function']['optList'],
             'hasVote':hasVote,
             'typeAB':mode['function']['typeAB'],
         }
     }
     self.finish_success(result=mode)
コード例 #25
0
ファイル: post.py プロジェクト: Chao-Lu/superman
    async def delete(self):
        user_info=await self.user_info

        json = self.json_body
        comment_id= json['comment_id']
        comment = await self.db.comment.get_by_id(comment_id)
        if comment is None:
            raise ResourceNotExistError("评论不存在{0}".format(comment_id))
        if comment['commenter'] == str(user_info['_id']):
            pass
        elif await self.is_supervise(str(user_info['_id'])):
            pass
        else:
            raise PermissionDeniedError("无权删除本条评论")
        await self.db.post.remove_comment(comment['postId'],comment_id)
        await self.db.comment.update(comment_id,{'state':'off'})
        self.finish_success(result='OK')
コード例 #26
0
 async def post(self):
     user_info = await self.user_info
     master = await self.db.master.get_by_user(user_info['_id'])
     if master:
         json = self.json_body
         order_id = json['order_id']
         order = await self.db.order.get_by_id(order_id)
         if order is None:
             raise ResourceNotExistError("订单不存在")
         elif order['state'] == 'accpaid':
             #给达人记录现金收益
             await self.db.master.add_money_by_user_id(
                 user_info['_id'], order['price'])
             #完成约见订单
             await self.db.order.update(order_id, {'state': 'to_meet'})
         self.finish_success(result='ok')
     else:
         raise PermissionDeniedError("不是达人")
コード例 #27
0
 async def get(self, operator):
     if operator == '/question':
         code = self.get_argument("code")
         question = (
             await
             self.db.classroom_question.get_a_question_by_code(code))[0]
         question.pop('answer')
         # 删除问题的答案
         self.finish_success(result=question)
     elif operator == '/all_my_answers':
         page = self.get_argument("page")
         pagesize = self.get_argument("pagesize")
         student_id = await self.user_id
         result, count = await self.db.classroom_answer.get_answers_of_a_student(
             student_id, pagesize, page)
         self.finish_success(result={'answers': result, 'count': count})
     else:
         raise ResourceNotExistError("操作不存在")
コード例 #28
0
ファイル: appointment.py プロジェクト: Chao-Lu/superman
 async def put(self):
     user_info = await self.user_info
     json = self.json_body
     master = await self.db.master.get_by_user(user_info['_id'])
     if master:
         order_id = json['order_id']
         order = await self.db.order.get_by_id(order_id)
         if order is None:
             raise ResourceNotExistError("订单不存在")
         elif order['state'] == 'to_meet':
             await self.db.order.update(order_id, {'state': 'to_evaluate'})
             notice = produce_notice_system_appointment(
                 'order_finish', order['trainee'],
                 {'orderId': str(order_id)})
             notice_id = await self.db.notice.insert(notice)
         self.finish_success(result='ok')
     else:
         raise PermissionDeniedError("不是达人")
コード例 #29
0
ファイル: appointment.py プロジェクト: Chao-Lu/superman
 async def delete(self):
     user_info = await self.user_info
     json = self.json_body
     master = await self.db.master.get_by_user(user_info['_id'])
     if master:
         order_id = json['order_id']
         order = await self.db.order.get_by_id(order_id)
         if order is None:
             raise ResourceNotExistError("订单不存在")
         elif order['state'] == 'accpaid':
             #将虚拟币返回给用户
             await self.db.user.add_vcoin_number(order['trainee'],
                                                 order['price'])
             #关闭约见订单
             await self.db.order.update(order_id, {'state': 'off'})
         self.finish_success(result='ok')
     else:
         raise PermissionDeniedError("不是达人")
コード例 #30
0
    async def delete(self):
        user_info=await self.user_info

        json = self.json_body
        comment_id= json['comment_id']
        reply = json['reply']
        if reply['replyerId'] == str(user_info['_id']):
            pass
        elif  await self.is_supervise(str(user_info['_id'])):
            pass
        else:
            raise PermissionDeniedError("无权删除本条回复")
            
        comment = await self.db.comment.get_by_id(comment_id)
        if comment is None:
            raise ResourceNotExistError("评论不存在{0}".format(comment_id))
        await self.db.comment.remove_reply(comment_id,reply)
        self.finish_success(result='OK')