Example #1
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'设置成功',
        })
Example #2
0
 def setUp(self):
     user = User.objects.create_user(
         '*****@*****.**',
         '*****@*****.**',
         '123456'
     )
     self.feed = Feed.objects.create(
         salary_min=1000,
         salary_max=21500,
         skill_required='fdsafdsakjfklsafjdsakfdj',
         expect_area='北京,成都,上海',
         talent_level='初级',
         job_type='fdsafdsf',
         keywords='fdsafjdkaslfj',
         title='fdasfjdkasfj',
         job_desc='fdsafjkdlsajfdklafj',
         feed_obj_id='55a878df8230dbfce1130553',
         user=user,
         feed_expire_time=after7day(),
         expire_time=after7day(),
     )
Example #3
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
Example #4
0
    def create_mongo_feed(self, feed_pkg):
        mongo_feed = Feed2()
        mongo_feed._data = deepcopy(self.data)
        mongo_feed.username = self.user.username
        mongo_feed.deleted = False
        mongo_feed.remarks = []
        mongo_feed.ignored = False
        mongo_feed.feed_type = 1
        mongo_feed.display = True
        mongo_feed.add_time = datetime.datetime.now()
        mongo_feed.feed_expire_time = after7day()
        mongo_feed.expire_time = feed_pkg.feed_end_time

        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']]
        return mongo_feed
Example #5
0
    def create_mongo_feed(self, feed_pkg):
        mongo_feed = Feed2()
        mongo_feed._data = deepcopy(self.data)
        mongo_feed.username = self.user.username
        mongo_feed.deleted = False
        mongo_feed.remarks = []
        mongo_feed.ignored = False
        mongo_feed.feed_type = 1
        mongo_feed.display = True
        mongo_feed.add_time = datetime.datetime.now()
        mongo_feed.feed_expire_time = after7day()
        mongo_feed.expire_time = feed_pkg.feed_end_time

        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']
        ]
        return mongo_feed
