def after_upload_resume(request):

    login_name = request.session.get('login_name')
    login_name = login_name + "\\"

    resume_user_dir = resume_base_dir + login_name
    once_imported_telephone_list_file = 'once_imported_telephone_list.txt'
    once_imported_telephone_list_file_path = resume_user_dir + once_imported_telephone_list_file

    with open(once_imported_telephone_list_file_path,
              "r") as f:  #    , encoding="utf-8"
        telephone_string = f.read()

    telephone_string = re.sub(r',$', '', telephone_string,
                              re.RegexFlag.S | re.RegexFlag.M)
    telephone_string = re.sub(r'^\s+|\s+$', '', telephone_string,
                              re.RegexFlag.S | re.RegexFlag.M)

    if telephone_string:
        telephone_list = telephone_string.split(',')

        if telephone_list:
            telephone_list = list(map(int, telephone_list))

            candidate_obj = Candidate_resource.objects(
                telephone__in=telephone_list).as_pymongo()

            result_json = dumps(candidate_obj, ensure_ascii=False)
            #             print(result_json)
            return HttpResponse(result_json)
    else:
        return HttpResponse({'msg': 'failed'})
Exemple #2
0
def get_total_count(request):
    filter_params_dict = {}
    for key, value in request.GET.items():
        if value:
            key = key + '__icontains'
            filter_params_dict.update({key: value})

#     if filter_params_dict:
#         candidate_obj = CandidateResource.objects.filter(**filter_params_dict).values('name', 'telephone', 'company', 'position', 'new_remark')
#     else:
#         candidate_obj = CandidateResource.objects.all().values('name', 'telephone', 'company', 'position')

#     candidate_obj = Candidate_resource.objects(company='美团', name='周璐')
#     candidate_obj = Candidate_resource.objects(**filter_params_dict)
#     if filter_params_dict:
#         candidate_obj = Candidate_resource.objects(**filter_params_dict)
#     else:
#         candidate_obj = Candidate_resource.objects.all()

    if filter_params_dict:
        candidate_obj = Candidate_resource.objects(**filter_params_dict)
        data_list = list(candidate_obj)
        total_count = len(data_list)
    else:
        total_count = Candidate_resource.objects.count()

    print('total:' + str(total_count))
    return HttpResponse(total_count)
Exemple #3
0
def update_jianli(request):
    filter_params_dict = {}
    update_params_dict = {}
    login_name = request.session.get('login_name')

    for key, value in request.POST.items():
        if key == 'telephone':
            value = int(value)
            print(type(value))
            
            
            if value:
                filter_params_dict.update({key: value})
                update_params_dict.update({key: value})
        else:
            if value:
                # print(key + ':' + value)
                update_params_dict.update({key: value})
            else:
                update_params_dict.update({key: ''})

#     conment = update_params_dict['new_remark']
#     conment = update_params_dict.pop('new_remark')
#     print(conment)
    
    print(filter_params_dict)
    print(update_params_dict)
    
    #    时间戳
    date_strf = time.time()
    #    格式化时间
    format_time_string = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())

    update_params_dict.update({'last_operator': login_name, 'update_time': format_time_string})
    update_params_dict.update({'new_import_flag': 0})
    
    status = 'error'
    if filter_params_dict:
#         candidate_obj = CandidateResource.objects.filter(**filter_params_dict).update(**update_params_dict)
        
#         candidate_resource.update(filter_params_dict, {"$set":update_params_dict,
#                                                     "$push":{"new_remark":{
#                                                                                    "comment" : "1101更新数据和更新内嵌文档都已经好用了",
#                                                                                    "date_strf":date_strf,
#                                                                                    "date_string":format_time_string
#                                                                                    }}})
        
        candidate_obj = Candidate_resource.objects(**filter_params_dict).update(upsert= True, **update_params_dict)
        if candidate_obj:
            status = 'success'
        
#         if(conment != ''):
#             one_remark = One_remark(comment=conment, date_strf=date_strf, date_string=format_time_string)
# #             candidate_obj = Candidate_resource.objects(**filter_params_dict).update(push__new_remark=one_remark)
#             candidate_obj = Candidate_resource.objects(**filter_params_dict).update(upsert= True, **update_params_dict, push__new_remark=one_remark)
#             if candidate_obj:
#                 status = 'success'
        

    return JsonResponse({'status': status})
