def post_recommand_job(request): user_id = request.user_id audio_for_zg = html.escape(request.POST.get('audio_for_zg', '')) + "," + request.POST.get( 'audio_for_zg_length', '') audio_for_qlm = html.escape( request.POST.get('audio_for_qlm', '')) + "," + request.POST.get( 'audio_for_qlm_length', '') if user_id == 0: return HttpResponse("十分抱歉,参数错误,请联系客服人员") job_uuid = request.GET.get('job_uuid', '') last_share_uuid = request.GET.get('last_share_uuid', '00000000000000000000000000000000') job_details = Job.objects.filter(uuid=job_uuid)[:1] if job_details: my_recommend = MyRecommend(uuid=str_tools.gen_uuid(), user_id=user_id, job_id=job_details[0].id, audio_for_zg=audio_for_zg, audio_for_qlm=audio_for_qlm, last_share_uuid=last_share_uuid) my_recommend.save() merge_msg = MergeMsg(update_time=datetime.datetime.now(), uuid=str_tools.gen_uuid(), bl_user_id=user_id, zg_user_id=job_details[0].user_id, recommend_id=my_recommend.id, zg_have_read=False, last_words="给您推荐了千里马!快听听吧!") merge_msg.save() my_recommend_merge = MyRecommendMerg.objects.filter( user_id=user_id, job_id=job_details[0].id) if my_recommend_merge: my_recommend_merge[ 0].recommend_num = my_recommend_merge[0].recommend_num + 1 my_recommend_merge[0].save() else: my_recommend_merge = MyRecommendMerg(user_id=user_id, job_id=job_details[0].id, recommend_num=1) my_recommend_merge.save() else: log.error("uid(%s) try to get not exsit job(%s), maybe attack" % (user_id, job_uuid)) return HttpResponse("十分抱歉,获取职位信息失败,请重试。重试失败请联系客服人员") return HttpResponseRedirect( "/job/post_recommand_job_success?last_share_uuid=" + last_share_uuid + "&recommend_uuid=" + str(my_recommend.uuid) + "&post_success=1&share_to_zg=0")
def fetch_user_info_callback(openid, userinfo): exist = Bind.objects.filter(wx_openid=openid) if not exist: logging.info("new user. openid: %s userinfo: %s" % (openid, userinfo)) sex = 'O' if 'sex' in userinfo: if userinfo['sex'] == 1: sex = 'M' else: sex = 'F' profile = Profile(uuid=gen_uuid(), nick=userinfo['nickname'], sex=sex, portrait=userinfo['headimgurl'], real_name='', company_name='', title='', vip='1', desc='', nation=userinfo['country'], province=userinfo['province'], city=userinfo['city'], district='') profile.save() bind = Bind(user_id=profile.id, phone_number='', phone_number_verify_time='1972-01-01', wx_openid=openid, wx_openid_verify_time=datetime.datetime.now(), qq_openid='', qq_openid_verify_time='1972-01-01', weibo_openid='', weibo_openid_verify_time='1972-01-01', email='', email_verify_time='1972-01-01') bind.save() profileext = ProfileExt(user_id=profile.id, education='', blood_type='', birthday='1972-01-01', certificate_no='') profileext.save() else: logging.debug('exist userinfo: %s' % openid)
def interest_job(request): user_id = request.user_id # 1.从vip职位列表那里直接点击感兴趣进来传进来-------job_uuid->job # 2.通过别人分享链接(分享的职位详情)进来------------share_uuid获取job_id->job # 3.通过别人分享链接(分享的带推荐录音的职位详情)进来 share_uuid获取recommend_id->job recommend_uuid = request.GET.get('recommend_uuid', '') last_share_uuid = request.GET.get('last_share_uuid', '') job_uuid = request.GET.get('job_uuid', '') job_details = [] if last_share_uuid: # 通过别人的分享链接进来的1.职位详情2.带录音的职位详情,只要有share_uuid就可以拿到job if recommend_uuid: # 传recommend_uuid,为带录音的职位详情 recommends = MyRecommend.objects.filter(uuid=recommend_uuid)[:1] if not recommends: return HttpResponse("十分抱歉,获取推荐信息失败,请重试。重试失败请联系客服人员") job_details = Job.objects.filter(id=recommends[0].job_id)[:1] elif job_uuid: job_details = Job.objects.filter(uuid=job_uuid)[:1] if not job_details: log.error("uid(%s) try to get not exsit job, maybe attack" % user_id) return HttpResponse("十分抱歉,获取职位信息失败,请重试。重试失败请联系客服人员") elif job_uuid: # 说明直接点我感兴趣进来的,没有通过分享 job_details = Job.objects.filter(uuid=job_uuid)[:1] last_share_uuid = "00000000000000000000000000000000" if not job_details: log.error("uid(%s) try to get not exsit job(%s), maybe attack" % (user_id, job_uuid)) return HttpResponse("十分抱歉,获取职位信息失败,请重试。重试失败请联系客服人员") be_interested = BeInterested.objects.filter(job_id=job_details[0].id, qlm_user_id=user_id)[:1] if not be_interested: # 当前user以前没有对这个职位点击过我感兴趣,则插入数据 be_interested = BeInterested(last_share_uuid=last_share_uuid, job_id=job_details[0].id, qlm_user_id=user_id, uuid=str_tools.gen_uuid()) be_interested.save() conversation = Conversation( be_interested_id=be_interested.id, user_id=user_id, words="主公,我揭了您的“招贤令”!<span style='color:#8e8e8e;'>(系统代发消息)</span>") conversation.save() conversation = Conversation( create_time=datetime.datetime.fromtimestamp(time.time() + 2), be_interested_id=be_interested.id, user_id=job_details[0].user_id, words= "管家!快给英雄赐座。容我先批完折子。<span style='color:#8e8e8e;'>(系统代发消息)</span>") conversation.save() merge_msg = MergeMsg( update_time=datetime.datetime.now(), uuid=str_tools.gen_uuid(), zg_user_id=job_details[0].user_id, be_interested_id=be_interested.id, qlm_user_id=user_id, last_words= "管家!快给英雄赐座。容我先批完折子。<span style='color:#8e8e8e;'>(系统代发消息)</span>", qlm_have_read=True, zg_have_read=False) merge_msg.save() # 更新my_interview表 my_interview = MyInterview(user_id=user_id, job_id=job_details[0].id, last_share_uuid=last_share_uuid) my_interview.save() else: be_interested = be_interested[0] be_interested_uuid = be_interested.uuid return HttpResponseRedirect("/chat/chat_detail?be_interested_uuid=" + str(be_interested_uuid))
def post_job(request): user_id = request.user_id profile = user_tools.get_user_profile_by_user_id(user_id=user_id, need_default=False) if not profile: log.error('Cant find user profile by user_id: %s when post_job' % user_id) return HttpResponse("十分抱歉,获取用户信息失败,请重试。重试失败请联系客服人员") company_name = html.escape(request.POST.get('company_name'))[:30] job_title = html.escape(request.POST.get('job_title'))[:30] work_experience = html.escape(request.POST.get('work_experience'))[:10] salary = html.escape(request.POST.get('salary'))[:10] education = html.escape(request.POST.get('education'))[:10] job_addr = html.escape(request.POST.get('job_addr')).split(' ') if len(job_addr) < 2: return HttpResponse("地理位置参数错误") province = job_addr[0][:20] city = job_addr[1][:20] district = '' if len(job_addr) == 3: # 防止有些地方没有区,数组越界异常 district = job_addr[2][:20] if not (company_name and job_title and work_experience and salary and education and job_addr and province and city): return HttpResponse("十分抱歉,你输入的参数缺失,请检查确认后重试。重试失败请联系客服人员") skills = "" for i in range(1, 7): skill = html.escape(request.POST.get('skill%s' % i)) if skill != "": skills += skill + "," skills = skills[:-1][:120] piclist = '' for i in range(1, 7): picname = html.escape(request.POST.get('img_url%s' % i)) if picname: if piclist: piclist = '%s,%s' % (piclist, picname) else: piclist = picname piclist = piclist[:256] job_uuid = request.POST.get('job_uuid', '') if job_uuid: # 有job_uuid, 更新职位信息 job_details = Job.objects.filter(uuid=job_uuid)[:1] if job_details: job_id = job_details[0].id job = Job(id=job_id, uuid=job_uuid, user_id=user_id, company_name=company_name, job_title=job_title, work_experience=work_experience, salary=salary, education=education, province=province, city=city, district=district, skill=skills, piclist=piclist, create_time=job_details[0].create_time) else: log.error("uid(%s) try to get not exsit job(%s), maybe attack" % (user_id, job_uuid)) return HttpResponse("十分抱歉,获取职位信息失败,请重试。重试失败请联系客服人员") else: # 插入一条新的职位 job = Job(uuid=str_tools.gen_uuid(), user_id=user_id, company_name=company_name, job_title=job_title, work_experience=work_experience, salary=salary, education=education, province=province, city=city, district=district, skill=skills, piclist=piclist) profile.pub_valid_job_cnt += 1 profile.save() job.save() try: if profile.vip: vip_job = VipJobList(job_id=job.id, user_id=user_id, pub_time=datetime.datetime.now()) vip_job.save() except Exception, e: log.error("VipJobList Exception: %s" % e)
def post_job(request): user_id = get_userid_by_openid(request.openid) if not user_id: logging.error('Cant find user_id by openid: %s when post_job' % request.openid) return HttpResponse("十分抱歉,获取用户信息失败,请重试。重试失败请联系客服人员") company_name = request.POST.get('company_name') job_title = request.POST.get('job_title') work_experience = request.POST.get('work_experience') salary = request.POST.get('salary') education = request.POST.get('education') addrs = request.POST.get('city').split(' ') province = addrs[0] city = addrs[1] district = '' if len(addrs) == 3: # 防止有些地方没有区,数组越界异常 district = addrs[2] if not (company_name and job_title and work_experience and salary and education and addrs): return HttpResponse("十分抱歉,你输入的参数缺失,请检查确认后重试。重试失败请联系客服人员") skills = "" for i in range(1, 7): skill = request.POST.get('skill%s' % i) if skill != "": skills += skill + "," skills = skills[:-1] piclist = '' OSSUgcRes = OSSTools('ugcres') access_token = CommonHelper.access_token for i in range(1, 7): media_id = request.POST.get('img_url%s' % i) if media_id: url = "http://file.api.weixin.qq.com/cgi-bin/media/get?access_token=%s&media_id=%s" % ( access_token, media_id) picname = str_tools.gen_short_uuid() + ".jpg" OSSUgcRes.upload_from_url(picname, url) if piclist: piclist = '%s,%s' % (piclist, picname) else: piclist = picname job = Job(uuid=str_tools.gen_uuid(), user_id=user_id, company_name=company_name, job_title=job_title, work_experience=work_experience, salary=salary, education=education, province=province, city=city, district=district, skill=skills, piclist=piclist) job.save() if is_vip(user_id): vip_job = VipJobList(job_id=job.id, user_id=user_id, pub_time=datetime.datetime.now()) vip_job.save() page_data = model_to_dict(job, exclude=['id', 'user_id', 'is_valid', 'create_time', 'update_time', ]) page_data['time'] = convert.format_time(job.create_time) page_data['city'] = job.city + " " + job.district profile = Profile.objects.filter(id=job.user_id)[0] page_data['username'] = profile.real_name page_data['portrait'] = profile.portrait page_data['user_title'] = profile.title page_data['user_company'] = profile.company_name page_data['uuid'] = str(page_data['uuid']) user_info_map = {} user_info_map[page_data['uuid']] = convert.get_userinfo(profile) page_data['user_info_map'] = json.dumps(user_info_map) page_data['jsapi'] = convert.get_jsApi(request) page_data['post_success'] = 1 return render_to_response('job/job_detail.html', page_data)
def post_job(request): user_id = get_userid_by_openid(request.openid) if not user_id: logging.error('Cant find user_id by openid: %s when post_job' % request.openid) return HttpResponse("十分抱歉,获取用户信息失败,请重试。重试失败请联系客服人员") profile = get_user_profile_by_user_id(user_id=user_id, need_default=False) if not profile: logging.error('Cant find user profile by user_id: %s when post_job' % user_id) return HttpResponse("十分抱歉,获取用户信息失败,请重试。重试失败请联系客服人员") company_name = request.POST.get('company_name') job_title = request.POST.get('job_title') work_experience = request.POST.get('work_experience') salary = request.POST.get('salary') education = request.POST.get('education') addrs = request.POST.get('city').split(' ') province = addrs[0] city = addrs[1] district = '' if len(addrs) == 3: # 防止有些地方没有区,数组越界异常 district = addrs[2] if not (company_name and job_title and work_experience and salary and education and addrs): return HttpResponse("十分抱歉,你输入的参数缺失,请检查确认后重试。重试失败请联系客服人员") skills = "" for i in range(1, 7): skill = request.POST.get('skill%s' % i) if skill != "": skills += skill + "," skills = skills[:-1] piclist = '' OSSUgcRes = OSSTools('ugcres') access_token = CommonHelper.access_token for i in range(1, 7): media_id = request.POST.get('img_url%s' % i) if media_id: url = "http://file.api.weixin.qq.com/cgi-bin/media/get?access_token=%s&media_id=%s" % ( access_token, media_id) picname = str_tools.gen_short_uuid() + ".jpg" OSSUgcRes.upload_from_url(picname, url) if piclist: piclist = '%s,%s' % (piclist, picname) else: piclist = picname job = Job(uuid=str_tools.gen_uuid(), user_id=user_id, company_name=company_name, job_title=job_title, work_experience=work_experience, salary=salary, education=education, province=province, city=city, district=district, skill=skills, piclist=piclist) job.save() if is_vip(user_id): vip_job = VipJobList(job_id=job.id, user_id=user_id, pub_time=datetime.datetime.now()) vip_job.save() page_data = {} page_data = model_to_dict(job, exclude=['id', 'user_id', 'is_valid', 'create_time', 'update_time', ]) page_data['time'] = convert.format_time(job.create_time) page_data['city'] = job.city + " " + job.district page_data['username'] = profile.real_name page_data['portrait'] = profile.portrait page_data['user_title'] = profile.title page_data['user_company'] = profile.company_name page_data['jsapi'] = jsapi_sign(request) page_data['post_success'] = 1 template = get_template('job/job_detail.html') return HttpResponse(template.render(page_data, request))