Example #6
0
class Feed2(Document):
    """
    @summary: 所有订阅内容
    """
    keywords = StringField(default='')
    job_type = StringField(default='')  # 工作类型
    talent_level = StringField(default='')  # 人才级别
    expect_area = StringField(default='')  # 期望工作地
    job_desc = StringField(default='')  # 职位描述

    deleted = mongoengine.BooleanField(default=False)
    add_time = mongoengine.DateTimeField(default=datetime.now())
    delete_time = mongoengine.DateTimeField(default=datetime.now())
    expire_time = mongoengine.DateTimeField(required=False)
    calced = mongoengine.BooleanField(default=False, )

    username = StringField(default='')
    # 最新增加对于每个订阅职位的理解,更好辅助算法.
    remarks = ListField(EmbeddedDocumentField(Remark),
                        default=[],
                        required=False)
    ignored = mongoengine.BooleanField(default=False)  # 忽略用户输入关键词
    last_click_time = mongoengine.DateTimeField(default=datetime.now())
    feed_expire_time = mongoengine.DateTimeField(default=after7day())
    feed_type = mongoengine.IntField(default=1)

    title = mongoengine.StringField(default='', )
    salary_min = mongoengine.IntField(default=0, )
    salary_max = mongoengine.IntField(default=0, )
    work_years_min = mongoengine.IntField(default=0, )
    work_years_max = mongoengine.IntField(default=0, )
    type = mongoengine.StringField(default='', )
    category = mongoengine.StringField(default='', )
    degree = mongoengine.IntField(default=0, )
    key_points = mongoengine.StringField(default='', )
    skill_required = mongoengine.StringField(default='', )
    recruit_num = mongoengine.IntField(default=0, )
    job_tag = mongoengine.StringField(default='', )
    report_to = mongoengine.StringField(default='', )
    department_to = mongoengine.StringField(default='', )
    language = mongoengine.StringField(default='', )
    gender = mongoengine.StringField(default='', )
    major = mongoengine.StringField(default='', )
    display = mongoengine.BooleanField(default=True, )
    job_url = mongoengine.StringField(default='', )
    is_related = mongoengine.BooleanField(default=True, )
    job_domain = mongoengine.ListField(StringField())
    job_welfare = mongoengine.ListField(StringField())
    company_prefer = mongoengine.ListField(StringField())
    update_time = mongoengine.DateTimeField(
        default=datetime.now(),
        required=False,
    )
    analyze_titles = mongoengine.StringField(default='', )

    meta = {
        'collection':
        'feed',
        'index_background':
        True,
        'indexes': [
            'job_type',
            'feed_type',
            'talent_level',
            '-add_time',
            '-expect_area',
            '-username',
            '-delete_time',
            '-expire_time',
            '-last_click_time',
            '-feed_expire_time',
        ]
    }

    def __unicode__(self):
        return self.username

    class Meta:
        app_label = 'Feed'

    def get_keywords_area(self):
        return self.keywords.lower() + self.expect_area.lower()

    def get_area_list(self):
        return self.expect_area.split(',')

    def get_uniform_keywords(self):
        return uniform(self.keywords)

    def get_remarks_keywords_list(self):
        """
        @summary: 由于对每个订阅进行了人工备注,需要将其转换为,server计算时的格式.
        @author: [email protected] 2014-2-17 10:06:28

        """
        return [
            list(jieba.cut("".join(remark.get_necessary_keywords())))
            for remark in self.remarks
        ]

    def get_exclude_job_words(self):
        """
        @summary: 获取需要屏蔽的职位词
        """
        exclude_job_words = []

        for remark in self.remarks:
            exclude_job_words.extend(remark.get_exclude_job_keywords())
        return exclude_job_words

    def get_latent_semantic_keywords(self):
        """
        @summary: 获取需要加分加权重的词
        """
        latent_semantic_keywords = []

        for remark in self.remarks:
            latent_semantic_keywords.extend(
                remark.get_latent_semantic_keywords())
        return latent_semantic_keywords

    def get_clean_keywords_list(self, unique=True):
        """
        @summary: 获取规则化的关键词列表,  由于用户输入关键词可能含有中文标点等情况.
        #统一为半角,小写,用户输入关键词按照1.自然分词  2.用户本身的输入间隔进行
        #返回这两种分割非重复的关键词列表.

        """
        uniform_keywords = uniform(self.keywords)
        #         uniform_keywords = replace_punctuation(uniform_keywords)
        seg_keywords = jieba.cut(uniform_keywords)

        seg_keywords = [
            keyword.lower() for keyword in seg_keywords
            if not is_other(keyword)
        ]

        user_seg_keywords = uniform_keywords.split()

        user_seg_keywords = [
            keyword.lower() for keyword in user_seg_keywords
            if not is_other(keyword)
        ]

        if unique:
            seg_keywords = get_ordered_unique(seg_keywords)
            user_seg_keywords = get_ordered_unique(user_seg_keywords)

        if seg_keywords == user_seg_keywords:
            return [seg_keywords]
        else:
            return [seg_keywords, user_seg_keywords]

    def get_all_eng_words(self, unique=True):
        """
        @summary: 获取关键词和职位描述中的所有单词或者单词+数字类型 ,如cocos2d
        """
        desc = uniform(self.keywords + ' ' + self.job_desc)

        words = jieba.cut(desc)

        eng_words = [word for word in words if is_num_word(word)]
        if unique:
            eng_words = get_ordered_unique(eng_words)
        return eng_words

    def get_user_remark_keywords(self):
        """
        @summary: 获取用户填的和人工备注的关键词.

        """

        keywords_list = []
        if not self.ignored:
            clean_keywords_list = self.get_clean_keywords_list()
            keywords_list.extend(clean_keywords_list)
        remark_keywords_list = self.get_remarks_keywords_list()
        if remark_keywords_list != [[]]:
            keywords_list.extend(remark_keywords_list)

        return keywords_list
