Example #1
0
def get_position_title(resume):
    if not resume.works:
        return ''

    sorted_works = sorted(
        resume.works,
        key=lambda work: str2datetime(work.start_time),
        reverse=True
    )
    return sorted_works[0].position_title
Example #2
0
    def convert_display_time(self, display_time_str):
        display_time = str2datetime(display_time_str)

        if not display_time:
            default_display_time = get_tomommow()
            return default_display_time

        # 展示时间只需要精确到天
        # 同一天的推荐结果需要按job_related排序
        display_time = datetime.datetime(
            display_time.year,
            display_time.month,
            display_time.day,
        )
        return display_time
Example #3
0
    def get_query_calc_time(self, query_cond):
        if not query_cond.get('calc_time__gt'):
            return query_cond

        calc_time_str = self.request.GET.get('calc_time')
        if not calc_time_str:
            return query_cond

        calc_time = str2datetime(calc_time_str)
        invalid_time = datetime.datetime(1990, 01, 01)

        tomorrow = get_tomommow()
        min_calc_time = tomorrow + datetime.timedelta(days=-15)

        if calc_time == invalid_time:
            calc_time = min_calc_time
        query_cond['calc_time__gt'] = calc_time
        return query_cond
Example #4
0
 def get_latest_edu(self, resume):
     edus = resume.get('educations', [{}])
     sort_edus = sorted([i for i in edus if i],
                        key=lambda x: str2datetime(x.get('start_time')),
                        reverse=True)
     return sort_edus[:1]
Example #5
0
 def get_latest_edu(self, resume):
     edus = resume.get('educations', [{}])
     sort_edus = sorted([i for i in edus if i], key=lambda x: str2datetime(x.get('start_time')), reverse=True)
     return sort_edus[:1]
def trans_advance_user():
    vip_a = VipRoleSetting.objects.get(code_name='experience_user')

    UserVip.objects.filter(
        is_active=True,
        user__username__in=username_list,
    ).update(
        vip_role=vip_a
    )

    manual_service = list(PackageItem.objects.all(
    ).values_list(
        'id',
        'price',
    ))
    manual_mapper = {
        i[1]: i[0]
        for i in manual_service
    }

    user_list = User.objects.filter(
        username__in=username_list,
        manual_roles=None,
    )

    experience_service = VipRoleUtils.get_experience_vip()

    for i in user_list:
        user = i
        username = i.username
        user_price = users_mapper.get(username, {}).get('price', 0)
        if not user_price:
            print 'user %s is valid, no price' % username

        pid = manual_mapper.get(user_price, 0)
        if not pid:
            print 'user %s price %s is valid, valid price' % (username, user_price)

        start_time = str2datetime(users_mapper.get(username, {}).get('start_time', ''))
        end_time = str2datetime(users_mapper.get(username, {}).get('end_time', ''))

        with transaction.atomic():
            if not user.vip_roles.filter(is_active=True).exists():
                srv_meta = {
                    'service_name': 'self_service',
                    'product': experience_service,
                    'user': user,
                }
                experience_srv = SelfService(**srv_meta)
                experience_srv.create_service()
                experience_srv.active_service()

            order = OrderManage.create_order(
                user,
                pid,
                'manual_service',
                1,
                'offline',
            )
            OrderManage.paid_order(order.order_id, user)

            UserManualService.objects.filter(
                user=user,
                is_active=True,
            ).update(
                active_time=start_time,
                expire_time=end_time,
            )
            print 'trans %s success' % username
def trans_advance_user():
    vip_a = VipRoleSetting.objects.get(code_name='experience_user')

    UserVip.objects.filter(
        is_active=True,
        user__username__in=username_list,
    ).update(vip_role=vip_a)

    manual_service = list(PackageItem.objects.all().values_list(
        'id',
        'price',
    ))
    manual_mapper = {i[1]: i[0] for i in manual_service}

    user_list = User.objects.filter(
        username__in=username_list,
        manual_roles=None,
    )

    experience_service = VipRoleUtils.get_experience_vip()

    for i in user_list:
        user = i
        username = i.username
        user_price = users_mapper.get(username, {}).get('price', 0)
        if not user_price:
            print 'user %s is valid, no price' % username

        pid = manual_mapper.get(user_price, 0)
        if not pid:
            print 'user %s price %s is valid, valid price' % (username,
                                                              user_price)

        start_time = str2datetime(
            users_mapper.get(username, {}).get('start_time', ''))
        end_time = str2datetime(
            users_mapper.get(username, {}).get('end_time', ''))

        with transaction.atomic():
            if not user.vip_roles.filter(is_active=True).exists():
                srv_meta = {
                    'service_name': 'self_service',
                    'product': experience_service,
                    'user': user,
                }
                experience_srv = SelfService(**srv_meta)
                experience_srv.create_service()
                experience_srv.active_service()

            order = OrderManage.create_order(
                user,
                pid,
                'manual_service',
                1,
                'offline',
            )
            OrderManage.paid_order(order.order_id, user)

            UserManualService.objects.filter(
                user=user,
                is_active=True,
            ).update(
                active_time=start_time,
                expire_time=end_time,
            )
            print 'trans %s success' % username