def history(request): user = get_user(request) user_info = get_user_info(user) if isinstance(user_info, Employer): offer_list = Offer.objects.filter(employer=user_info, status='E') favor_list = [] favors = FavorList.objects.filter(employer=user_info) favor_index = 0 for favor in favors: favor_index = favor_index + 1 employee = favor.employee favor_dict = model_to_dict(employee, exclude=['id', 'user', 'skills', 'gender', 'type']) gender = get_enum_desc_from_value(GENDER, employee.gender) type = get_enum_desc_from_value(EMPLOYEE_TYPE, employee.type) favor_dict['index'] = favor_index favor_dict['id'] = favor.id favor_dict['gender'] = gender favor_dict['type'] = type favor_dict['contact'] = '' favor_dict['post_ref'] = '' favor_list.append(favor_dict) black_list = [] blackList = Blacklist.objects.filter(employer=user_info) black_list_index = 0 for black_list_emp in blackList: black_list_index = black_list_index + 1 employee = black_list_emp.employee black_list_dict = model_to_dict(employee, exclude=['id', 'user', 'skills', 'gender', 'type']) gender = get_enum_desc_from_value(GENDER, employee.gender) type = get_enum_desc_from_value(EMPLOYEE_TYPE, employee.type) black_list_dict['index'] = black_list_index black_list_dict['id'] = black_list_emp.id black_list_dict['gender'] = gender black_list_dict['type'] = type black_list_dict['contact'] = '' black_list_dict['post_ref'] = '' black_list.append(black_list_dict) context = {"expired": offer_list, "favor_list": favor_list, "black_list": black_list} template = 'partime/offer/offer_history.html' else: request_list = Request.objects.filter(employee=user_info, status='E') context = {"expired": request_list} template = 'partime/request/request_history.html' return render(request, template, context)
def match(request): user = get_user(request) user_info = get_user_info(user) results = [] index = 0 if isinstance(user_info, Employer): offer_list = Offer.objects.filter(employer=user_info) for offer in offer_list: index = index + 1 offer_dict = model_to_dict(offer, fields=['id', 'post_name']) matches = [] matchedRequests = RequestOfferMatch.objects.filter(offer=offer) match_index = 0 for match in matchedRequests: match_index = match_index + 1 employee = match.request.employee match_dict = model_to_dict(employee, exclude=['id', 'user', 'skills', 'gender', 'type']) gender = get_enum_desc_from_value(GENDER, employee.gender) type = get_enum_desc_from_value(EMPLOYEE_TYPE, employee.type) skills = ','.join([skill.name for skill in employee.skills.all()]) match_dict['index'] = match_index match_dict['id'] = match.id match_dict['gender'] = gender match_dict['type'] = type match_dict['skills'] = skills match_dict['show_approve'] = match.show_approve(True) match_dict['show_reject'] = match.show_reject(True) match_dict['status_msg'] = match.get_status_msg() matches.append(match_dict) offer_dict['index'] = index offer_dict['matches'] = matches results.append(offer_dict) context = {"offers": results} template = 'partime/offer/offer_match.html' else: request_list = Request.objects.filter(employee=user_info) for req in request_list: index = index + 1 request_dict = model_to_dict(req, fields=['id', 'date_from', 'date_to']) matches = [] matchedOffers = RequestOfferMatch.objects.filter(request=req) match_index = 0 for match in matchedOffers: match_index = match_index + 1 offer = match.offer employer = offer.employer match_dict = model_to_dict(employer, exclude=['id', 'user', 'favor_list', 'black_list', 'gender', 'type']) gender = get_enum_desc_from_value(GENDER, employer.gender) type = get_enum_desc_from_value(EMPLOYER_TYPE, employer.type) match_dict['index'] = match_index match_dict['id'] = match.id match_dict['gender'] = gender match_dict['type'] = type match_dict['post_category'] = offer.post_category.name match_dict['duration'] = str(offer.duration) + ' ' + get_enum_desc_from_value(YTD, offer.duration_unit) match_dict['home_base'] = offer.home_base match_dict['pay_rate'] = str(offer.pay_rate) + ' ' + get_enum_desc_from_value(PAY_RATE, offer.pay_rate_unit) match_dict['show_approve'] = match.show_approve(False) match_dict['show_reject'] = match.show_reject(False) match_dict['status_msg'] = match.get_status_msg() matches.append(match_dict) request_dict['index'] = index request_dict['matches'] = matches results.append(request_dict) context = {"requests": results} template = 'partime/request/request_match.html' return render(request, template, context)