Example #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
Example #2
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))
Example #3
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"
Example #4
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))
Example #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')
Example #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')