Exemple #1
0
    def get_resume_info_mapper(self, resume_id_list):
        resume_id_list = [get_oid(resume_id) for resume_id in resume_id_list if get_oid(resume_id)]
        resume_info_query = ResumeData.objects.filter(
            id__in=resume_id_list,
        )

        resume_dict_list = []
        for i in resume_info_query:
            work_years = i.get_work_years()
            resume_dict = mongo_to_dict(i, [])
            resume_dict['work_years'] = work_years
            resume_dict_list.append(resume_dict)

        resume_info_mapper = {
            str(resume['id']): {
                'id': resume.get('id', ''),
                'works': resume.get('works', [{}])[:1],
                'gender': resume.get('gender', ''),
                'age': resume.get('age', ''),
                'job_target': resume.get('job_target', {}),
                'address': resume.get('address', ''),
                'work_years': resume.get('work_years', 0),
                'educations': self.get_latest_edu(resume),
                'self_evaluation': resume.get('self_evaluation', ''),
                'is_secret': resume.get('is_secret', False),
                'last_contact': resume.get('last_contact', ''),
                'hr_evaluate': resume.get('hr_evaluate', ''),
            }
            for resume in resume_dict_list
        }
        return resume_info_mapper
    def read_feed(cls, request, feed_sid, resume_id, read_user=None):
        feed_oid = get_oid(feed_sid)
        resume_oid = get_oid(resume_id)
        if read_user is None:
            read_user = request.GET.get('user', '')

        if not feed_oid or not resume_oid or read_user not in ('admin',
                                                               'user'):
            return False

        upload_read_meta = {
            'admin': {
                'set__admin_read_status': 'read'
            },
            'user': {
                'set__user_read_status': 'read',
                'inc__click_count': 1,
                'set__user_read_time': datetime.datetime.now()
            },
        }

        FeedResult.objects(feed=feed_oid,
                           resume=resume_oid,
                           user_read_status='read').update(inc__click_count=1)
        FeedResult.objects(
            feed=feed_oid,
            resume=resume_oid,
            user_read_status='unread',
        ).update(**upload_read_meta[read_user])
        return True
Exemple #3
0
    def add_candidate_extra_info(self, candidate_list):
        resume_oid_list = [get_oid(i.resume_id) for i in candidate_list if get_oid(i.resume_id)]
        resume_data = ResumeData.objects.filter(
            id__in=resume_oid_list,
        ).only(
            'job_target',
            'works',
            'address',
            'source',
            'update_time',
        )
        resume_data_dict = {
            str(r.id): r
            for r in resume_data
        }
        for candidate in candidate_list:
            resume_id = candidate.resume_id
            resume_data = resume_data_dict.get(resume_id)

            if not resume_data:
                continue

            candidate.work = self.get_candidate_work(
                resume_data,
            )
            candidate.job_target = self.get_candidate_job_target(
                resume_data,
            )
            candidate.address = resume_data.address
            candidate.update_time = resume_data.update_time
        return candidate_list
Exemple #4
0
    def add_candidate_extra_info(self, candidate_list):
        resume_oid_list = [
            get_oid(i.resume_id) for i in candidate_list
            if get_oid(i.resume_id)
        ]
        resume_data = ResumeData.objects.filter(id__in=resume_oid_list, ).only(
            'job_target',
            'works',
            'address',
            'source',
            'update_time',
        )
        resume_data_dict = {str(r.id): r for r in resume_data}
        for candidate in candidate_list:
            resume_id = candidate.resume_id
            resume_data = resume_data_dict.get(resume_id)

            if not resume_data:
                continue

            candidate.work = self.get_candidate_work(resume_data, )
            candidate.job_target = self.get_candidate_job_target(resume_data, )
            candidate.address = resume_data.address
            candidate.update_time = resume_data.update_time
        return candidate_list
Exemple #5
0
 def set_display_count(self, feed_result):
     feed_list = feed_result['data']
     feed_result_oid_list = [
         get_oid(fr['id']) for fr in feed_list if get_oid(fr.get('id'))
     ]
     result = FeedResult.objects(id__in=feed_result_oid_list).update(
         inc__display_count=1)
     return result
 def get_feed_result(cls, feed_id, resume_id):
     feed_oid = get_oid(feed_id)
     resume_oid = get_oid(resume_id)
     if not feed_oid or not resume_oid:
         return False
     feed_result = FeedResult.objects.filter(
         feed=feed_oid,
         resume=resume_oid,
     ).first()
     return feed_result
