def submit_question(obj,user,**kwargs): """ 发布问题后向好友分发,同事插入solr """ try: task_id=insert_activity.delay(0,obj.id,user.id) task_id=insert_solr.delay('question',id=obj.id,title=remove_htmltag(obj.title),user_id=user.id) return task_id except Exception,e: print e
def follow_question(instance,user,optype,**kwarg): """关注问题后向好友分发 """ try: if optype=="delete": task_id=delete_activity.delay(2,instance,user.id) else: task_id=insert_activity.delay(2,instance.id,user.id) return task_id except Exception,e: print e
def submit_vote(instance,user,optype,**kwarg): """ 评价回答后向好友分发""" try: if optype=="delete": task_id=delete_activity.delay(3,instance,user.id) else: task_id=insert_activity.delay(3,instance.id,user.id) return task_id except Exception,e: print e
def submit_answer(obj,user,**kwarg): """ 回答问题后向好友分发,同事插入solr """ try: task_id=insert_activity.delay(1,obj.id,user.id) #import pdb;pdb.set_trace() #task_id=insert_solr.delay('answer',{'id':obj.id,'content':obj.content,'question_id':obj.question_id,'user_id':obj.user_id}) #task_id=insert_solr.delay('answer',obj.id,obj.content,obj.question_id,obj.user_id) task_id=insert_solr.delay('answer',id=obj.id,content=remove_htmltag(obj.content),question_id=obj.question_id,\ user_id=obj.user_id) return task_id except Exception,e: print e
def follow_question(instance,user,optype,**kwarg): """关注问题后向好友分发 """ try: if optype=="delete": task_id=delete_activity.delay(2,instance,user.id) else: question=instance.question content_dict={"question_id":question.id,"question_title":question.title,"user_id":user.id,"user_name":user.surname+user.name} task_id=insert_message.delay(1,instance.question.id,user.id,question.user.id,content_dict) task_id=insert_activity.delay(2,instanc.question.id,user.id) return task_id except Exception,e: print e
def submit_vote(instance,user,optype,**kwarg): """ 评价回答后向好友分发""" try: if optype=="delete": task_id=delete_activity.delay(3,instance,user.id) else: answer=instance.answer content_dict={"answer_id":answer.id,"answer_content":answer.content,"user_id":user.id,"user_name":user.surname+user.name,"status":\ instance.status,"question_id":answer.question.id} task_id=insert_message.delay(3,instance.id,user.id,instance.answer.user.id,content_dict) task_id=insert_activity.delay(3,instance.id,user.id) return task_id except Exception,e: print e
def submit_answer(obj,user,**kwarg): """ 回答问题后向好友分发,同时插入solr """ try: question=kwarg.get("question") content_dict={"question_id":question.id,"question_title":question.title,"question_user_id":question.user.id,"user_id":user.id,\ "user_name":user.surname+user.name} task_id=insert_message(1,obj.id,user.id,None,content_dict) task_id=insert_activity.delay(1,obj.id,user.id) #import pdb;pdb.set_trace() #task_id=insert_solr.delay('answer',{'id':obj.id,'content':obj.content,'question_id':obj.question_id,'user_id':obj.user_id}) #task_id=insert_solr.delay('answer',obj.id,obj.content,obj.question_id,obj.user_id) task_id=insert_solr.delay('answer',id=obj.id,content=remove_htmltag(obj.content),question_id=obj.question_id,\ user_id=obj.user_id) return task_id except Exception,e: print e