Exemple #4
0
def search_jianli(request):
    filter_params_dict = {}
    pagination_params_dict = {}

    for key, value in request.GET.items():
        print(key + ':' + value)
        if re.search('page', key, flags=0):
            pagination_params_dict.update({key: value})
        else:
            if value:
                key = key + '__icontains'
                filter_params_dict.update({key: value})

    print(filter_params_dict)
    print(pagination_params_dict)

    per_page_count = int(pagination_params_dict.get('per_page_count'))

    from_search_count = 0
    if pagination_params_dict.get('current_page_num'):
        current_page_num = int(
            pagination_params_dict.get('current_page_num')) - 1
        from_search_count = per_page_count * current_page_num

#     if filter_params_dict:
#         # candidate_obj = CandidateResource.objects.filter(company='美团', name='周璐').values('name', 'telephone', 'company')[:10]
#         # candidate_obj = CandidateResource.objects.filter(**filter_params_dict)[0:1]   #---    这种方式报错
#         candidate_obj = CandidateResource.objects.filter(**filter_params_dict).values('name', 'telephone', 'company', 'position', 'new_remark')[from_search_count:from_search_count + 10]
#     else:
#         candidate_obj = CandidateResource.objects.all().values('name', 'telephone', 'company', 'position', 'new_remark')[from_search_count:from_search_count + 10]

    collection_obj = Candidate_resource.objects(**filter_params_dict)[0:1]
    candidate_obj = collection_obj._collection_obj.find(
        collection_obj._query, sort=[
            ("update_time", pymongo.DESCENDING)
        ])[from_search_count:from_search_count + 10]

    #     if filter_params_dict:
    #         candidate_obj = Candidate_resource.objects(**filter_params_dict)[from_search_count:from_search_count + 10]
    #     else:
    # #         candidate_obj = Candidate_resource.objects.all()[from_search_count:from_search_count + 10]
    #         candidate_obj = Candidate_resource.objects[from_search_count:from_search_count + 10]
    #
    #     data_list = list(candidate_obj)

    #     print(len(data_list))
    #     for user in candidate_obj:
    #         print(user.name)

    #     data_json = data_list.to_json()
    #     data_json = serializers(data_list)
    #     data_json = json.dumps(data_list, ensure_ascii=False)

    data_json = dumps(candidate_obj, ensure_ascii=False)
    #     data_json = serializers.serialize('json', candidate_obj, ensure_ascii=False)
    print(data_json)  #-----------------------------------

    return HttpResponse(data_json)
Exemple #5
0
def resume_remark_add(request):
    filter_params_dict = {}
    update_params_dict = {}
    
    if request.method == "POST":
    
        for key, value in request.POST.items():
            if key == 'telephone':
                value = int(value)
                print(type(value))
                filter_params_dict.update({key: value})
            else:
                if value:
                    update_params_dict.update({key: value})
                else:
                    update_params_dict.update({key: ''})
        
        conment = update_params_dict.pop('new_remark')
        print(conment)
        
        #    时间戳
        date_strf = time.time()
        #    格式化时间
        format_time_string = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
        #    最近的操作者
        last_operator_login_name = request.session.get('login_name')
        
        update_params_dict.update({'update_time':format_time_string, 'last_operator':last_operator_login_name})
        
        print(filter_params_dict)
        print(update_params_dict)
        
        status = 'error'
        if filter_params_dict:
            if conment != '':
                one_remark = One_remark(comment=conment, date_strf=date_strf, date_string=format_time_string, last_operator=last_operator_login_name)
    #             candidate_obj = Candidate_resource.objects(**filter_params_dict).update(push__new_remark=one_remark)
                candidate_obj = Candidate_resource.objects(**filter_params_dict).update(upsert= True, **update_params_dict, push__new_remark=one_remark)
                if candidate_obj:
                    status = 'success'
            
    
        return JsonResponse({'status': status})
        
#         for register_login_name, value in request.POST.items():
#             if register_login_name:
#                 admin_obj = Candidate_user.objects(login_name=admin_login_name, prompt_message__login_name=register_login_name).update_one(set__prompt_message__S__del_flag=1)
#                 delete_count += 1
#                   
#         if(delete_count):
#             status = 'success'
#         
#         return HttpResponse("success")
#         return JsonResponse({'status': status, 'del_count': delete_count})
    else:
        telephone = request.GET.get('telephone')
        return render(request, 'talent_manage_html/resume_remark_add.html',{'telephone':telephone})
