Exemple #1
0
def fabu_list(request):
	user_id = get_userid_by_openid(request.openid)
	job_from_point = convert.str_to_int(request.GET.get('from', '0'), 0)  # 有from时,则为翻页,无时,则为首页
	number_limit = convert.str_to_int(request.GET.get('limit', '10'), 10)  # 异常情况下,或者不传的情况下,默认为10
	jobs = Job.objects.filter(user_id=user_id).order_by('-id')[job_from_point:number_limit + job_from_point]
	own_job_list = []
	vip_job_list = []
	user_info_map = {}
	profile = Profile.objects.filter(id=user_id)[0]
	username = profile.real_name
	portrait = profile.portrait
	for my_job in jobs:
		city = my_job.city + " " + my_job.district
		job = {'job_uuid': my_job.uuid, 'city': city, 'company_name': my_job.company_name,
		       'job_title': my_job.job_title, 'education': my_job.education, 'work_experience': my_job.work_experience,
		       'salary': my_job.salary, 'create_time': convert.format_time(my_job.create_time), 'username': username,
		       'portrait': portrait, 'user_company': profile.company_name}
		own_job_list.append(job)
		user_info_map[my_job.uuid] = convert.get_userinfo(profile)

	if job_from_point == 0:  # 首页,需要返回页面
		page_data = {}
		page_data = {'own_job_list': json.dumps(own_job_list), 'vip_job_list': json.dumps(vip_job_list),
		             'user_info_map': json.dumps(user_info_map), 'jsapi': convert.get_jsApi(request)}
		return render_to_response('user/fabu_list.html', page_data)
	else:  # 加载下一页,ajax请求
		# page_data['job_list'] = json.dumps(job_list)
		# page_data['own_job'] = []
		return HttpResponse(json.dumps(own_job_list), content_type='application/json')
Exemple #2
0
def fabu_list(request):
    user_id = get_userid_by_openid(request.openid)
    if not user_id:
        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 fabu_list' % user_id)
        return HttpResponse("十分抱歉,获取用户信息失败,请重试。重试失败请联系客服人员")

    job_from_point = convert.str_to_int(request.GET.get('from', '0'), 0)  # 有from时,则为翻页,无时,则为首页
    number_limit = convert.str_to_int(request.GET.get('limit', '10'), 10)  # 异常情况下,或者不传的情况下,默认为10
    jobs = Job.objects.filter(user_id=user_id).order_by('-id')[job_from_point:number_limit + job_from_point]

    job_list = []
    for my_job in jobs:
        city = my_job.city + " " + my_job.district
        job = {'city': city, 'company_name': my_job.company_name, 'job_title': my_job.job_title,
               'education': my_job.education, 'work_experience': my_job.work_experience, 'salary': my_job.salary,
               'create_time': convert.format_time(my_job.create_time), 'username': profile.real_name, 'portrait': profile.portrait}
        job_list.append(job)

    if job_from_point == 0:  # 首页,需要返回页面
        template = get_template('user/fabu_list.html')
        return HttpResponse(template.render({'job_list': json.dumps(job_list)}, request))
    else:  # 加载下一页,ajax请求
        return HttpResponse(json.dumps(job_list), content_type='application/json')