Exemple #7
0
    def post(self, request):
        publish_all = request.POST.get('publish_all')
        if publish_all:
            return self.publish_all(request)

        feed_sid = request.POST.get('feed_id', '')
        resume_sids = request.POST.getlist('resume_ids[]', [])
        display_time_str = request.POST.get('pub_time', '')

        feed_id = get_oid(feed_sid)

        if not feed_id:
            return JsonResponse({
                'status': 'error',
                'msg': u'没有订阅',
            })

        if not resume_sids:
            return JsonResponse({
                'status': 'error',
                'msg': u'请选择要发布的简历',
            })

        now = datetime.datetime.now()
        display_time = self.convert_display_time(display_time_str)
        resume_oids = [get_oid(resume_id) for resume_id in resume_sids]
        admin = request.user

        # 发布数据
        FeedResult.objects(
            feed=feed_id,
            resume__in=resume_oids,
        ).update(
            set__published=True,
            set__display_time=display_time,
            set__pub_time=now,
            set__publisher=admin.username,
        )

        # 添加cls_score,如果没有这个字段设置为100
        FeedResult.objects(
            feed=feed_id,
            resume__in=resume_oids,
            score__cls_score=None,
        ).update(set__score__cls_score=100, )

        self.add_pub_data(feed_id, resume_oids, display_time)
        self.add_email_data(feed_id, resume_oids)
        FeedCacheUtils.add_feed_id_update_cache(feed_sid)

        return JsonResponse({
            'status': 'ok',
            'msg': u'已成功发布%s条订阅' % len(resume_oids),
        })
Exemple #8
0
def get_resume_mapper(resume_id_list):
    resume_oid_list = [
        get_oid(resume_id) for resume_id in resume_id_list
        if get_oid(resume_id)
    ]
    resume_data_query = ResumeData.objects.filter(
        id__in=resume_oid_list, ).only('works', )
    mapper = {}
    for resume_data in resume_data_query:
        works = resume_data.works
        resume_id = str(resume_data.id)
        work = works[0] if works else None
        mapper[resume_id] = work.position_title if work else ''
    return mapper
Exemple #9
0
def get_resume_mapper(resume_id_list):
    resume_oid_list = [get_oid(resume_id) for resume_id in resume_id_list if get_oid(resume_id)]
    resume_data_query = ResumeData.objects.filter(
        id__in=resume_oid_list,
    ).only(
        'works',
    )
    mapper = {}
    for resume_data in resume_data_query:
        works = resume_data.works
        resume_id = str(resume_data.id)
        work = works[0] if works else None
        mapper[resume_id] = work.position_title if work else ''
    return mapper
    def get_update_resume(cls, resume_id):
        resume_oid = get_oid(resume_id)
        if not resume_oid:
            return False

        update_resume = ResumeData.objects.filter(id=resume_oid, ).first()
        return update_resume
Exemple #11
0
    def get(self, request, feed_id):
        if self.is_malice_user(feed_id):
            return JsonResponse({
                'status': 'error',
                'msg': u'你的请求有误,查询失败',
            })

        feed_oid = get_oid(feed_id)
        user_feed = UserFeed2.objects(
            feed=feed_oid,
            is_deleted=False,
        ).first()

        if not (user_feed and self.feed_expire_status(user_feed.feed)):
            return JsonResponse({'status': 'ok', 'msg': u'订阅未过期,不需要重置'})
        feed_expire_time = after7day()
        Feed2.objects(id=feed_oid).update(
            set__feed_expire_time=feed_expire_time)
        Feed.objects.filter(feed_obj_id=feed_id).update(
            feed_expire_time=feed_expire_time)
        CeleryUtils.user_feed_task(feed_id)

        return JsonResponse({
            'status': 'ok',
            'msg': u'设置成功',
        })
Exemple #12
0
    def get_reco_feed_results(self, resume_id):
        '''
        显示未发布的定制
        '''
        resume_oid = get_oid(resume_id)
        feed_results = FeedResult.objects.filter(
            is_recommended=True,
            published=False,
            resume=resume_oid,
            resume_source__ne='talent_partner',
        ).only(
            'id',
            'feed',
            'calc_time',
            'admin',
            'watch',
            'download',
        ).order_by('-calc_time').limit(30).no_cache().select_related()
        feed_results = [i for i in feed_results if hasattr(i.feed, 'username')]

        username_list = [i.feed.username for i in feed_results]
        users = list(User.objects.filter(
            username__in=username_list,
        ).values(
            'username',
            'first_name',
        ))
        company_mapper = {
            i['username']: i['first_name']
            for i in users
        }
        for fr in feed_results:
            fr.company_name = company_mapper.get(fr.feed.username, fr.feed.username)

        return feed_results