def module_separation(all_text):
    #    个人信息/个人资料/基本信息/基本资料
    personal_base_info_list = ["个人信息", "个人资料", "基本信息", "基本资料"]
    #    个人简介
    profile_info_list = ["个人简介"]
    #    教育背景/教育经历
    education_info_list = ["教育背景", "教育经历"]
    #    工作经历/工作经验
    work_experience_info_list = ["工作经历", "工作经验"]
    #    项目经验/项目经历
    project_experience_info_list = ["项目经历", "项目经验"]
    #    工作能力标签/工作能力/专业评价
    ability_info_list = ["工作能力", "专业评价", "工作能力标签"]
    #    语言能力
    language_info_list = ["语言能力"]
    #    证书
    certificate_info_list = ["证书"]
    #    专业技能/技能标签/技能评价/IT技能
    skill_info_list = ["专业技能", "技能评价", "技能标签", "IT技能"]
    #    求职信息/求职意向/职业意向
    intention_info_list = ["求职信息", "求职意向", "职业意向"]
    #    自我评价
    self_evaluation_info_list = ["自我评价"]
    #    附加信息
    extra_info_list = ["附加信息"]
    #    兴趣爱好
    hobby_info_list = ["兴趣爱好"]

    all_module_title_info_list = [
        personal_base_info_list, profile_info_list, education_info_list,
        work_experience_info_list, project_experience_info_list,
        ability_info_list, language_info_list, certificate_info_list,
        skill_info_list, intention_info_list, self_evaluation_info_list,
        extra_info_list, hobby_info_list
    ]
    all_module_title_info_string = str(all_module_title_info_list)

    all_text = re.sub(":", ":", all_text)
    all_text = re.sub(",", ",", all_text)
    all_text = re.sub("~", "~", all_text)
    all_text = re.sub("(", "(", all_text)
    all_text = re.sub(")", ")", all_text)
    all_text = re.sub(";", ";", all_text)

    all_text = re.sub("项目经验\s*", "项目经验 ", all_text)

    all_text = '###' + all_text
    for one_info_list in all_module_title_info_list:
        for one_string in one_info_list:
            if re.search(one_string, all_text):
                all_text = re.sub(one_string, "###" + one_string, all_text)
                #                 print(all_text)
                continue

#     print(all_text)

    module_list = all_text.split("###")

    name = ''
    telephone = ''
    email = ''
    age = ''
    education = ''

    special_module_dict = {}
    normal_module_dict = {}
    for one_module_string in module_list:
        if re.search(r"^([^:\s]*)[:\s]\s*(.*)$", one_module_string,
                     re.RegexFlag.I | re.RegexFlag.S | re.RegexFlag.M):
            module_obj = re.search(
                r"^([^:\s]*)[:\s]\s*(.*)$", one_module_string,
                re.RegexFlag.I | re.RegexFlag.S | re.RegexFlag.M)
            one_module_title = module_obj.group(1)
            one_module_text = module_obj.group(2)

            if one_module_title not in all_module_title_info_string:
                special_module_dict[one_module_title] = one_module_text
            else:
                normal_module_dict[one_module_title] = one_module_text

            print(one_module_title + ":\n" + one_module_text)
        else:
            continue

        if re.search(r"姓名", one_module_string):
            name = re.search(r"姓名\s*[:]*\s+([^\s]*)",
                             one_module_string).group(1)
            print(name)

        if re.search(r"(联系方式|电话)\s*[:\s]\s*([^\s]*)", one_module_string):
            telephone = re.search(r"(联系方式|电话)\s*[:\s]\s*([^\s]*)",
                                  one_module_string).group(2)
            print(telephone)

        if re.search(r"邮箱|email", one_module_string):
            email = re.search(r"(邮箱|email)\s*[:]*\s+([^\s]*)",
                              one_module_string).group(2)
            print(email)

        if re.search(r"出生", one_module_string):
            age = re.search(r"(出生日期|出生年月|生日|年龄)\s*[:]*\s+([^\s]*)",
                            one_module_string).group(2)
            print(age)

        if re.search(r"学历|统招|本科|博士|硕士|双学位|学士学位|专科|大专", one_module_string):
            if re.search(r"学历\s*[:]*\s+([^\s]*)", one_module_string):
                education = re.search(r"学历\s*[:]*\s+([^\s]*)",
                                      one_module_string).group(1)
            else:
                education = re.search(
                    r"([^\s^\(\)]*(统招|本科|博士|硕士|双学位|学士学位|专科|大专)[^\s^\(^\)]*)",
                    one_module_string).group(1)

            print(education)

    if special_module_dict:
        for module_title in special_module_dict:
            name = re.sub(r"(籍贯|民族|政治).*$", "", module_title)

            module_text = special_module_dict[module_title]
            if re.search(r"(^\d+岁)", module_text):
                age = re.search(r"(\d+岁)", module_text).group(1)
                print(age)