Exemple #3
0
def index(request):
    user_id = get_userid_by_openid(request.openid)
    if not user_id:
        logging.error('Cant find user_id by openid: %s when index' % request.openid)
        return HttpResponse("十分抱歉,获取用户信息失败,请重试。重试失败请联系客服人员")

    own_profile = get_user_profile_by_user_id(user_id=user_id, need_default=False)
    if not own_profile:
        logging.error('Cant find user profile by user_id: %s when index' % user_id)
        return HttpResponse("十分抱歉,获取用户信息失败,请重试。重试失败请联系客服人员")  
        
    vip_job_from_point = convert.str_to_int(request.GET.get('from', '0'), 0)  # 有from时,则为翻页,无时,则为首页
    number_limit = convert.str_to_int(request.GET.get('limit', '10'), 10)  # 异常情况下,或者不传的情况下,默认为10
    own_job = {}
    user_info_map = {}

    # 取本人发布过的,并且有效的简历
    if vip_job_from_point != 0:  # 不是首页的话,翻页不需要继续找own_jobs了
        own_job = []
    else:  # 首页
        own_jobs = Job.objects.filter(user_id=user_id).order_by('-id')[:1]
        if len(own_jobs) == 1:  # 自己发过职位
            my_job = own_jobs[0]
            own_job = {'city': my_job.city + " " + my_job.district, 'company_name': my_job.company_name, 'job_title': my_job.job_title,
               'education': my_job.education, 'work_experience': my_job.work_experience, 'salary': my_job.salary,
               'create_time': convert.format_time(my_job.create_time), 'username': own_profile.real_name, 'portrait': own_profile.portrait,
               'uuid': my_job.uuid}

            userinfo = {'nick': own_profile.real_name, 'portrait':own_profile.portrait, 'user_company':own_profile.company_name, 'user_title':own_profile.title, 'user_desc':own_profile.desc, 'user_city':own_profile.city}

            user_info_map[my_job.uuid] = userinfo

    # 按发布时间去取VIP发布简历 -- 以后从缓存中取
    vip_job_ids = VipJobList.objects.all().order_by('-pub_time')[vip_job_from_point:number_limit + vip_job_from_point]
    vip_jobs = Job.objects.filter(id__in=[vip_job_id.job_id for vip_job_id in vip_job_ids])
    job_list = []
    for my_job in vip_jobs:
    	profile = get_user_profile_by_user_id(user_id=my_job.user_id, need_default=True)

        city = my_job.city + " " + my_job.district
        job = {'city': city, 'company_name': my_job.company_name, 'job_title': my_job.job_title,
               'education': my_job.education, 'work_experience': my_job.work_experience, 'salary': my_job.salary,
               'create_time': convert.format_time(my_job.create_time), 'username': profile.real_name, 'portrait': profile.portrait,
               'job_uuid': my_job.uuid}

        userinfo = {'nick':profile.real_name, 'portrait':profile.portrait, 'user_company':profile.company_name, 'user_title':profile.title, 'user_desc':profile.desc}
        userinfo['user_city'] = profile.city

        user_info_map[my_job.uuid] = userinfo
        job_list.append(job)

    job_list.reverse()
    
    if vip_job_from_point == 0:  # 首页,需要返回页面
        page_data = {'own_job': json.dumps(own_job), 'job_list': json.dumps(job_list), 'user_info_map': json.dumps(user_info_map)}
        page_data['jsapi'] = jsapi_sign(request)
        template = get_template('index.html')
        return HttpResponse(template.render(page_data, request))
    else:  # 加载下一页,ajax请求
        return HttpResponse(json.dumps(job_list), content_type='application/json')
