def post(self, request, *args, **kwargs): jobId = self.kwargs.get('jobId') if request.user.is_authenticated: if checkDuplicateResume(jobId, request.user.id): self.json_data['result'] = False self.json_data['error'] = "Duplicated Submission! 您已经提交过该岗位的申请" else: form = ResumeSubmissionForm(data=request.POST, files=request.FILES) form.user = request.user if form.is_valid(): instance = form.save() self.json_data['result'] = True mail_content = {'username': instance.user.userprofile.lastNameEN + " " + instance.user.userprofile.firstNameEN, 'dept': instance.jobRelated.dept.deptTitle, 'jobName': instance.jobRelated.jobName} confirm_mail = AutoMailSender( title="CV Submitted. 我们已经收到您的简历", mail_text="", template_path='myCSSAhub/email/cv_mail.html', fill_in_context=mail_content, to_address=request.user.email, ) confirm_mail.send_now() else: self.json_data['result'] = False self.json_data['error'] = "抱歉,您的表单填写有误,请重新检查。请注意,每项字数不可超过500字。" else: self.json_data['result'] = False self.json_data['error'] = 'You need to login first! 请先登录! ' return JsonResponse(self.json_data)
def get(self, request, *args, **kwargs): prev_submission = None jobId = self.kwargs.get('jobId') job_data = JobModels.JobList.objects.get(jobId=jobId) if checkDuplicateResume(jobId,request.user.id): prev_submission = JobModels.Resume.objects.filter(Q(disabled=False) & Q(user__id=request.user.id) & Q(jobRelated__jobId=jobId)).first() return render(request, 'PublicSite/jobapplication.html', {'job_data': job_data, 'prev_submission':prev_submission})