Exemple #13
0
    def get(self, request, record_id):
        buy_record = self.get_buy_record(record_id)

        resume_id = buy_record.resume_id
        resume_oid = get_oid(resume_id)

        mark_choices = self.get_mark_choices(buy_record)
        mark_logs = self.get_mark_logs(buy_record)
        contact_info = get_object_or_none(
            ContactInfoData,
            resume_id=resume_id,
        )
        resume_info = ResumeData.objects.filter(id=resume_oid, ).first()
        referer_url = self.get_referer_url()

        return render(
            request,
            self.template_name,
            {
                'contact_info': contact_info,
                'resume_info': resume_info,
                'mark_choices': mark_choices,
                'mark_logs': mark_logs,
                'referer_url': referer_url,
                'buy_record': buy_record,
            },
        )
    def update_today_cache(cls):
        update_feed_id_list = cache.get(cls.update_cache_key, [])
        today = get_today()
        tomorrow = get_tomommow()

        has_update_feed_list = []

        for feed_id in update_feed_id_list:
            feed_oid = get_oid(feed_id)
            today_cache_key = feed_id + '_today_cache'
            today_cache_value = cache.get(today_cache_key, [])

            feed_results = FeedResult.objects(
                feed=feed_oid,
                display_time__gte=today,
                display_time__lt=tomorrow,
            )
            resume_ids = [str(fr.resume.id) for fr in feed_results]
            if resume_ids:
                today_cache_value = list(
                    set(today_cache_value) | set(resume_ids))
                cache.set(today_cache_key, today_cache_value, timeout=0)
                has_update_feed_list.append(feed_id)

        not_update_feed_list = list(
            set(update_feed_id_list) - set(has_update_feed_list))
        cache.set(cls.update_cache_key, not_update_feed_list, timeout=0)
Exemple #15
0
 def search_result(self, feed_id):
     request = self.request
     start = get_int(self.request.GET.get('start', 0))
     read_id_list = UserReadResume.objects.filter(
         user=request.user, feed_id=str(feed_id)).values_list('resume_id')
     read_id_list = set([get_oid(res[0]) for res in read_id_list if res])
     return feed_group_search_ajax(start, feed_id, read_id_list)
    def get(self, request, record_id):
        buy_record = self.get_buy_record(record_id)

        resume_id = buy_record.resume_id
        resume_oid = get_oid(resume_id)

        mark_choices = self.get_mark_choices(buy_record)
        mark_logs = self.get_mark_logs(buy_record)
        contact_info = get_object_or_none(
            ContactInfoData,
            resume_id=resume_id,
        )
        resume_info = ResumeData.objects.filter(
            id=resume_oid,
        ).first()
        referer_url = self.get_referer_url()

        return render(
            request,
            self.template_name,
            {
                'contact_info': contact_info,
                'resume_info': resume_info,
                'mark_choices': mark_choices,
                'mark_logs': mark_logs,
                'referer_url': referer_url,
                'buy_record': buy_record,
            },
        )
Exemple #17
0
    def deactive_feed(self, user_vip):
        now = datetime.datetime.now()
        user_charge_pack = get_object_or_none(
            UserChargePackage,
            user=user_vip.user,
            package_type=2,
            feed_package__name='会员定制',
            pkg_source=1,
        )

        user_charge_pack.extra_feed_num = user_vip.item.feed_count
        user_charge_pack.rest_feed = user_vip.item.feed_count
        user_charge_pack.save()

        user_feeds = UserFeed.objects.select_related('feed').filter(
            user_charge_pkg=user_charge_pack, is_deleted=False)
        feed_ids = [user_feed.feed.id for user_feed in user_feeds]
        feed_obj_ids = [
            get_oid(user_feed.feed.feed_obj_id) for user_feed in user_feeds
        ]
        user_feeds.update(expire_time=now)
        Feed.objects.filter(id__in=feed_ids).update(expire_time=now)

        Feed2.objects.filter(id__in=feed_obj_ids).update(set__expire_time=now)

        UserFeed2.objects.filter(feed__in=feed_obj_ids).update(
            set__expire_time=now)
        return True
Exemple #18
0
    def get_feed_hitstory(self, resume_id):

        feed_results = FeedResult.objects.filter(
            resume=get_oid(str(resume_id)),
            published=True,
            is_recommended=True,
        )

        feed_ids = [str(feed.feed.id) for feed in feed_results]

        buy_records = ResumeBuyRecord.objects.filter(
            feed_id__in=feed_ids
        )

        buy_record_ids = [str(buy_record.feed_id)
                          for buy_record in buy_records]

        feed_results_list = []

        for ret in feed_results:
            feed_doc = {}
            if not isinstance(ret.feed, Feed2):
                continue
            company_name_query = User.objects.filter(
                username=ret.feed.username
            ).first()
            company_name = " " if not company_name_query else company_name_query.first_name

            feed_doc['company_name'] = company_name
            feed_doc['admin'] = ret.admin
            feed_doc['job'] = ret.feed.keywords
            feed_doc['pub_time'] = ret.pub_time
            feed_doc['is_clicked'] = False
            feed_doc['is_down'] = False
            feed_doc['is_interview'] = False
            feed_doc['is_enter'] = False
            feed_id = str(ret.feed.id)

            if ret.click_count >= 1:
                feed_doc['is_clicked'] = True

            if feed_id in buy_record_ids:
                feed_doc['is_down'] = True
                feed_doc['is_clicked'] = True

            buy_record = ResumeBuyRecord.objects.filter(
                resume_id=str(ret.resume.id),
                user__username=ret.feed.username
            ).first()
            if hasattr(buy_record, 'resume_mark'):

                if buy_record.resume_mark.has_interview:
                    feed_doc['is_interview'] = True
                if buy_record.resume_mark.current_mark.code_name == 'entry':
                    feed_doc['is_enter'] = True

            feed_results_list.append(feed_doc)

        return feed_results_list
