示例#1
0
def get_job_detail(job_id):
    job_details = Job.objects.filter(id=job_id)[:1]

    if not job_details:
        log.error("no job_details id by job_id: %s" % job_id)
        return None

    page_data = model_to_dict(job_details[0],
                              exclude=[
                                  'id',
                                  'user_id',
                                  'is_valid',
                                  'create_time',
                                  'update_time',
                              ])

    page_data['job_addr'] = job_details[0].city + " " + job_details[0].district
    page_data['job_city'] = job_details[0].city

    profile = user_tools.get_user_profile_by_user_id(
        user_id=job_details[0].user_id, need_default=True)
    page_data['username'] = user_tools.get_user_name(profile)
    page_data['portrait'] = profile.portrait
    page_data['user_company'] = profile.company_name
    page_data['user_uuid'] = profile.uuid
    page_data['user_title_count'] = len(Job.objects.filter(user_id=profile.id))
    page_data['user_info_map'] = json.dumps(
        {job_details[0].uuid: user_tools.get_userinfomap(profile)})
    page_data['vip_display'] = "block" if profile.vip else "none"
    return page_data
示例#2
0
def ajax_send_words(request):
    user_id = request.user_id
    be_interested_uuid = request.POST.get('be_interested_uuid')
    words = request.POST.get('words', '')

    profile = user_tools.get_user_profile_by_user_id(user_id,
                                                     need_default=False)
    data = ""
    if be_interested_uuid and words:
        be_interesteds = BeInterested.objects.filter(
            uuid=be_interested_uuid)[:1]
        if be_interesteds:
            conversation = Conversation(be_interested_id=be_interesteds[0].id,
                                        user_id=user_id,
                                        words=words)
            conversation.save()

            openid = None
            if be_interesteds[0].qlm_user_id != user_id:
                openid = user_tools.get_openid(be_interesteds[0].qlm_user_id)
            else:
                job_details = Job.objects.filter(
                    id=be_interesteds[0].job_id).only('user_id')
                if job_details:
                    openid = user_tools.get_openid(job_details[0].user_id)

            send_notice_tool.send_notice(openid)

            merge_msg = MergeMsg.objects.filter(
                be_interested_id=be_interesteds[0].id)[0]  # 既然都可以发送了,肯定有这条记录了
            merge_msg.last_words = words
            if be_interesteds[0].qlm_user_id == user_id:  # 说明发送的这个人是千里马
                merge_msg.qlm_have_read = True
                merge_msg.zg_have_read = False
                merge_msg.update_time = datetime.datetime.now()
            else:
                merge_msg.qlm_have_read = False
                merge_msg.zg_have_read = True
                merge_msg.update_time = datetime.datetime.now()
            merge_msg.save()

            data = {
                'user_portrait': profile.portrait,
                'user_nick': user_tools.get_user_name(profile),
                'words': conversation.words,
                'user_uuid': profile.uuid,
                'vip_display': "block" if profile.vip else "none",
                'create_time':
                conversation.create_time.strftime('%Y-%m-%d %H:%M')
            }
    else:
        log.error(
            "uid(%s) try to get not exsit be_interested_uuid(%s), maybe attack"
            % (user_id, be_interested_uuid))

    return HttpResponse(json.dumps(data), content_type='application/json')
