Example #1
0
 def reply(self, user_id, c_type, content, img_uri, audio_uri, task_id, pwd):
     """回复"""
     self.check_content(c_type, content, img_uri, audio_uri)
     task = self.get_db_task(task_id, pwd)
     if datetime.now() > task.ddl:
         raise ext.ParamError(u'任务已过期')
     # if user_id == task.user_id:
     #     raise ext.OtherError(u'本人不能操作')
     if task.type != Task.TYPE_REPLY:
         raise ext.OtherError(U'不允许接龙')
     r = Reply.query.filter(Reply.user_id == user_id, Reply.task_id == task_id,
                            Reply.status == Reply.STATUS_ON).first()
     if r:
         raise ext.OtherError(u'您已经接龙了')
     user_cache = user_mgr.get_cache(user_id)
     r = Reply(
         user_id=user_id,
         c_type=c_type,
         content=content,
         img_uri=img_uri,
         audio_uri=audio_uri,
         task_id=task_id,
         img_url=user_cache['img_url'],
         nickname=user_cache['nickname']
     )
     db.session.add(r)
     utils.commit_db(db, e_log, u'【回复】user_id:%s' % user_id)
     return dict()
Example #2
0
 def add_task(self, user_id, type_, title, c_type, content, img_uri, audio_uri, ddl):
     """发布任务"""
     self.check_content(c_type, content, img_uri, audio_uri)
     user_info = user_mgr.get_cache(user_id)
     task = self.init_task(user_id, type_, title, c_type, content, img_uri, audio_uri, user_info, ddl)
     tls = self.add_task_list(task, user_id)
     utils.commit_db(db, e_log, u'【发布任务】user_id:%s' % user_id)
     return dict(task_id=task.id, pwd=task.pwd)
Example #3
0
 def add_attend(self, user_id, to_id):
     """关注"""
     cache = user_mgr.get_cache(to_id)
     if self.is_attend_exist(user_id, to_id):
         raise ext.OtherError(U'您已关注TA')
     a = Attend(from_id=user_id, to_id=to_id)
     db.session.add(a)
     utils.commit_db(db, e_log, u'【关注】user_id:%s' % user_id)
     return dict()
Example #4
0
 def add_form_id(self, user_id, form_id):
     """新增form_id"""
     if len(form_id) < 1:
         return
     cache = user_mgr.get_cache(user_id)
     ddl = datetime.now() + timedelta(days=7)
     form_id = FormId(user_id=user_id,
                      openid=cache['wxa_openid'],
                      ddl=ddl,
                      form_id=form_id)
     db.session.add(form_id)
     utils.commit_db(db, self.e_log, u'【新增form_id】入库失败')
Example #5
0
 def read(self, user_id, task_id, pwd):
     """已读"""
     task = self.get_db_task(task_id, pwd)
     if user_id == task.user_id:
         return dict()
         raise ext.OtherError(u'本人不能已读')
     user_info = user_mgr.get_cache(user_id)
     r = Read.query.filter(Read.user_id == user_id, Read.task_id == task_id).first()
     if r:
         return dict()
     r = Read(user_id=user_id, task_id=task_id, img_url=user_info['img_url'], nickname=user_info['nickname'])
     db.session.add(r)
     utils.commit_db(db, e_log, u'【已读】user_id:%s' % user_id)
     return dict(read_suc=1)