Exemple #19
0
 def add_reco_count(self, candidate_list):
     resume_oid_list = [get_oid(i.resume_id) for i in candidate_list if get_oid(i.resume_id)]
     feed_results = FeedResult.objects.filter(
         is_recommended=True,
         published=False,
         resume__in=resume_oid_list,
         resume_source__ne='talent_partner',
     ).only(
         'resume',
     ).order_by('-job_related').no_cache().no_dereference()
     reco_list = [str(i.resume.id) for i in feed_results]
     reco_mapper = {
         key: reco_list.count(key)
         for key in reco_list
     }
     for i in candidate_list:
         i.reco_count = reco_mapper.get(i.resume_id, 0)
Exemple #20
0
    def get_feed_list(self, feed_id):
        feed_id = get_oid(feed_id)

        if not feed_id:
            return []

        page = get_int(self.request.GET.get('start', '0'))
        if page < 0:
            page = 0

        query_cond = self.get_query_cond()
        query_cond.update({'feed': feed_id})

        feed_result_list = FeedResult.objects(
            resume_source__ne='talent_partner',
            **query_cond).only(*self.only_fields).skip(
                self.page_count * page).limit(self.page_count).order_by(
                    *self.get_sort_cond()).select_related()

        feed_result_dict_list = []
        for f in feed_result_list:
            try:
                work_years = f.resume.get_work_years()
                feed_dict = mongo_to_dict(f, [])
                feed_result_dict_list.append(feed_dict)
                feed_dict['resume']['work_years'] = work_years
            except AttributeError:
                # 处理由于删除重复简历,导致的推荐结果缺失问题
                django_log.error('resume not exists %s' % f.resume.id)
                continue

        feed_query_count = FeedResult.objects(**query_cond).count()

        tomorrow = get_tomommow()
        total_count = 13 * FeedResult.objects(feed=feed_id).count()
        total_recommend_count = FeedResult.objects(
            feed=feed_id,
            published=True,
            is_recommended=True,
            display_time__lt=tomorrow,
        ).count()

        newest_recommend_count = FeedResult.objects(
            feed=feed_id,
            user_read_status__ne='read',
            published=True,
        ).count()

        return {
            'start': page,
            'next_start': page + 1 if feed_result_dict_list else -1,
            'data': feed_result_dict_list,
            'total_recommend_count': total_recommend_count,
            'total_count': total_count,
            'newest_recommend_count': newest_recommend_count,
            'feed_query_count': feed_query_count,
        }
    def get_update_resume(cls, resume_id):
        resume_oid = get_oid(resume_id)
        if not resume_oid:
            return False

        update_resume = ResumeData.objects.filter(
            id=resume_oid,
        ).first()
        return update_resume
Exemple #22
0
    def get_query_advance(self, query_cond):
        work_years = self.get_advance_work_years()
        degree = self.get_advance_degree()
        gender = self.get_advance_gender()
        age = self.get_advance_age()
        current_area = self.get_current_area()
        salary = self.get_advance_salary()

        not_query_advance = (not work_years and not degree and not gender
                             and not age and not current_area and not salary)
        if not_query_advance:
            return query_cond

        feed_oid = get_oid(self.kwargs.get('feed_id'))
        feed_resumes = list(
            FeedResult.objects.filter(
                feed=feed_oid,
                published=True,
                is_recommended=True,
            ).order_by('-display_time').limit(500).only('resume').as_pymongo())
        ids_list = [str(i['resume']) for i in feed_resumes]

        search_params = {
            'work_years': work_years,
            'degree': degree,
            'gender': gender,
            'age': age,
            'current_area': current_area,
            'salary': salary,
            'size': 100,
            'ids_list': ','.join(ids_list),
        }
        result = ParseUtils.search_resume(search_params)
        resume_data = result.get('data', {}).get('results', [])

        if result.get('status') != 'ok':
            return query_cond

        query_cond.update({
            'resume__in':
            [get_oid(i['id']) for i in resume_data if i.get('id')]
        })

        return query_cond
Exemple #23
0
    def get_resume(self):
        resume_id = self.kwargs.get('resume_id', '')
        resume_oid = get_oid(resume_id)
        if not resume_oid:
            raise Http404
        resume = ResumeData.objects.filter(id=resume_oid).first()

        if not resume:
            raise Http404
        return resume
    def is_user_feed(cls, user, feed_id):
        feed_oid = get_oid(feed_id)
        if not feed_oid:
            return False

        feed = Feed.objects.filter(
            user=user,
            feed_obj_id=feed_oid,
        ).first()
        return feed
Exemple #25
0
    def is_malice_user(self, feed_id):
        username = self.request.user.username
        feed_oid = get_oid(feed_id)

        user_feed = UserFeed2.objects(
            username=username,
            feed=feed_oid,
            is_deleted=False,
        )
        return False if user_feed else True
    def get_resume(self):
        resume_id = self.kwargs.get('resume_id', '')
        resume_oid = get_oid(resume_id)
        if not resume_oid:
            raise Http404
        resume = ResumeData.objects.filter(id=resume_oid).first()

        if not resume:
            raise Http404
        return resume