示例#3
0
def get_job(request):
    user_id = request.user_id
    job_uuid = request.GET.get('job_uuid', '')
    last_share_uuid = request.GET.get('last_share_uuid', '')
    job_details = Job.objects.filter(uuid=job_uuid)[:1]
    if job_details:

        if user_id == job_details[0].user_id:
            return HttpResponseRedirect("/user/fabu_detail?job_uuid=" +
                                        job_uuid)

        page_data = model_to_dict(job_details[0],
                                  exclude=[
                                      'id',
                                      'user_id',
                                      'create_time',
                                      'update_time',
                                  ])
        page_data[
            'job_addr'] = job_details[0].city + " " + job_details[0].district
        page_data['job_city'] = job_details[0].city

        profile = user_tools.get_user_profile_by_user_id(
            user_id=job_details[0].user_id, need_default=True)
        page_data['username'] = user_tools.get_user_name(profile)
        page_data['portrait'] = profile.portrait
        page_data['user_company'] = profile.company_name
        page_data['user_uuid'] = profile.uuid
        page_data['user_title_count'] = profile.pub_valid_job_cnt
        page_data['last_share_uuid'] = last_share_uuid

        page_data['vip_display'] = "block" if profile.vip else 'none'

        # 收藏按钮的控制
        if user_id != job_details[0].user_id:  # 这个职位不是该userid发布的
            my_collection = MyCollection.objects.filter(
                user_id=user_id, job_id=job_details[0].id)
            if my_collection:  # 我已经收藏过该职位
                page_data['collection'] = "取消收藏"
            else:
                page_data['collection'] = "收藏职位"

        page_data['user_info_map'] = json.dumps(
            {job_uuid: user_tools.get_userinfomap(profile)})
    else:
        log.error("uid(%s) try to get not exsit job(%s), maybe attack" %
                  (user_id, job_uuid))
        return HttpResponse("十分抱歉,获取职位信息失败,请重试。重试失败请联系客服人员")

    page_data['jsapi'] = jsapi_sign(request)
    page_data = user_tools.get_isbind_and_isedit(None, request, page_data)

    template = get_template('job/job_detail.html')
    return HttpResponse(template.render(page_data, request))
示例#4
0
def fullfill_recommend_detail(page_data, my_recommend, need_audio_4_zg,
                              need_audio_4_qlm):
    if not my_recommend:
        return

    profile = Profile.objects.filter(id=my_recommend.user_id)[:1]
    if not profile:
        log.error("no profile id by my_recommend user_id: %s" %
                  my_recommend.user_id)
        return

    page_data['recommend_audio_4_qlm'] = ''
    page_data['recommend_audio_length_4_qlm'] = ''

    page_data['recommend_audio_4_zg'] = ''
    page_data['recommend_audio_length_4_zg'] = ''
    # 推荐的相关信息start
    if need_audio_4_zg:
        recommend_audio = my_recommend.audio_for_zg.split(",")
        page_data['recommend_audio_4_zg'] = recommend_audio[0]
        page_data['recommend_audio_length_4_zg'] = recommend_audio[1]
        page_data['share_to'] = 'zg'

    if need_audio_4_qlm:
        recommend_audio = my_recommend.audio_for_qlm.split(",")
        page_data['recommend_audio_4_qlm'] = recommend_audio[0]
        page_data['recommend_audio_length_4_qlm'] = recommend_audio[1]
        page_data['share_to'] = 'qlm'

    page_data['bole_name'] = user_tools.get_user_name(profile[0])
    page_data['bole_portrait'] = profile[0].portrait
    page_data['bole_user_info_map'] = json.dumps(
        user_tools.get_userinfomap(profile[0]))
    page_data['recommend_expire_time'] = convert.format_expire_time(
        my_recommend.create_time)
    page_data['recommend_uuid'] = my_recommend.uuid

    page_data['bl_vip_display'] = "block" if profile[0].vip else "none"
示例#5
0
def recommand_job(request):
    user_id = request.user_id
    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:
        page_data = model_to_dict(job_details[0],
                                  exclude=[
                                      'id',
                                      'user_id',
                                      'is_valid',
                                      'create_time',
                                      'update_time',
                                  ])
        page_data[
            'job_addr'] = job_details[0].city + " " + job_details[0].district
        page_data['job_city'] = job_details[0].city

        profile = user_tools.get_user_profile_by_user_id(
            user_id=job_details[0].user_id, need_default=True)
        page_data['username'] = user_tools.get_user_name(profile)
        page_data['portrait'] = profile.portrait
        page_data['user_company'] = profile.company_name
        page_data['user_info_map'] = json.dumps(
            user_tools.get_userinfomap(profile))
        page_data['last_share_uuid'] = last_share_uuid

        page_data['vip_display'] = "block" if profile.vip else "none"
    else:
        log.error("uid(%s) try to get not exsit job(%s), maybe attack" %
                  (user_id, job_uuid))
        return HttpResponse("十分抱歉,获取职位信息失败,请重试。重试失败请联系客服人员")

    page_data['jsapi'] = jsapi_sign(request)
    template = get_template('job/job_recommand.html')
    return HttpResponse(template.render(page_data, request))
示例#6
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')
示例#7
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')
示例#8
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')