示例#1
0
文件: helper.py 项目: MSchumi/test
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
示例#2
0
文件: helper.py 项目: MSchumi/test
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
示例#3
0
文件: helper.py 项目: MSchumi/test
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
示例#4
0
文件: helper.py 项目: MSchumi/test
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
示例#5
0
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
示例#6
0
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
示例#7
0
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