Example #7
0
class Feed(Model):
    """
    @summary: 所有订阅内容

    @change: [email protected] 2014-6-15 18:43:18 加入外键,映射Feed所对应使用的套餐
    """
    FEED_META = (
        (1, '用户购买'),
        (2, '聘宝生成'),
    )
    DEGREE_CHOICES = (
        (0, u'不限'),
        (3, u'大专'),
        (4, u'本科'),
        (7, u'硕士'),
        (10, u'博士'),
    )

    feed_obj_id = CharField(
        default='',
        max_length=100,
        verbose_name=u'在mongo中的id',
        db_index=True,
    )
    keywords = CharField(default='', max_length=350, verbose_name=u'关键字')
    job_type = CharField(default='', max_length=100, verbose_name=u'职位类型')
    talent_level = CharField(default='', max_length=100, verbose_name=u'人才级别')
    expect_area = CharField(default='', max_length=100, verbose_name=u'期望工作地')
    job_desc = CharField(default='', max_length=5000, verbose_name=u'职位描述')

    deleted = BooleanField(default=False, verbose_name=u'删除状态')
    delete_time = DateTimeField(
        verbose_name=u'删除时间',
        auto_now_add=True,
    )
    add_time = DateTimeField(
        verbose_name=u'添加时间',
        auto_now_add=True,
    )
    expire_time = DateTimeField(null=True, blank=True, verbose_name='套餐到期')

    username = CharField(default='', max_length=100)
    user = ForeignKey(User, verbose_name=u'用户')
    # 最新增加对于每个订阅职位的理解,更好辅助算法.
    ignored = BooleanField(default=False)  # 忽略用户输入关键词
    last_click_time = DateTimeField(
        verbose_name=u'最后点击',
        auto_now_add=True,
    )
    feed_expire_time = DateTimeField(
        verbose_name=u'刷新到',
        default=after7day(),
        db_index=True,
    )
    feed_type = IntegerField(
        verbose_name='定制来源',
        choices=FEED_META,
        default=1,
    )
    title = models.CharField(
        max_length=100,
        verbose_name='职位名称',
        default='',
    )
    salary_min = models.IntegerField(
        default=0,
        verbose_name='最低薪资',
    )
    salary_max = models.IntegerField(
        default=0,
        verbose_name='最高工资',
    )
    work_years_min = models.IntegerField(
        default=0,
        verbose_name='最低工作年限',
    )
    work_years_max = models.IntegerField(
        default=0,
        verbose_name='最高工作年限',
    )
    type = models.CharField(
        max_length=30,
        default='',
        verbose_name='工作性质',
    )
    category = models.CharField(
        max_length=30,
        default='',
        verbose_name='职位类别',
    )
    degree = models.IntegerField(choices=DEGREE_CHOICES,
                                 default=0,
                                 verbose_name=u'最低学历')
    key_points = models.CharField(
        default='',
        max_length=1000,
        verbose_name=u'职位诱惑',
    )
    skill_required = models.CharField(
        default='',
        max_length=1000,
        verbose_name=u'岗位要求',
    )
    company = models.ForeignKey(
        'jobs.Company',
        verbose_name=u'公司',
        null=True,
        blank=True,
    )
    recruit_num = models.IntegerField(default=0, verbose_name=u'招聘人数')
    job_tag = models.CharField(
        default='',
        max_length=100,
        verbose_name=u'标签',
    )
    report_to = models.CharField(default='',
                                 max_length=100,
                                 verbose_name=u'汇报对象')
    department_to = models.CharField(
        default='',
        max_length=100,
        verbose_name=u'所属部门',
    )
    language = models.CharField(
        default='',
        max_length=100,
        verbose_name=u'语言要求',
    )
    gender = models.CharField(
        default='',
        max_length=100,
        verbose_name=u'性别要求',
    )
    major = models.CharField(
        default='',
        max_length=100,
        verbose_name=u'专业要求',
    )
    display = models.BooleanField(
        default=True,
        verbose_name=u'是否展示',
    )
    job_url = models.CharField(
        default='',
        max_length=200,
        verbose_name=u'职位地址',
    )
    job_domain = models.ManyToManyField(
        'jobs.CompanyCategory',
        verbose_name='类别',
        null=True,
        blank=True,
    )
    is_related = models.BooleanField(
        default=True,
        verbose_name='是否相关',
    )
    job_welfare = models.CharField(
        default='',
        max_length=200,
        verbose_name='职位诱惑',
    )
    company_prefer = models.ManyToManyField(
        'system.CompanyCategoryPrefer',
        verbose_name='职位偏好',
        null=True,
        blank=True,
    )
    update_time = models.DateTimeField(
        auto_now=True,
        db_index=True,
        verbose_name='更新时间',
    )
    analyze_titles = models.CharField(
        default='',
        max_length=350,
        verbose_name='职位扩展名',
        blank=True,
    )

    def __unicode__(self):
        return "%s %s %s %s" % (self.expect_area, self.job_type,
                                self.talent_level, self.keywords)

    def get_salary(self):
        salary_low, salary_high = self.salary_min, self.salary_max
        if salary_low == 0 and salary_high == 0:
            return '面议'
        if salary_low == 0 and salary_high == 1000000:
            return '面议'
        if salary_low > 0 and salary_high == 1000000:
            return '%dK以上' % (salary_low / 1000)
        if salary_low == 0 and salary_high < 1000000:
            return '%dK以下' % (salary_high / 1000)
        return '%dK-%dK' % (salary_low / 1000, salary_high / 1000)

    def fast_find(self):
        fast_url = 'http://pinbot.me:8888/search?kw=%s&addr=%s&jt=%s' % (
            self.keywords, self.expect_area, self.job_type)
        return mark_safe("<a href='%s' target=%d>%s</a>" %
                         (fast_url, self.id, self.keywords[:6] + '...'))

    fast_find.short_description = '快速查找人才'

    def reco_results(self):
        url = '/statis/feed_result/group/%s?username=%s#/group/%s' % (
            self.feed_obj_id, self.user.username, self.feed_obj_id)
        return mark_safe("<a href='%s' target=reco_%d>%s</a>" %
                         (url, self.id, u'管理推荐'))

    reco_results.short_description = '推荐结果预览'

    def feed_expire_status(self):
        tomorrow = get_tomommow()
        feed_has_expire = self.feed_expire_time < tomorrow
        return u'是' if feed_has_expire else u'否'

    feed_expire_status.short_description = u'7天到期'

    def show_company_name(self):
        return self.user.first_name

    show_company_name.short_description = u'公司'

    class Meta:
        db_table = 'feed_feed'
        app_label = 'feed'
        verbose_name = u'订阅管理'
        verbose_name_plural = verbose_name
        permissions = (
            ('visit_taocv', '淘CV访问权限'),
            ('visit_feed', '专属定制访问权限'),
        )