#             if re.search(r"(\s*([^\s]*市[^\s]*)\s*)", module_text):
#                 district_city = re.search(r"(\s*([^\s]*市[^\s]*)\s*)", module_text).group(1)
#                 print(district_city)

            if re.search(r"(\s*\d{11}\s*)", module_text):
                telephone = re.search(r"\s*(\d{11})\s*", module_text).group(1)
                print(telephone)

            if re.search(r"\s*([^\s]*\@[^\s]*)\s*", module_text):
                email = re.search(r"\s*([^\s]*\@[^\s]*)\s*",
                                  module_text).group(1)
                print(email)

    if not name:
        print("name error")
        return

    if not telephone:
        print("telephone error")
        return

    if not email:
        print("email error")
        return

    if not age:
        print("age error")
        return

    if not education:
        print("education error")
        return

    filter_params_dict = {}
    update_params_dict = {}

    filter_params_dict.update({'telephone': telephone})

    update_params_dict.update({
        'name': name,
        'email': email,
        'age': age,
        'education': education
    })

    for module_title in normal_module_dict:
        module_text = normal_module_dict[module_title]

        module_text = re.sub("^\s*ABOUT\s*ME\s*", "", module_text)
        module_text = re.sub("^\s*EDUCATION\s*", "", module_text)
        module_text = re.sub("^\s*WORKEXPERIENCE\s*", "", module_text)
        module_text = re.sub("^\s*PROJECTEXPERIENCE\s*", "", module_text)
        module_text = re.sub("^\s*SKILL\s*", "", module_text)

        module_text = re.sub(r"(20\d{2}[.-]\d{1,2}\s*-)", r"\n\1", module_text)
        module_text = re.sub("^\s+", "", module_text)

        if module_title in education_info_list:
            update_params_dict.update({'education': module_text})
        elif module_title in work_experience_info_list:
            update_params_dict.update({'work_experience': module_text})
        elif module_title in project_experience_info_list:
            update_params_dict.update({'project_experience': module_text})
        elif module_title in skill_info_list:
            update_params_dict.update({'skills': module_text})

        elif module_title in profile_info_list:
            update_params_dict.update({'personal_profile': module_text})
        elif module_title in ability_info_list:
            update_params_dict.update({'work_ability': module_text})
        elif module_title in language_info_list:
            update_params_dict.update({'language_ability': module_text})
        elif module_title in certificate_info_list:
            update_params_dict.update({'certificate': module_text})
        elif module_title in intention_info_list:
            update_params_dict.update({'career_intention': module_text})
        elif module_title in self_evaluation_info_list:
            update_params_dict.update({'self_evaluation': module_text})
        elif module_title in extra_info_list:
            update_params_dict.update({'extra_info': module_text})
        elif module_title in hobby_info_list:
            update_params_dict.update({'hobby_info': module_text})

    candidate_obj = Candidate_resource.objects(**filter_params_dict).update(
        upsert=True, **update_params_dict)
    if candidate_obj:
        status = 'success'
def module_separation(all_text, resume_user_dir, resume_name):
    all_text = special_format_process(all_text)

    all_text = base_symbol_format(all_text)

    all_text = re.sub(r"(\d)\s*\)", r"\1)", all_text,
                      re.RegexFlag.I | re.RegexFlag.S | re.RegexFlag.M)

    all_text = date_format_process(all_text)

    all_text = re.sub(r"·{1,}", r"\t", all_text,
                      re.RegexFlag.I | re.RegexFlag.S | re.RegexFlag.M)

    all_text = re.sub(r"项目经验\s*", r"项目经验 \n", all_text,
                      re.RegexFlag.I | re.RegexFlag.S | re.RegexFlag.M)

    #     resume_user_dir = 'F:\\ZZMK\\imported_resume\\susan\\'
    login_name = re.search(r"\\([^\\]*)\\$", resume_user_dir).group(1)
    print(login_name)

    filter_params_dict = {}
    update_params_dict = {}

    name = get_name(resume_name, all_text)

    telephone = get_telephone(all_text)
    #
    #     try:
    #         telephone = get_telephone(all_text)
    #     except ValueError:
    #         if not telephone:
    #             print("not telephone")
    #             status = 'failed'
    #             return status

    email = get_email(all_text)
    education = get_education(all_text)

    gender = get_gender(all_text)
    age = get_age(all_text)
    position_rank = get_position_rank(all_text)
    district_city = get_district_city(all_text)

    update_params_dict.update({
        'name': name,
        'gender': gender,
        'age': age,
        'email': email,
        'education': education,
        'position': position_rank,
        'district_city': district_city
    })

    #    获取其他字段内容
    update_params_dict = get_other_params(all_text, update_params_dict)

    work_experience = ''
    if 'work_experience' in update_params_dict:
        work_experience = update_params_dict['work_experience']

    for key in update_params_dict:

        if key != 'work_experience':
            if key != 'district_city':
                work_experience = work_experience.replace(
                    update_params_dict[key], "",
                    re.RegexFlag.I | re.RegexFlag.S | re.RegexFlag.M)