Exemple #4
0
def index(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("十分抱歉,获取用户信息失败,请重试。重试失败请联系客服人员")

	vip_job_from_point = convert.str_to_int(request.GET.get('from', '0'), 0)  # 有from时,则为翻页,无时,则为首页
	number_limit = convert.str_to_int(request.GET.get('limit', '10'), 10)  # 异常情况下,或者不传的情况下,默认为10
	own_job_list = []
	vip_job_list = []
	user_info_map = {}
	# 取本人发布过的,并且有效的简历
	if vip_job_from_point == 0:  # 是首页的话,找own_jobs
		own_jobs = Job.objects.filter(user_id=user_id).filter(is_valid=True).order_by('-id')[:1]
		if len(own_jobs) == 1:  # 自己发过职位
			own_job = model_to_dict(own_jobs[0],
				exclude=['id', 'user_id', 'is_valid', 'create_time', 'update_time', 'city', 'province', 'district',
				         'piclist', 'skill', ])
			own_job['city'] = own_jobs[0].city + " " + own_jobs[0].district
			own_job['create_time'] = convert.format_time(own_jobs[0].create_time)
			own_job['job_uuid'] = own_jobs[0].uuid
			profile = Profile.objects.filter(id=user_id)[0]
			own_job['username'] = profile.real_name
			own_job['portrait'] = profile.portrait
			own_job['user_company'] = profile.company_name
			own_job_list.append(own_job)

			user_info_map[own_job['uuid']] = convert.get_userinfo(profile)


	# 按发布时间去取VIP发布简历 -- 以后从缓存中取
	vip_jobs = VipJobList.objects.all().order_by('-pub_time')[vip_job_from_point:number_limit + vip_job_from_point]
	job_id_list = [job.job_id for job in vip_jobs]
	vip_jobs = Job.objects.filter(is_valid=True).filter(id__in=job_id_list)
	user_id_list = [job.user_id for job in vip_jobs]
	profiles = Profile.objects.filter(id__in=user_id_list)

	for my_job in vip_jobs:
		profile = profiles.get(id=my_job.user_id)
		username = profile.real_name
		portrait = profile.portrait
		city = my_job.city + " " + my_job.district
		job = {'city': city, 'company_name': my_job.company_name, 'job_title': my_job.job_title,
		       'education': my_job.education, 'work_experience': my_job.work_experience, 'salary': my_job.salary,
		       'create_time': convert.format_time(my_job.create_time), 'username': username, 'portrait': portrait,
		       'job_uuid': my_job.uuid, 'user_company': profile.company_name}

		user_info_map[my_job.uuid] = convert.get_userinfo(profile)
		vip_job_list.append(job)

	vip_job_list.reverse()
	page_data = {'own_job_list': json.dumps(own_job_list), 'vip_job_list': json.dumps(vip_job_list),
	             'user_info_map': json.dumps(user_info_map), 'jsapi': convert.get_jsApi(request)}
	# 请把own_jobs和vip_jobs渲染到页面上
	if vip_job_from_point == 0:  # 首页,需要返回页面
		return render_to_response('index.html', page_data)
	else:  # 加载下一页,ajax请求
		return HttpResponse(json.dumps(vip_job_list), content_type='application/json')
Exemple #5
0
def chat_detail(request):

    send_notice_tool.touch(request.openid)

    user_id = request.user_id
    be_interested_uuid = request.GET.get('be_interested_uuid', '')

    chat_from_point = convert.str_to_int(request.GET.get('from', '0'),
                                         0)  # 有from时,则为翻页,无时,则为首页
    number_limit = convert.str_to_int(request.GET.get('limit', '10'),
                                      10)  # 异常情况下,或者不传的情况下,默认为10

    chat_user_info_map = {}
    be_interesteds = BeInterested.objects.filter(uuid=be_interested_uuid)[:1]
    if not be_interesteds:
        log.error('Cant find be_interesteds by be_interested_uuid: %s ' %
                  be_interested_uuid)
        return HttpResponse("十分抱歉,获取留言信息失败,请重试。重试失败请联系客服人员")

    be_interested = be_interesteds[0]

    job_details = Job.objects.filter(id=be_interested.job_id)[:1]
    if not job_details:
        log.error("uid(%s) try to get not exsit job, maybe attack" % user_id)
        return HttpResponse("十分抱歉,获取职位信息失败,请重试。重试失败请联系客服人员")

    conversations = Conversation.objects.filter(
        be_interested_id=be_interested.id).order_by(
            "-id")[chat_from_point:chat_from_point + number_limit]
    conversation_list = []
    qlm_profile = user_tools.get_user_profile_by_user_id(
        be_interested.qlm_user_id, need_default=True)
    bl_profile = user_tools.get_user_profile_by_user_id(job_details[0].user_id,
                                                        need_default=True)
    for conversation in conversations:
        if be_interested.qlm_user_id == conversation.user_id:  # 说明是qlm
            profile = qlm_profile
        else:
            profile = bl_profile

        conversation_data = {
            'user_portrait': profile.portrait,
            'user_nick': user_tools.get_user_name(profile),
            'user_uuid': profile.uuid,
            'words': conversation.words,
            'create_time': conversation.create_time.strftime('%Y-%m-%d %H:%M'),
            'vip_display': 'block' if profile.vip else 'none'
        }

        chat_user_info_map[profile.uuid] = user_tools.get_userinfomap(profile)
        conversation_list.append(conversation_data)

    if chat_from_point == 0:  # 首页,需要返回页面
        page_data = logic_tools.get_job_detail(job_details[0].id)
        page_data['conversation_list'] = json.dumps(conversation_list)
        page_data['be_interested_uuid'] = str(be_interested.uuid)
        page_data['chat_user_info_map'] = json.dumps(chat_user_info_map)
        page_data['jsapi'] = jsapi_sign(request)

        merge_msg = MergeMsg.objects.filter(
            be_interested_id=be_interested.id)[:1]
        if not merge_msg:
            log.error('Cant find merge_msg by be_interested_id: %s' %
                      be_interested.id)
            return HttpResponse("十分抱歉,获取推荐消息失败,请重试。重试失败请联系客服人员")
        if user_id == job_details[0].user_id:  # 我是主公,返回千里马的姓名
            merge_msg[0].zg_have_read = True
            merge_msg[0].save()
            page_data['des_nick'] = user_tools.get_user_name(qlm_profile)
        else:
            merge_msg[0].qlm_have_read = True
            merge_msg[0].save()
            page_data['des_nick'] = user_tools.get_user_name(bl_profile)
        template = get_template('chat/chat.html')
        return HttpResponse(template.render(page_data, request))
    else:  # 加载下一页,ajax请求
        page_data = {
            "conversation_list": conversation_list,
            "chat_user_info_map": chat_user_info_map
        }
        return HttpResponse(json.dumps(page_data),
                            content_type='application/json')
Exemple #6
0
def index(request):
    user_id = request.user_id
    own_profile = user_tools.get_user_profile_by_user_id(user_id=user_id,
                                                         need_default=False)
    if not own_profile:
        log.error('Cant find user profile by user_id: %s when index' % user_id)
        return HttpResponse("十分抱歉,获取用户信息失败,请重试。重试失败请联系客服人员")

    vip_job_from_point = convert.str_to_int(request.GET.get('from', '0'),
                                            0)  # 有from时,则为翻页,无时,则为首页
    number_limit = convert.str_to_int(request.GET.get('limit', '10'),
                                      10)  # 异常情况下,或者不传的情况下,默认为10
    own_job_list = []
    user_info_map = {}

    # 取本人发布过的,并且有效的简历
    if vip_job_from_point == 0:  # 不是首页的话,翻页不需要继续找own_jobs了
        own_jobs = Job.objects.filter(user_id=user_id,
                                      is_valid=True).order_by('-id')[:1]
        if len(own_jobs) == 1:  # 自己发过职位
            my_job = own_jobs[0]
            own_job = {
                'job_city': my_job.city,
                'job_addr': my_job.city + " " + my_job.district,
                'company_name': my_job.company_name,
                'job_title': my_job.job_title,
                'education': my_job.education,
                'work_experience': my_job.work_experience,
                'salary': my_job.salary,
                'create_time': convert.format_time(my_job.create_time),
                'username': user_tools.get_user_name(own_profile),
                'portrait': own_profile.portrait,
                'job_uuid': my_job.uuid,
                'user_company': own_profile.company_name,
                'vip_display': 'none'
            }
            own_job_list.append(own_job)

            user_info_map[my_job.uuid] = user_tools.get_userinfomap(
                own_profile)

    # 按发布时间去取VIP发布简历
    vip_job_records = VipJobList.objects.all().order_by(
        '-pub_time')[vip_job_from_point:number_limit + vip_job_from_point]
    vip_jobs = Job.objects.filter(id__in=list(
        set([vip_job_record.job_id for vip_job_record in vip_job_records])))
    vip_job_id_to_vip_job = {}
    for vip_job in vip_jobs:
        vip_job_id_to_vip_job[vip_job.id] = vip_job

    profiles = Profile.objects.filter(
        id__in=list(set([vip_job.user_id for vip_job in vip_jobs])))
    user_id_to_profile = {}
    for profile in profiles:
        user_id_to_profile[profile.id] = profile

    vip_job_list = []
    for vip_job_record in vip_job_records:
        vip_job = vip_job_id_to_vip_job[vip_job_record.job_id]
        profile = user_id_to_profile[vip_job.user_id]
        job = {
            'job_city': vip_job.city,
            'job_addr': vip_job.city + " " + vip_job.district,
            'company_name': vip_job.company_name,
            'job_title': vip_job.job_title,
            'education': vip_job.education,
            'work_experience': vip_job.work_experience,
            'salary': vip_job.salary,
            'create_time': convert.format_time(vip_job.create_time),
            'username': user_tools.get_user_name(profile),
            'portrait': profile.portrait,
            'job_uuid': vip_job.uuid,
            'user_company': profile.company_name
        }
        vip_job_list.append(job)

        user_info_map[vip_job.uuid] = user_tools.get_userinfomap(profile)

    page_data = {
        'own_job_list': json.dumps(own_job_list),
        'vip_job_list': json.dumps(vip_job_list),
        'user_info_map': json.dumps(user_info_map)
    }
    page_data = user_tools.get_isbind_and_isedit(own_profile, request,
                                                 page_data)

    if vip_job_from_point == 0:  # 首页,需要返回页面
        page_data['jsapi'] = jsapi_sign(request)
        template = get_template('index.html')
        return HttpResponse(template.render(page_data, request))
    else:  # 加载下一页,ajax请求
        page_data = {
            'own_job_list': own_job_list,
            'vip_job_list': vip_job_list,
            'user_info_map': user_info_map
        }
        return HttpResponse(json.dumps(page_data),
                            content_type='application/json')
Exemple #7
0
def get_chat_list(request):
    user_id = request.user_id
    chat_from_point = convert.str_to_int(request.GET.get('from', '0'),
                                         0)  # 有from时,则为翻页,无时,则为首页
    number_limit = convert.str_to_int(request.GET.get('limit', '10'),
                                      10)  # 异常情况下,或者不传的情况下,默认为10
    chat_list = []
    chats = MergeMsg.objects.filter(
        Q(qlm_user_id=user_id) | Q(zg_user_id=user_id)).order_by(
            "-update_time")[chat_from_point:chat_from_point + number_limit]

    user_id_list = []
    be_interested_id_list = []
    recommend_id_list = []
    job_id_list = []
    for merge_msg in chats:
        if merge_msg.qlm_user_id == user_id:  # 本人是千里马,发消息来的为主公
            user_id_list.append(merge_msg.zg_user_id)
            be_interested_id_list.append(merge_msg.be_interested_id)
        else:  # 本人是主公,发消息来的有可能是千里马或是伯乐
            if merge_msg.recommend_id != 0:  # 说明是伯乐发消息
                user_id_list.append(merge_msg.bl_user_id)
                recommend_id_list.append(merge_msg.recommend_id)
            else:  # 本人是主公,对方是千里马
                user_id_list.append(merge_msg.qlm_user_id)
                be_interested_id_list.append(merge_msg.be_interested_id)

    id_to_profile = {}
    profiles = Profile.objects.filter(id__in=list(set(user_id_list)))
    for profile in profiles:
        id_to_profile[profile.id] = profile

    id_to_be_interested = {}
    be_interesteds = BeInterested.objects.filter(
        id__in=list(set(be_interested_id_list)))
    for be_interested in be_interesteds:
        job_id_list.append(be_interested.job_id)
        id_to_be_interested[be_interested.id] = be_interested

    id_to_be_recommend = {}
    recommends = MyRecommend.objects.filter(
        id__in=list(set(recommend_id_list)))
    for recommend in recommends:
        job_id_list.append(recommend.job_id)
        id_to_be_recommend[recommend.id] = recommend

    id_to_job = {}
    jobs = Job.objects.filter(id__in=list(set(job_id_list)))
    for job in jobs:
        id_to_job[job.id] = job

    for merge_msg in chats:
        if merge_msg.qlm_user_id == user_id:  # 本人是千里马,发消息来的为主公
            zg_profile = id_to_profile[merge_msg.zg_user_id]
            be_interested = id_to_be_interested[merge_msg.be_interested_id]
            if not zg_profile or not be_interested:
                continue
            zg_job = id_to_job[be_interested.job_id]
            if not zg_job:
                continue
            display_css = "none" if merge_msg.qlm_have_read else "block"  # 已读和未读判断
            chat_info = {
                'user_tag': "主公",
                'portrait': zg_profile.portrait,
                'nick': user_tools.get_user_name(zg_profile),
                'last_words': merge_msg.last_words,
                'update_time': convert.format_time(merge_msg.update_time),
                'display_css': display_css,
                'background_color': "#c773ff",
                'job_title': zg_job.company_name + zg_job.job_title,
                'go_url':
                "/chat/chat_detail?be_interested_uuid=" + be_interested.uuid,
                'hint': '招聘职位:'
            }
        else:  # 本人是主公,发消息来的有可能是千里马或是伯乐
            if merge_msg.recommend_id != 0:  # 说明是伯乐发消息
                bl_profile = id_to_profile[merge_msg.bl_user_id]
                recommend = id_to_be_recommend[merge_msg.recommend_id]
                if not bl_profile or not recommend:
                    continue
                zg_job = id_to_job[recommend.job_id]
                if not zg_job:
                    continue
                display_css = "none" if merge_msg.zg_have_read else "block"
                chat_info = {
                    'user_tag':
                    "伯乐",
                    'portrait':
                    bl_profile.portrait,
                    'nick':
                    user_tools.get_user_name(bl_profile),
                    'last_words':
                    merge_msg.last_words,
                    'update_time':
                    convert.format_time(merge_msg.update_time),
                    'display_css':
                    display_css,
                    'background_color':
                    "#ff9600",
                    'job_title':
                    zg_job.company_name + zg_job.job_title,
                    'go_url':
                    "/job/post_recommand_job_success?is_chat=1&share_to_zg=1&recommend_uuid="
                    + recommend.uuid + "&merge_msg_uuid=" + merge_msg.uuid,
                    'hint':
                    '推荐职位:'
                }
            else:  # 本人是主公,对方是千里马
                qlm_profile = id_to_profile[merge_msg.qlm_user_id]
                be_interested = id_to_be_interested[merge_msg.be_interested_id]
                if not qlm_profile or not be_interested:
                    continue
                zg_job = id_to_job[be_interested.job_id]
                if not zg_job:
                    continue
                display_css = "none" if merge_msg.zg_have_read else "block"
                chat_info = {
                    'user_tag':
                    "千里马",
                    'portrait':
                    qlm_profile.portrait,
                    'nick':
                    user_tools.get_user_name(qlm_profile),
                    'last_words':
                    merge_msg.last_words,
                    'update_time':
                    convert.format_time(merge_msg.update_time),
                    'display_css':
                    display_css,
                    'background_color':
                    "#00a8ff",
                    'job_title':
                    zg_job.company_name + zg_job.job_title,
                    'go_url':
                    "/chat/chat_detail?be_interested_uuid=" +
                    be_interested.uuid,
                    'hint':
                    '应聘职位:'
                }
        chat_list.append(chat_info)

    page_data = {'chat_list': json.dumps(chat_list)}

    send_notice_tool.touch(request.openid)

    if chat_from_point == 0:  # 首页,需要返回页面
        page_data['jsapi'] = jsapi_sign(request)
        template = get_template('chat/mesg.html')
        return HttpResponse(template.render(page_data, request))
    else:  # 加载下一页,ajax请求
        return HttpResponse(json.dumps({'chat_list': chat_list}),
                            content_type='application/json')
Exemple #8
0
def interview_list(request):
    user_id = request.user_id
    interview_job_from_point = convert.str_to_int(request.GET.get('from', '0'),
                                                  0)  # 有from时,则为翻页,无时,则为首页
    number_limit = convert.str_to_int(request.GET.get('limit', '10'),
                                      10)  # 异常情况下,或者不传的情况下,默认为10

    interview_job_list = []
    user_info_map = {}

    my_interviews = MyInterview.objects.filter(user_id=user_id).order_by(
        '-id')[interview_job_from_point:number_limit +
               interview_job_from_point]

    job_id_list = [job.job_id for job in my_interviews]
    interview_jobs = Job.objects.filter(id__in=list(set(job_id_list)))

    user_id_list = [job.user_id for job in interview_jobs]
    profiles = Profile.objects.filter(id__in=list(set(user_id_list)))
    user_id_to_profile = {}
    for profile in profiles:
        user_id_to_profile[profile.id] = profile

    for interview_job in interview_jobs:
        profile = user_id_to_profile[interview_job.user_id]
        job_addr = interview_job.city + " " + interview_job.district
        job = {
            'job_city': interview_job.city,
            'job_addr': job_addr,
            'company_name': interview_job.company_name,
            'job_title': interview_job.job_title,
            'education': interview_job.education,
            'work_experience': interview_job.work_experience,
            'salary': interview_job.salary,
            'create_time': convert.format_time(interview_job.create_time),
            'username': user_tools.get_user_name(profile),
            'portrait': profile.portrait,
            'job_uuid': interview_job.uuid,
            'user_company': profile.company_name,
            'vip_display': 'block' if profile.vip else 'none'
        }
        user_info_map[interview_job.uuid] = user_tools.get_userinfomap(profile)
        interview_job_list.append(job)

    interview_job_list.reverse()
    if interview_job_from_point == 0:  # 首页,需要返回页面
        page_data = {
            'interview_job_list': json.dumps(interview_job_list),
            'user_info_map': json.dumps(user_info_map),
            'jsapi': jsapi_sign(request)
        }

        template = get_template('user/yinping_list.html')
        return HttpResponse(template.render(page_data, request))
    else:  # 加载下一页,ajax请求
        page_data = {
            'interview_job_list': interview_job_list,
            'user_info_map': user_info_map
        }
        return HttpResponse(json.dumps(page_data),
                            content_type='application/json')
Exemple #9
0
def fabu_list(request):
    user_id = request.user_id
    user_uuid = request.GET.get('user_uuid', '')
    if user_uuid:  # 查某人的所有职位
        profile = Profile.objects.filter(uuid=user_uuid)[:1]
        if profile:
            profile = profile[0]
            if profile.id == user_id:
                page_title = "我的发布"
            else:
                page_title = "他的发布"
            user_id = profile.id
        else:
            log.error('Cant find user profile by user_id: %s when fabu_list' %
                      user_id)
            return HttpResponse("十分抱歉,获取用户信息失败,请重试。重试失败请联系客服人员")
    else:  # 查自己发过的所有职位
        profile = user_tools.get_user_profile_by_user_id(user_id=user_id,
                                                         need_default=False)
        page_title = "我的发布"
        if not profile:
            log.error('Cant find user profile by user_id: %s when fabu_list' %
                      user_id)
            return HttpResponse("十分抱歉,获取用户信息失败,请重试。重试失败请联系客服人员")

    job_from_point = convert.str_to_int(request.GET.get('from', '0'),
                                        0)  # 有from时,则为翻页,无时,则为首页
    number_limit = convert.str_to_int(request.GET.get('limit', '10'),
                                      10)  # 异常情况下,或者不传的情况下,默认为10

    jobs = Job.objects.filter(
        user_id=user_id).order_by('-id')[job_from_point:number_limit +
                                         job_from_point]
    own_job_list = []
    user_info_map = {}
    for my_job in jobs:
        job_addr = my_job.city + " " + my_job.district
        job = {
            'job_uuid': my_job.uuid,
            'job_city': my_job.city,
            'job_addr': job_addr,
            'company_name': my_job.company_name,
            'job_title': my_job.job_title,
            'education': my_job.education,
            'work_experience': my_job.work_experience,
            'salary': my_job.salary,
            'create_time': convert.format_time(my_job.create_time),
            'username': user_tools.get_user_name(profile),
            'portrait': profile.portrait,
            'user_company': profile.company_name
        }
        own_job_list.append(job)
        user_info_map[my_job.uuid] = user_tools.get_userinfomap(profile)

    vip_display = 'block' if user_tools.get_userinfomap(
        profile)['vip'] else 'none'
    if job_from_point == 0:  # 首页,需要返回页面
        page_data = {
            'vip_display': vip_display,
            'own_job_list': json.dumps(own_job_list),
            'vip_job_list': json.dumps([]),
            'user_info_map': json.dumps(user_info_map),
            'jsapi': jsapi_sign(request),
            'page_title': page_title,
            "user_uuid": user_uuid
        }
        page_data = user_tools.get_isbind_and_isedit(None, request, page_data)
        template = get_template('user/fabu_list.html')
        return HttpResponse(template.render(page_data, request))
    else:  # 加载下一页,ajax请求
        page_data = {
            'own_job_list': own_job_list,
            'vip_job_list': json.dumps([]),
            'user_info_map': user_info_map
        }
        return HttpResponse(json.dumps(page_data),
                            content_type='application/json')
Exemple #10
0
def recommand_list(request):
    user_id = request.user_id
    recommend_job_from_point = convert.str_to_int(request.GET.get('from', '0'),
                                                  0)  # 有from时,则为翻页,无时,则为首页
    number_limit = convert.str_to_int(request.GET.get('limit', '10'),
                                      10)  # 异常情况下,或者不传的情况下,默认为10

    recommend_job_list = []
    user_info_map = {}

    my_recommend_merges = MyRecommendMerg.objects.filter(
        user_id=user_id).order_by(
            'update_time')[recommend_job_from_point:number_limit +
                           recommend_job_from_point]

    job_id_list = [job.job_id for job in my_recommend_merges]
    recommend_jobs = Job.objects.filter(id__in=list(set(job_id_list)))
    user_id_list = [job.user_id for job in recommend_jobs]
    profiles = Profile.objects.filter(id__in=list(set(user_id_list)))
    user_id_to_profile = {}
    for profile in profiles:
        user_id_to_profile[profile.id] = profile

    for recommend_job in recommend_jobs:
        profile = user_id_to_profile[recommend_job.user_id]
        my_recommend_merge = [
            my_recommend_merge for my_recommend_merge in my_recommend_merges
            if my_recommend_merge.job_id == recommend_job.id
        ]
        job_addr = recommend_job.city + " " + recommend_job.district
        job = {
            'job_city': recommend_job.city,
            'job_addr': job_addr,
            'company_name': recommend_job.company_name,
            'job_title': recommend_job.job_title,
            'education': recommend_job.education,
            'work_experience': recommend_job.work_experience,
            'salary': recommend_job.salary,
            'create_time': convert.format_time(recommend_job.create_time),
            'username': user_tools.get_user_name(profile),
            'portrait': profile.portrait,
            'job_uuid': recommend_job.uuid,
            'user_company': profile.company_name,
            'recommend_num': my_recommend_merge[0].recommend_num,
            'vip_display': 'block' if profile.vip else 'none'
        }
        user_info_map[recommend_job.uuid] = user_tools.get_userinfomap(profile)
        recommend_job_list.insert(0, job)

    if recommend_job_from_point == 0:  # 首页,需要返回页面
        page_data = {
            'recommend_job_list': json.dumps(recommend_job_list),
            'user_info_map': json.dumps(user_info_map),
            'jsapi': jsapi_sign(request)
        }
        template = get_template('user/recommand_list.html')
        return HttpResponse(template.render(page_data, request))
    else:  # 加载下一页,ajax请求
        page_data = {
            'recommend_job_list': recommend_job_list,
            'user_info_map': user_info_map
        }
        return HttpResponse(json.dumps(page_data),
                            content_type='application/json')