Example #8
0
 def create_mysql_feed(self, feed_pkg):
     feed = self.form.save(commit=False)
     feed.feed_expire_time = after7day()
     feed.expire_time = feed_pkg.feed_end_time
     feed.user = self.user
     return feed
Example #9
0
 def create_mysql_feed(self, feed_pkg):
     feed = self.form.save(commit=False)
     feed.feed_expire_time = after7day()
     feed.expire_time = feed_pkg.feed_end_time
     feed.user = self.user
     return feed
Example #10
0
 def setUp(self):
     user = User.objects.create_user(
         '*****@*****.**',
         '*****@*****.**',
         '123456'
     )
     self.feed1 = Feed.objects.create(
         salary_min=1000,
         salary_max=21500,
         skill_required='fdsafdsakjfklsafjdsakfdj',
         expect_area='北京,成都,上海,广州',
         talent_level='初级',
         job_type='fdsafdsf',
         keywords='fdsafjdkaslfj',
         title='fdasfjdkasfj',
         job_desc='fdsafjkdlsajfdklafj',
         feed_obj_id='55a878df8230dbfce1130553',
         user=user,
         feed_expire_time=after7day(),
         expire_time=after7day(),
     )
     self.feed2 = Feed.objects.create(
         salary_min=1000,
         salary_max=1500,
         skill_required='fdsafdsakjfklsafjdsakfdj',
         expect_area='fdasfsf,fdsafda',
         talent_level='初级',
         job_type='fdsafdsf',
         keywords='fdsafjdkaslfj',
         title='fdasfjdkasfj',
         job_desc='fdsafjkdlsajfdklafj',
         feed_obj_id='55a878df8230dbfce1130553',
         user=user,
         feed_expire_time=after7day(),
         expire_time=after7day(),
         deleted=True,
     )
     self.feed3 = Feed.objects.create(
         salary_min=1000,
         salary_max=1500,
         skill_required='fdsafdsakjfklsafjdsakfdj',
         expect_area='fdasfsf,fdsafda',
         talent_level='初级',
         job_type='fdsafdsf',
         keywords='fdsafjdkaslfj',
         title='fdasfjdkasfj',
         job_desc='fdsafjkdlsajfdklafj',
         feed_obj_id='55a878df8230dbfce1130553',
         user=user,
         feed_expire_time=after7day(),
         expire_time=after7day(),
     )
     resume = UploadResume.objects.select_related('user').get(id=2)
     RecoResumeTask.objects.bulk_create([
         RecoResumeTask(
             feed=self.feed1,
             user=resume.user,
             upload_resume=resume,
         ),
         RecoResumeTask(
             feed=self.feed2,
             user=resume.user,
             upload_resume=resume,
         ),
         RecoResumeTask(
             feed=self.feed3,
             user=resume.user,
             upload_resume=resume,
         ),
     ])