Exemple #27
0
    def check_feed_display(self, feed_id):
        username = self.request.user.username
        feed_oid = get_oid(feed_id)

        if not feed_oid:
            return False

        user_feed = UserFeed2.objects(
            username=username,
            feed=feed_oid,
        ).first()
        return user_feed
def main():
    resume_sid_list = list(
        ContactInfoData.objects.filter(source='brick', ).values_list(
            'resume_id',
            flat=True,
        ))
    resume_oid_list = [get_oid(i) for i in resume_sid_list]

    ResumeData.objects.filter(id__in=resume_oid_list).update(
        set__source='brick', )
    FeedResult.objects.filter(resume__in=resume_oid_list).update(
        set__feed_source='brick', )
    def add_feed_result(cls, feed_id, resume_id, source='pinbot', admin=''):
        now = datetime.datetime.now()
        feed_oid = get_oid(feed_id)
        resume_oid = get_oid(resume_id)

        if not feed_oid or not resume_oid:
            return False

        feed_result = FeedResult.objects.filter(
            feed=feed_oid,
            resume=resume_oid,
        ).first()

        if feed_result:
            feed_result.published = True
            feed_result.is_recommended = True
            feed_result.display_time = now
            feed_result.feed_source = source
            feed_result.pub_time = now
            feed_result.score['cls_score'] = 100
            if feed_result.resume_source:
                feed_result.resume_source = 'accept' + feed_result.resume_source
            if admin:
                feed_result.admin = admin
            feed_result.save()
            return feed_result

        feed_result = FeedResult(
            feed=feed_oid,
            resume=resume_oid,
            is_recommended=True,
            published=True,
            display_time=now,
            pub_time=now,
            admin=admin,
            feed_source=source,
        )
        feed_result.score['cls_score'] = 100
        feed_result.save()
        return feed_result
Exemple #30
0
    def set_feed_time(self, feed_id):
        now = datetime.datetime.now()
        feed_oid = get_oid(feed_id)
        feed_expire_time = after7day()

        Feed2.objects(id=feed_oid).update(
            set__last_click_time=now,
            set__feed_expire_time=feed_expire_time,
        )
        Feed.objects.filter(feed_obj_id=str(feed_id)).update(
            last_click_time=now,
            feed_expire_time=feed_expire_time,
        )
        return True
Exemple #31
0
    def del_tag(self, resume_id, tag_names, tag_ids):

        # 写入mongodb数据
        tag_list = [{'name': tag_name} for tag_name in tag_names]

        ResumeData.objects(id=get_oid(resume_id)).update(
            pull_all__tags=tag_list)

        # 写入mysql数据
        candidate_obj = self.get_candidate_by_resume_id(
            resume_id=str(resume_id))
        candidate_obj.tags.remove(*tag_ids)
        candidate_obj.save()

        return True
Exemple #32
0
    def get(self, request, feed_id):
        feed_id = str(get_oid(feed_id))
        if not feed_id:
            return JsonResponse({
                'status': 'form_error',
                'msg': '请选择正确的定制数据',
            })

        ret = CeleryUtils.admin_send_reco_task(feed_id)

        return JsonResponse({
            'status': 'ok',
            'msg': 'ok',
            'task_id': ret.task_id,
        })
Exemple #33
0
    def update_status(self, resume_id, job_status, admin=''):

        admin_time = datetime.datetime.now()
        ResumeData.objects.filter(
            id=get_oid(resume_id)
        ).update(
            set__job_target__job_hunting_state=job_status,
            set__admin=admin,
            set__admin_time=admin_time,
        )

        candidate_obj = self.get_candidate_by_resume_id(resume_id)
        candidate_obj.has_contact = True
        candidate_obj.save()

        return True
 def is_send_resume(cls, user, resume_id):
     username = user.username
     resume_oid = get_oid(resume_id)
     feed_id_list = [
         i.id for i in list(
             Feed2.objects.filter(
                 deleted=False,
                 username=username,
             ).only('id', 'username'))
     ]
     has_send = FeedResult.objects.filter(
         feed__in=feed_id_list,
         resume=resume_oid,
         feed_source='brick',
     )
     return True if has_send else False
Exemple #35
0
    def add_tag(self, resume_id, tag_names, tag_ids):

        # 写入mongodb数据
        tag_list = [{'name': tag_name} for tag_name in tag_names]

        ResumeData.objects.filter(id=get_oid(resume_id)).update(
            add_to_set__tags=tag_list)

        # 写入mysql数据
        candidate_obj = self.get_candidate_by_resume_id(
            resume_id=str(resume_id))
        candidate_obj.tags.clear()
        candidate_obj.tags.add(*tag_ids)
        candidate_obj.has_contact = True
        candidate_obj.save()
        return True
