def recruiter_browse(request): q = request.GET.get('q') if q==None: q = "" level = request.GET.getlist('level') level.sort() seeking = request.GET.getlist('seeking') seeking.sort() acm = request.GET.get('acm') == "yes" graduation_start = request.GET.get('graduation_start') graduation_end = request.GET.get('graduation_end') if graduation_start == "": graduation_start = None if graduation_end == "": graduation_end = None level_str = None if len(level) > 0: level_str = "".join(level) seeking_str = None if len(seeking) > 0: seeking_str = "".join(seeking) sets = ResumeDownloadSet.objects.filter(level=level_str,seeking=seeking_str,acm=acm,graduation_start=graduation_start,graduation_end=graduation_end,owner=request.user) if sets.count() > 0: set = sets[0] else: set = ResumeDownloadSet(level=level_str,seeking=seeking_str,acm=acm,graduation_start=graduation_start,graduation_end=graduation_end) if request.GET.get('download') == "true": set.owner = request.user set.save() download = set.generate_download() return HttpResponseRedirect('/corporate/resume/recruiter/download/%d.pdf'%(download.id)) if q != "": queries = q.split() qset1 = reduce(operator.__or__, [Q(netid__icontains=q) | Q(first_name__icontains=query) | Q(last_name__icontains=query) for query in queries]) people = set.get_people(qset1) else: people = set.get_people() num_per_page = request.GET.get('num_per_page') if num_per_page==None: num_per_page = 50 else: num_per_page = int(num_per_page) # Show requested number of resumes per page (50 by default) paginator = Paginator(people, num_per_page) total_people = paginator.count page = request.GET.get('page') try: people = paginator.page(page) except PageNotAnInteger: # If page is not an integer, deliver first page. people = paginator.page(1) except EmptyPage: # If page is out of range (e.g. 9999), deliver last page of results. people = paginator.page(paginator.num_pages) graduation_choices = ResumePerson.RESUME_PERSON_GRADUATION return render_to_response('corporate/resume/recruiter_browse.html',{ "section":"corporate", "page":"browse", "people":people, "q":q, "set":set, "total_people":total_people, "graduation_choices":graduation_choices, "num_per_page": num_per_page, "request":request },context_instance=RequestContext(request))
def recruiter_browse(request): q = request.GET.get('q') if q==None: q = "" level = request.GET.getlist('level') level.sort() seeking = request.GET.getlist('seeking') seeking.sort() acm = request.GET.get('acm') == "yes" graduation_start_arg = request.GET.get('graduation_start') graduation_end_arg = request.GET.get('graduation_end') today = datetime.today() graduation_start = today if graduation_start_arg != "": try: graduation_start = datetime.strptime(graduation_start_arg, "%Y-%m-%d") except: pass graduation_end = None if graduation_end_arg != "": try: graduation_end = datetime.strptime(graduation_end_arg, "%Y-%m-%d") except: pass level_str = None if len(level) > 0: level_str = "".join(level) seeking_str = None if len(seeking) > 0: seeking_str = "".join(seeking) sets = ResumeDownloadSet.objects.filter(level=level_str,seeking=seeking_str,acm=acm,graduation_start=graduation_start,graduation_end=graduation_end,owner=request.user) if sets.count() > 0: set = sets[0] else: set = ResumeDownloadSet(level=level_str,seeking=seeking_str,acm=acm,graduation_start=graduation_start,graduation_end=graduation_end) if request.GET.get('download') == "true": set.owner = request.user set.save() download = set.generate_download() return HttpResponseRedirect('/corporate/resume/recruiter/download/%d.pdf'%(download.id)) num_per_page = request.GET.get('num_per_page') if num_per_page==None: num_per_page = 50 else: num_per_page = int(num_per_page) if q != "": queries = q.split() qset1 = reduce(operator.__or__, [Q(netid__icontains=q) | Q(first_name__icontains=query) | Q(last_name__icontains=query) for query in queries]) people = set.get_people(qset1) else: people = set.get_people() # Sortable tables sort_field = request.GET.get("sort_field") sort_dir = request.GET.get("sort_dir") if sort_field == None: sort_field = "name" if sort_dir == None or sort_dir != "-": sort_dir = "" if sort_field != "name": people = people.order_by(sort_dir + sort_field) else: people = people.order_by(sort_dir + "last_name", sort_dir + "first_name") # Show requested number of resumes per page (50 by default) paginator = Paginator(people, num_per_page) total_people = paginator.count page = request.GET.get('page') try: people = paginator.page(page) except PageNotAnInteger: # If page is not an integer, deliver first page. people = paginator.page(1) except EmptyPage: # If page is out of range (e.g. 9999), deliver last page of results. people = paginator.page(paginator.num_pages) graduation_choices = ResumePerson.RESUME_PERSON_GRADUATION # Sortable table urls new_sort_dir = "-" if sort_dir == "" else "" print new_sort_dir name_sort_url = request.GET.copy() name_sort_url["sort_field"] = "name"; name_sort_url["sort_dir"] = new_sort_dir if sort_field == "name" else "" grad_sort_url = request.GET.copy() grad_sort_url["sort_field"] = "graduation"; grad_sort_url["sort_dir"] = new_sort_dir if sort_field == "graduation" else "" level_sort_url = request.GET.copy() level_sort_url["sort_field"] = "level"; level_sort_url["sort_dir"] = new_sort_dir if sort_field == "level" else "" seek_sort_url = request.GET.copy() seek_sort_url["sort_field"] = "seeking"; seek_sort_url["sort_dir"] = new_sort_dir if sort_field == "seeking" else "" # Sortable table arrows active_arrow = " " + (u'\u25B2' if sort_dir == "" else u'\u25BC') name_arrow = active_arrow if sort_field == "name" else "" grad_arrow = active_arrow if sort_field == "graduation" else "" level_arrow = active_arrow if sort_field == "level" else "" seek_arrow = active_arrow if sort_field == "seeking" else "" return render_to_response('corporate/resume/recruiter_browse.html',{ "section":"corporate", "page":"browse", "people":people, "q":q, "set":set, "total_people":total_people, "graduation_choices":graduation_choices, "num_per_page": num_per_page, "request":request, # Sortable table urls "name_sort_url": "?" + name_sort_url.urlencode(), "grad_sort_url": "?" + grad_sort_url.urlencode(), "level_sort_url": "?" + level_sort_url.urlencode(), "seek_sort_url": "?" + seek_sort_url.urlencode(), # Sortable table arrows "name_arrow": name_arrow, "grad_arrow": grad_arrow, "level_arrow": level_arrow, "seek_arrow": seek_arrow },context_instance=RequestContext(request))
def recruiter_browse(request): q = request.GET.get('q') if q == None: q = "" level = request.GET.getlist('level') level.sort() seeking = request.GET.getlist('seeking') seeking.sort() acm = request.GET.get('acm') == "yes" graduation_start = request.GET.get('graduation_start') graduation_end = request.GET.get('graduation_end') if graduation_start == "": graduation_start = None if graduation_end == "": graduation_end = None level_str = None if len(level) > 0: level_str = "".join(level) seeking_str = None if len(seeking) > 0: seeking_str = "".join(seeking) sets = ResumeDownloadSet.objects.filter(level=level_str, seeking=seeking_str, acm=acm, graduation_start=graduation_start, graduation_end=graduation_end, owner=request.user) if sets.count() > 0: set = sets[0] else: set = ResumeDownloadSet(level=level_str, seeking=seeking_str, acm=acm, graduation_start=graduation_start, graduation_end=graduation_end) if request.GET.get('download') == "true": set.owner = request.user set.save() download = set.generate_download() return HttpResponseRedirect( '/corporate/resume/recruiter/download/%d.pdf' % (download.id)) if q != "": queries = q.split() qset1 = reduce(operator.__or__, [ Q(netid__icontains=q) | Q(first_name__icontains=query) | Q(last_name__icontains=query) for query in queries ]) people = set.get_people(qset1) else: people = set.get_people() num_per_page = request.GET.get('num_per_page') if num_per_page == None: num_per_page = 50 else: num_per_page = int(num_per_page) # Show requested number of resumes per page (50 by default) paginator = Paginator(people, num_per_page) total_people = paginator.count page = request.GET.get('page') try: people = paginator.page(page) except PageNotAnInteger: # If page is not an integer, deliver first page. people = paginator.page(1) except EmptyPage: # If page is out of range (e.g. 9999), deliver last page of results. people = paginator.page(paginator.num_pages) graduation_choices = ResumePerson.RESUME_PERSON_GRADUATION return render_to_response('corporate/resume/recruiter_browse.html', { "section": "corporate", "page": "browse", "people": people, "q": q, "set": set, "total_people": total_people, "graduation_choices": graduation_choices, "num_per_page": num_per_page, "request": request }, context_instance=RequestContext(request))