#             print(key + "\n")
#             print(update_params_dict[key] + "\n")

#     print(work_experience)
    update_params_dict.update({'work_experience': work_experience})

    filter_params_dict.update({'telephone': telephone})

    exist_obj = Candidate_resource.objects(telephone=telephone).as_pymongo()
    if not exist_obj:
        #    格式化时间
        format_time_string = time.strftime('%Y-%m-%d %H:%M:%S',
                                           time.localtime())
        update_params_dict.update({
            'first_uploader': login_name,
            'first_upload_time': format_time_string
        })
        update_params_dict.update({
            'last_operator': login_name,
            'update_time': format_time_string
        })
        update_params_dict.update({'new_import_flag': 1})
    else:
        format_time_string = time.strftime('%Y-%m-%d %H:%M:%S',
                                           time.localtime())
        update_params_dict.update({
            'last_operator': login_name,
            'update_time': format_time_string
        })
        update_params_dict.update({'new_import_flag': 0})

    candidate_obj = Candidate_resource.objects(**filter_params_dict).update(
        upsert=True, **update_params_dict)

    if candidate_obj:
        status = 'success'

        once_imported_telephone_list_file = 'once_imported_telephone_list.txt'
        once_imported_telephone_list_file_path = resume_user_dir + once_imported_telephone_list_file
        if os.path.exists(once_imported_telephone_list_file_path):
            with open(once_imported_telephone_list_file_path,
                      "a") as f:  #    , encoding="utf-8"
                f.write(telephone + ',')
    else:
        status = 'failed'

    return status
Exemple #8
0
def get_resumeInfo(request):

    resume_info_dict = {}
    if request.GET.get('telephone'):
        telephone = request.GET.get('telephone')

        resume_obj = Candidate_resource.objects.filter(
            telephone=telephone).as_pymongo()
        resume_info_dict = resume_obj[0]

        #********************************    前端控制显示排序    **************************
        remark_list = resume_info_dict.get('new_remark')
        #    根据dict的key排序list中的dict
        if remark_list:
            remark_list = sorted(remark_list,
                                 key=itemgetter('date_strf'),
                                 reverse=True)
            resume_info_dict.update({'new_remark': remark_list})
        #********************************    前端控制显示排序    **************************
    else:
        telephone = ""
        resume_info_dict.update({'telephone': telephone})

    #---    为了编辑简历信息,获取models中的所有字段,传到前端
    conn = MongoClient(host="127.0.0.1", port=27017)  #connect to mongodb
    db = conn.LMK_DB
    collection_data_dict = db.collection_data_dict
    collection_name = 'candidate_resource'
    filter_dict = {'collection_name': collection_name}
    result_dict = collection_data_dict.find_one(filter_dict)

    field_name_list_obj = Candidate_resource.__get_field_name__(
        Candidate_resource)
    field_name_list = field_name_list_obj.owner_document._fields_ordered

    all_fields_dict = {}
    for field_name in field_name_list:
        if re.search(r"_id", field_name):
            continue

        if result_dict['en_ch_dict'][field_name]:
            ch_field_name = result_dict['en_ch_dict'][field_name]
            #             print(field_name + " = " + ch_field_name)
            all_fields_dict.update({field_name: ch_field_name})

    return_dict = {}
    if all_fields_dict:
        #    很多字段不需要在页面显示,需要pop掉,而且需要把必须的主要字段位移到数组的前面
        all_fields_dict.pop('first_uploader')
        all_fields_dict.pop('first_upload_time')
        all_fields_dict.pop('last_operator')
        all_fields_dict.pop('update_time')
        all_fields_dict.pop('new_import_flag')
        all_fields_dict.pop('del_flag')
        all_fields_dict.pop('new_remark')

        return_dict.update({'all_fields_dict': all_fields_dict})

    if resume_info_dict:
        if telephone:
            resume_info_dict.pop('_id')

        return_dict.update({'resume_info_dict': resume_info_dict})

    return render(request, 'talent_manage_html/show_resume_info.html',
                  return_dict)