Exemple #36
0
    def get_context_data(self, *args, **kwargs):
        context = super(ResumeBuyRecordList,
                        self).get_context_data(*args, **kwargs)
        record_list = context.get('record_list', [])

        for r in list(record_list):
            resume_id = r.resume_id
            resume_oid = get_oid(resume_id)
            resume_info = ResumeData.objects.filter(id=resume_oid).first()
            contact_info = get_object_or_none(
                ContactInfoData,
                resume_id=resume_id,
            )
            r.resume_info = resume_info
            r.contact_info = contact_info
        return context
def main():
    mysql_feeds = Feed.objects.filter(
        feed_type=1,
        deleted=False,
        update_time__gt=start_time,
    )

    for feed in mysql_feeds:
        feed_oid = get_oid(feed.feed_obj_id)
        keywords = feed.keywords
        analyze_titles = feed.analyze_titles

        Feed2.objects.filter(id=feed_oid).update(
            set__keywords=keywords,
            set__analyze_titles=analyze_titles
        )
        print feed.feed_obj_id, 'update success'
Exemple #38
0
    def del_tag(self, resume_id, tag_names, tag_ids):

        # 写入mongodb数据
        tag_list = [{'name': tag_name}for tag_name in tag_names]

        ResumeData.objects(
            id=get_oid(resume_id)
        ).update(
            pull_all__tags=tag_list
        )

        # 写入mysql数据
        candidate_obj = self.get_candidate_by_resume_id(resume_id=str(resume_id))
        candidate_obj.tags.remove(*tag_ids)
        candidate_obj.save()

        return True
Exemple #39
0
    def add_tag(self, resume_id, tag_names, tag_ids):

        # 写入mongodb数据
        tag_list = [{'name': tag_name} for tag_name in tag_names]

        ResumeData.objects.filter(
            id=get_oid(resume_id)
        ).update(
            add_to_set__tags=tag_list
        )

        # 写入mysql数据
        candidate_obj = self.get_candidate_by_resume_id(resume_id=str(resume_id))
        candidate_obj.tags.clear()
        candidate_obj.tags.add(*tag_ids)
        candidate_obj.has_contact = True
        candidate_obj.save()
        return True
    def get_context_data(self, *args, **kwargs):
        context = super(ResumeBuyRecordList, self).get_context_data(
            *args, **kwargs)
        record_list = context.get('record_list', [])

        for r in list(record_list):
            resume_id = r.resume_id
            resume_oid = get_oid(resume_id)
            resume_info = ResumeData.objects.filter(
                id=resume_oid
            ).first()
            contact_info = get_object_or_none(
                ContactInfoData,
                resume_id=resume_id,
            )
            r.resume_info = resume_info
            r.contact_info = contact_info
        return context
    def update_mongo_feed(self, mysql_feed):
        feed_oid = get_oid(mysql_feed.feed_obj_id)
        mongo_feed = Feed2.objects.filter(id=feed_oid).first()
        now = datetime.datetime.now()

        if not mongo_feed.title:
            mongo_feed.title = self.data.get('title', '')
        mongo_feed.keywords = self.data['keywords']
        mongo_feed.analyze_titles = self.data['analyze_titles']
        mongo_feed.talent_level = self.data['talent_level']
        mongo_feed.job_desc = self.data['job_desc']
        mongo_feed.salary_min = self.data['salary_min']
        mongo_feed.salary_max = self.data['salary_max']
        mongo_feed.job_domain = [i.category for i in self.data['job_domain']]
        mongo_feed.job_welfare = self.data['job_welfare'].split(',') if self.data['job_welfare'] else []
        mongo_feed.company_prefer = [i.name for i in self.data['company_prefer']]
        mongo_feed.update_time = now
        mongo_feed.calced = False
        return mongo_feed
def main():
    resume_sid_list = list(ContactInfoData.objects.filter(
        source='brick',
    ).values_list(
        'resume_id',
        flat=True,
    ))
    resume_oid_list = [get_oid(i) for i in resume_sid_list]

    ResumeData.objects.filter(
        id__in=resume_oid_list
    ).update(
        set__source='brick',
    )
    FeedResult.objects.filter(
        resume__in=resume_oid_list
    ).update(
        set__feed_source='brick',
    )
    def deactive_feed(self, user_vip):
        now = datetime.datetime.now()
        user_charge_pack = get_object_or_none(
            UserChargePackage,
            user=user_vip.user,
            package_type=2,
            feed_package__name='会员定制',
            pkg_source=1,
        )

        user_charge_pack.extra_feed_num = user_vip.item.feed_count
        user_charge_pack.rest_feed = user_vip.item.feed_count
        user_charge_pack.save()

        user_feeds = UserFeed.objects.select_related('feed').filter(
            user_charge_pkg=user_charge_pack,
            is_deleted=False
        )
        feed_ids = [user_feed.feed.id for user_feed in user_feeds]
        feed_obj_ids = [get_oid(user_feed.feed.feed_obj_id) for user_feed in user_feeds]
        user_feeds.update(
            expire_time=now
        )
        Feed.objects.filter(
            id__in=feed_ids
        ).update(
            expire_time=now
        )

        Feed2.objects.filter(
            id__in=feed_obj_ids
        ).update(
            set__expire_time=now
        )

        UserFeed2.objects.filter(
            feed__in=feed_obj_ids
        ).update(
            set__expire_time=now
        )
        return True
    def get_feed(self):
        feed_id = self.kwargs.get('feed_id', '')
        feed_oid = get_oid(feed_id)

        if not feed_oid:
            return JsonResponse({
                'status': 'no_feed_id',
                'msg': 'no feed id',
            })

        username = self.request.user.username
        self.feed = Feed2.objects.filter(
            id=feed_oid,
            username=username,
        ).first()

        if not self.feed:
            return JsonResponse({
                'status': 'feed_not_found',
                'msg': 'feed not found',
            })
        return self.feed
