def main(request): if request.user.groups.filter(name="Recruiter").count() > 0: return HttpResponseRedirect("/corporate/resume/recruiter/") if request.method == "POST" and request.POST.get("student") == "yes": resume_form = ResumeForm(request.POST, request.FILES) resume_person_form = ResumePersonForm(request.POST) if resume_person_form.is_valid() and resume_form.is_valid(): try: rp = ResumePerson.objects.get(netid=resume_person_form.cleaned_data["netid"].lower()) resume_person_form = ResumePersonForm(request.POST, instance=rp) except: pass try: resume_person = resume_person_form.save() resume = resume_form.save(commit=False) resume.person = resume_person resume.save() return HttpResponseRedirect("/corporate/resume/student/thanks/%d" % (resume.id)) # Redirect after POST except ValueError: errors = resume_person_form._errors.setdefault("netid", ErrorList()) errors.append(u"Not a valid netid") else: resume_person_form = ResumePersonForm() resume_form = ResumeForm() if request.method == "POST" and request.POST.get("recruiter") == "yes": login_form = AuthenticationForm(data=request.POST) if login_form.is_valid(): login(request, login_form.get_user()) return HttpResponseRedirect("/corporate/resume/recruiter/") # Redirect after POST else: login_form = AuthenticationForm() return render_to_response( "corporate/resume/main.html", { "resume_form": resume_form, "resume_person_form": resume_person_form, "login_form": login_form, "section": "corporate", }, context_instance=RequestContext(request), )
def main(request): if request.user.groups.filter(name='Recruiter').count() > 0: return HttpResponseRedirect("/corporate/resume/recruiter/") if request.method == 'POST' and request.POST.get('student') == "yes": resume_form = ResumeForm(request.POST, request.FILES) resume_person_form = ResumePersonForm(request.POST) if resume_person_form.is_valid() and resume_form.is_valid(): try: rp = ResumePerson.objects.get( netid=resume_person_form.cleaned_data['netid'].lower()) resume_person_form = ResumePersonForm(request.POST, instance=rp) except: pass try: resume_person = resume_person_form.save() resume = resume_form.save(commit=False) resume.person = resume_person resume.save() return HttpResponseRedirect( "/corporate/resume/student/thanks/%d" % (resume.id)) # Redirect after POST except ValueError: errors = resume_person_form._errors.setdefault( "netid", ErrorList()) errors.append(u"Not a valid netid") else: resume_person_form = ResumePersonForm() resume_form = ResumeForm() if request.method == "POST" and request.POST.get('recruiter') == "yes": login_form = AuthenticationForm(data=request.POST) if login_form.is_valid(): login(request, login_form.get_user()) return HttpResponseRedirect( "/corporate/resume/recruiter/") # Redirect after POST else: login_form = AuthenticationForm() return render_to_response('corporate/resume/main.html', { 'resume_form': resume_form, 'resume_person_form': resume_person_form, 'login_form': login_form, 'section': "corporate", }, context_instance=RequestContext(request))
def student_referred(request): if request.user.groups.filter(name='Recruiter').count() > 0: return HttpResponseRedirect("/corporate/resume/recruiter/") if request.method == 'POST' and request.POST.get('student')=="yes": resume_form = ResumeForm(request.POST,request.FILES) resume_person_form = ResumePersonForm(request.POST) if resume_person_form.is_valid() and resume_form.is_valid(): try: rp = ResumePerson.objects.get(netid=resume_person_form.cleaned_data['netid'].lower()) resume_person_form = ResumePersonForm(request.POST,instance=rp) except: pass try: resume_person = resume_person_form.save() resume = resume_form.save(commit=False) resume.person = resume_person resume.save() return HttpResponseRedirect("/corporate/resume/student/thanks/%d"%(resume.id)) # Redirect after POST except ValueError: errors = resume_person_form._errors.setdefault("netid", ErrorList()) errors.append(u"Not a valid netid") return render_to_response('corporate/resume/student_referred.html',{ 'resume_found': False, 'resume_id': 0, 'resume_form': resume_form, 'resume_person_form': resume_person_form, 'section': "corporate", },context_instance=RequestContext(request)) else: return render_to_response('corporate/resume/student_referred.html',{ 'resume_found': False, 'resume_id': 0, 'resume_form': resume_form, 'resume_person_form': resume_person_form, 'section': "corporate", },context_instance=RequestContext(request)) else: # Form prepopulation data pre_resume_uuid = request.GET.get('resume_uuid') pre_users = ResumePerson.objects.filter(resume_uuid__exact=pre_resume_uuid) pre_netid = "" if pre_users.count() != 1 else pre_users[0].netid pre_fname = "" if pre_users.count() != 1 else pre_users[0].first_name pre_lname = "" if pre_users.count() != 1 else pre_users[0].last_name pre_graduation_date = datetime.now() if pre_users.count() != 1 else pre_users[0].graduation pre_level = "" if pre_users.count() != 1 else pre_users[0].level pre_seeking = "" if pre_users.count() != 1 else pre_users[0].seeking resume_person_form = ResumePersonForm(initial={'netid':pre_netid, 'first_name':pre_fname, 'last_name':pre_lname, 'level':pre_level, 'seeking':pre_seeking, 'graduation':pre_graduation_date}) resume_form = ResumeForm() # Get most recent resume for person resume_found = False if pre_resume_uuid != None: resume_people = ResumePerson.objects.filter(resume_uuid__exact=pre_resume_uuid) if resume_people.count() == 1: try: resume = resume_people[0].latest_resume() resume_found = True except: pass return render_to_response('corporate/resume/student_referred.html',{ 'resume_found': resume_found, 'resume_id': resume.id if resume_found else 0, 'resume_form': resume_form, 'resume_person_form': resume_person_form, 'section': "corporate", },context_instance=RequestContext(request))