def get(self, request): user = request.user now = datetime.datetime.now() charge_pkgs = UserChargePackage.objects.select_related( 'resume_package', ).filter( user=user, package_type=1, pay_status='finished', resume_end_time__gt=now, ).order_by('-resume_end_time') user_feeds = UserChargePackage.objects.select_related( 'feed_package', ).filter( user=user, package_type=2, pay_status='finished', extra_feed_num__gt=0, feed_end_time__gt=now, ).order_by('-id') has_pkg = UserChargePackage.objects.filter( user=user, package_type=1, pay_status='finished', resume_end_time__gt=now, ) user_point = point_utils.get_user_pinbot_point(user) pinbot_point = point_utils._get_pinbot_point(user) current_vip = VipRoleUtils.get_current_vip(user) highest_vip_level = VipRoleUtils.get_highest_vip_level() unsign_vip = VipRoleUtils.get_unsign_vip(user) rest_feed_count = PackageUtils.rest_feed_count(user) coin_stat = coin_utils.get_coin_statistic(user) withdraw_data = json.dumps( WithdrawUtils.get_withdraw_status(user), ensure_ascii=False ) is_partner = PartnerUtils.is_partner(user) return render( request, self.template, { 'charge_pkgs': charge_pkgs, 'user_feeds': user_feeds, 'user_point': user_point, 'pinbot_point': pinbot_point, 'current_vip': current_vip, 'highest_vip_level': highest_vip_level, 'unsign_vip': unsign_vip, 'rest_feed_count': rest_feed_count, 'has_pkg': has_pkg, 'coin_stat': coin_stat, 'withdraw_data': withdraw_data, 'is_partner': is_partner, }, )
def update_guide_switch(self, user): current_vip = VipRoleUtils.get_current_vip(user) if current_vip: return False user.userprofile.guide_switch = True user.userprofile.save() return user
def get(self, request): user = request.user company = Company.objects.select_related( 'category', ).filter( user=user ) company_card_dict = {} jobs_arr = [] companycard_css = 'curr' company_category = [] if len(company) >= 1: company = company[0] company.desc = company.desc.strip() company_json = model_to_dict(company) company_card_dict['company'] = company_json jobs = Job.objects.filter(company=company, deleted=False) for job in jobs: job_json = model_to_dict(job) jobs_arr.append(job_json) company_card_dict['jobs'] = jobs_arr company_category = company.category.all() company_card_dict['select_category'] = [ { 'category': c.category, 'id': c.id, } for c in company_category ] all_company_category = CompanyCategory.objects.filter( display=True, ).order_by( '-sort', ) select_id_list = [c.id for c in company_category] company_card_dict['all_company_category'] = [ { 'category': c.category, 'id': c.id, 'select': True if c.id in select_id_list else False } for c in all_company_category ] company_card_dict['show_mission'] = True if ( not FeedUtils.has_use_feed(user) and VipRoleUtils.get_current_vip(user) ) else False company_card_json = json.dumps(company_card_dict) return render( request, self.template_name, { 'company_json': company_card_json, 'companycard_css': companycard_css, }, )
def add_user_vip_record(self, user, with_manual=False): if with_manual: product_id = get_object_or_none(VipRoleSetting, code_name='experience_user').id else: product_id = self.product.id self.current_vip = VipRoleUtils.get_current_vip(user) self.vip_role = get_object_or_none( VipRoleSetting, id=product_id, allow_apply=True, ) if not self.vip_role: return False user_vip = UserVip( user=user, vip_role=self.vip_role, total_price=self.vip_role.price, ) user_vip.save() return user_vip
def get(self, request): ''' 兼容接口请求和页面请求 ''' ajax_request = request.is_ajax() all_feed = self.get_all_feed() has_rest_feed = self.has_rest_feed() if not all_feed: if ajax_request: return JsonResponse({ 'status': 'no_feed', 'msg': '没有定制', }) return render( request, 'feed_home_page.html', {}, ) all_feed_dict = [{ 'feed': { 'id': str(f.feed.id), 'keywords': f.feed.keywords, 'salary_min': f.feed.salary_min, 'salary_max': f.feed.salary_max, 'expect_area': f.feed.expect_area, 'talent_level': f.feed.talent_level, 'feed_type': f.feed.feed_type, 'unread_count': f.feed.unread_count, 'expire_status': f.feed.expire_status, 'has_expire': f.feed.has_expire, 'start_time': f.feed.start_time, 'partner_feed': f.feed.partner_feed, 'job_type': f.feed.job_type, 'title': f.feed.title, 'last_click_time': f.feed.last_click_time, 'calced': f.feed.calced, }, } for f in all_feed] current_vip = VipRoleUtils.get_current_vip(request.user) data = { 'all_feed': all_feed_dict, 'has_rest_feed': has_rest_feed, 'vip_user': True if current_vip else False, } if ajax_request: return JsonResponse({ 'status': 'ok', 'data': data, 'msg': 'ok', }) data_json = json.dumps(data, default=json_util.default) return render( request, self.template_name, { 'data': data_json, 'all_feed': all_feed, 'has_rest_feed': has_rest_feed, }, )
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')
def return_points(request, op_type, user_fd_back_id): """ @summary: 返还用户返还的极点. 管理员审核通过后返还用户的积点. @author: likaiguo 2014-6-17 10:38:29 """ json_data = '' user_fd_backs = UserResumeFeedback.objects.filter(pk=int(user_fd_back_id)) if user_fd_backs: user_fd_back = user_fd_backs[0] if op_type == 'deny': user_fd_back.check_status = 'deny' json_data = json.dumps({'status':'ok', 'data':'已拒绝返点'}) user_fd_back.save() MarkUtils.accu_mark_result( user_fd_back.user, user_fd_back.resume_id, 'deny', ) elif user_fd_back.check_status != 'checking': json_data = json.dumps({'status':'error', 'data':'重复操作,当前返点状态-%s' % user_fd_back.check_status}) elif request.user.is_staff: now = datetime.now() user_base_pkgs = UserChargePackage.objects.filter( user=user_fd_back.user, package_type=1, pay_status='finished', resume_end_time__gt=now, ).order_by('-start_time') if user_base_pkgs: base_pkg = user_base_pkgs[0] base_pkg.re_points += user_fd_back.feedback_info.type.re_points base_pkg.save() user_fd_back.check_status = 'pass' PartnerCoinUtils.resume_accusation(user_fd_back) PartnerCoinUtils.add_malice_user(user_fd_back) user_fd_back.save() json_data = json.dumps({'status':'ok', 'data':'已返还%d点' % user_fd_back.feedback_info.type.re_points}) MarkUtils.accu_mark_result( user_fd_back.user, user_fd_back.resume_id, 'pass', ) else: # 新服务模式返点到聘点中 user = user_fd_back.user current_vip = VipRoleUtils.get_current_vip(user) if current_vip: user_fd_back.check_status = 'pass' user_fd_back.save() point_utils.accu_return(user) json_data = json.dumps({'status':'ok', 'data':'返点成功'}) MarkUtils.accu_mark_result( user_fd_back.user, user_fd_back.resume_id, 'pass', ) PartnerCoinUtils.resume_accusation(user_fd_back) PartnerCoinUtils.add_malice_user(user_fd_back) else: json_data = json.dumps({'status':'error', 'data':'用户没有基础套餐'}) else: json_data = json.dumps({'status':'error', 'data':'请使用员工号'}) return HttpResponse(json_data, 'application/json')