def update_contactinfo_data():

    all_repeat_data = ContactInfoData.objects.raw(
        """
        select id,name,phone,source,email,count(*) from resumes_contactinfo
        where phone is not null
        group by name,phone,email,source having count(*) > 1
        """
    )
    for data in all_repeat_data:
        piece_repeat_data = ContactInfoData.objects.filter(
            name=data.name,
            phone=data.phone,
            email=data.email,
            source=data.source,
        )
        for repeat_data in piece_repeat_data:
            resume_id = get_oid(repeat_data.resume_id)
            if resume_id and not ResumeData.objects.filter(
                id=resume_id
            ):
                ContactInfoData.objects.filter(
                    resume_id=repeat_data.resume_id
                ).delete()
    def save_upload_resume(cls, contact_dict, parse_resume):
        now = datetime.datetime.now()

        resume = ResumeData(
            id=get_oid(parse_resume.get('resume_id', '')),
            name=contact_dict.get('name', ''),
            email=contact_dict.get('email', ''),
            phone=contact_dict.get('phone', ''),
            age=get_int(contact_dict.get('age', 0)),
            gender=contact_dict.get('gender', ''),
            birthday=contact_dict.get('birthday', ''),
            residence=contact_dict.get('residence', ''),
            address=parse_resume.get('address', ''),
            work_years=parse_resume.get('work_years', ''),
            job_target=parse_resume.get('job_target', {}),
            educations=parse_resume.get('educations', []),
            works=parse_resume.get('works', []),
            projects=parse_resume.get('projects', []),
            trains=parse_resume.get('trains', []),
            professional_skills=parse_resume.get('professional_skills', []),
            self_evaluation=parse_resume.get('self_evaluation', ''),
            created_at=parse_resume.get('created_at', now),
            updated_at=parse_resume.get('updated_at', now),
            created_time=parse_resume.get('created_time', now),
            update_time=parse_resume.get('update_time', now.strftime('%Y-%m-%d')),
            source=parse_resume.get('source', ''),
            owner=parse_resume.get('owner', ''),
            last_contact=parse_resume.get('last_contact', ''),
            hr_evaluate=parse_resume.get('hr_evaluate', ''),
            source_id=parse_resume.get('source_id') or parse_resume.get('resume_id', ''),
            view_id=parse_resume.get('view_id') or parse_resume.get('resume_id', ''),
            url_id=parse_resume.get('url_id') or parse_resume.get('resume_id', ''),
            url='http://pinbot.me/resumes/display/{0}/'.format(parse_resume.get('resume_id', '')),
        )
        resume.save()
        return resume
Exemple #47
0
    def get_resume_info(self, resume_id):

        ret = ResumeData.objects.filter(id=get_oid(resume_id)).first()
        return ret
Exemple #48
0
    def get(self, request, download_type, resume_id):
        resume_oid = get_oid(resume_id)

        if not resume_oid:
            raise Http404

        user = request.user
        request_dict = {
            key: True if get_int(value) else False
            for key, value in request.GET.items() if key in ('name', 'contact_info', 'salary')
        }

        resume = ResumeData.objects.filter(
            id=resume_oid,
        ).first()
        has_buy_resume = ResumeBuyRecord.objects.filter(
            user=user,
            resume_id=resume_id,
            status='LookUp'
        )
        is_pinbot_staff = user.is_staff
        show_contact_info = has_buy_resume or is_pinbot_staff
        contact_info = get_object_or_none(
            ContactInfoData,
            resume_id=resume_id,
        )

        filename = self.get_filename(contact_info, resume)
        resume_href = self.request.build_absolute_uri(
            reverse('resume-display-resume', args=(resume.id, 0))
        )
        context_data = {
            'download_type': download_type,
            'resume': resume,
            'contact_info': contact_info,
            'show_contact_info': show_contact_info,
            'resume_href': resume_href,
            'is_pinbot_staff': is_pinbot_staff,
            'request_dict': request_dict,
        }

        if download_type == 'pdf':
            filename = '%s.pdf' % filename
            context_data['assert_url'] = self.pdf_assert_path
            context_data['pdf_type'] = True
            response = PDFUtils.download_pdf(
                self.template,
                filename=filename,
                context_data=context_data,
            )
            return response
        else:
            filename = '%s.html' % filename
            html_assert_url = self.request.build_absolute_uri(
                STATIC_URL
            )

            context_data['assert_url'] = html_assert_url
            html_file = render_to_string(
                self.template,
                context_data,
            )
            response = HttpResponse(
                html_file,
                content_type='application/octet-stream',
            )
            response[
                'Content-Disposition'] = 'attachment; filename=%s' % filename
            return response
Exemple #49
0
    def startProcess(self, p, request):
        http_refer = request.META.get('HTTP_REFERER', None)
        token = p.get('token', '')
        interest = p.get('interest', 'true')
        brick = p.get('brick', '')
        if interest == 'true':
            interest = 1
            self.template_name = 'agree.html'
        else:
            interest = 2
            self.template_name = 'disagree.html'

        detail_id = get_oid(token)
        if detail_id is None:
            raise Http404()

        to_email = ''
        detail = get_object_or_none(MarketEmailSendDetail, id=detail_id)
        if detail is None:
            raise Http404()
        else:
            to_email = detail.to_email
            detail.user_request = str(request)
            detail.click_time = datetime.now()
            card_job_id = detail.info_dict.get('card_job_id', '0')
            detail.save()

        if not http_refer and brick != 'true':
            self.template_name = 'confirm.html'
            return render(
                request,
                self.template_name,
                locals()
            )

        send_infos = SendCompanyCard.objects.filter(
            feedback_status=0, to_email=detail.to_email, job_id=int(detail.info_dict['job_id']))
        if len(send_infos) >= 1:
            send_info = send_infos[0]

            time_elapse_days = (datetime.now() - send_info.send_time).days
            if time_elapse_days >= COMPANY_CARD_EXPIRE_DAY:
                return render(
                    request,
                    self.template_name
                )

            send_info.feedback_status = interest
            send_info.feedback_time = datetime.now()
            if interest == 1:
                result = buy_resume(
                    user=send_info.send_user, resume_id=send_info.resume_id, send_record=send_info, feed_id=send_info.feed_id)
                if result:
                    send_info.points_used = 12
                    send_info.download_status = True
                else:
                    send_info.download_status = False

            send_info.save()
            JobUtils.company_card_interest(
                send_info.job, card_job_id, interest)

        return render(
            request,
            self.template_name,
            locals()
        )
Exemple #50
0
def return_secret_points(request, bought_id):
    """
    @summary:
        简历信息设置为保密,管理员下载时,发现这个情况后就
    # 1.将该条购买记录更改为保密状态,xadmin操作链接.
    # 2. 套餐积点加回去,加到返还点数里,并且已购买此简历的用户会在管理员确认后看见返还点数
    # 3. 把这个信息存储到联系人信息表,后续查看此简历的客户不能看到下载和反馈按钮
    """
    resumes_buy_recds = ResumeBuyRecord.objects.filter(
        id=int(bought_id),
        status='Start',
    )

    if resumes_buy_recds and request.user.is_staff:
        now = datetime.now()
        # 1.将该条购买记录更改为保密状态
        buy_recd = resumes_buy_recds[0]
        resume_id = buy_recd.resume_id
        buy_recd.status = 'Secret'
        buy_recd.finished_time = now
        buy_recd.save()

        data = ''

        resume_oid = get_oid(buy_recd.resume_id)
        ResumeData.objects.filter(
            id=resume_oid,
        ).update(
            set__is_secret=True,
        )

        user = buy_recd.user
        # 2. 套餐积点加回去,加到返还点数里
        # 套餐为基础套餐,服务未到期,并且已付款
        user_base_pkgs = UserChargePackage.objects.filter(user=user, package_type=1,
                                                          resume_end_time__gte=datetime.now(),
                                                          pay_status='finished'
                                                          ).order_by('-start_time')

        current_vip = VipRoleUtils.get_current_vip(user)
        if user_base_pkgs:
            base_pkg = user_base_pkgs[0]
            base_pkg.re_points += 10
            base_pkg.save()
            data += '已返还10点 到套餐'
        elif current_vip:
            point_utils.secret_return(user)
        else:
            data += '套餐不满足(有基础套餐,服务未到期,已付款)之一'


        # 3. 把这个信息存储到联系人信息表
        contact_infos = ContactInfoData.objects.filter(resume_id=resume_id)
        if contact_infos:
            data += ' 联系信息已存在'
        else:
            ContactInfoData(resume_id=resume_id, status='secret', \
                            name='保密', source='', \
                            email=' ', \
                            source_id=''
                            ).save()
            data += ' 新建了该简历联系信息保密'

        json_data = json.dumps({'status':'ok', 'data':data})
    else:
        json_data = json.dumps({'status':'ok', 'data':'没有该购买,或者你不是管理员'})

    return HttpResponse(json_data, 'application/json')