Untitled
unknown
plain_text
2 years ago
5.6 kB
6
Indexable
@login_required def add_or_edit_qualification(request): if request.is_ajax() and request.method == 'POST': data = json.loads(request.body.decode('utf-8')) qual = QualificationCategory.objects.get(id=data['quaLevel']) degree = Degree.objects.get(id=data['quaName'],qualification_category__category_name=qual.category_name) disc = Discpline.objects.get(id=data['quaDisc']) sca = StudentCandidateApplication.objects.get(login_email=request.user) if data['name'] == 'EditAndSave': scq = StudentCandidateQualification.objects.get(application=sca, id=data['id']) scq.degree_id = degree scq.school_college = data['board'] scq.start_year = data['startYear'] scq.completion_year = data['endYear'] scq.discipline_id = disc scq.percentage_marks_cgpa = data['percentage'] scq.cpga_outoff = data['outoff'] if data['outoff'] else None scq.other_degree = data['other_degree'] if data['other_degree'] else None scq.other_discipline = data['other_discipline'] if data['other_discipline'] else None scq.save() return JsonResponse({ 'id':False, 'quaLevel':qual.category_name, 'quaName':degree.degree_short_name, 'board':scq.school_college, 'quaDisc':disc.discipline_name, 'startYear':scq.start_year, 'endYear':scq.completion_year, 'percentage':scq.percentage_marks_cgpa, 'outoff':scq.cpga_outoff, 'other_degree':scq.other_degree, 'other_discipline':scq.other_discipline, }) else: scq = StudentCandidateQualification.objects.create( application=sca, degree=degree, school_college=data['board'], start_year=data['startYear'], completion_year=data['endYear'], discipline=disc, percentage_marks_cgpa=data['percentage'], cpga_outoff=data['outoff'] if data['outoff'] else None, other_degree=data['other_degree'] if data['other_degree'] else None, other_discipline=data['other_discipline'] if data['other_discipline'] else None ) return JsonResponse({ 'id':scq.id, 'quaLevel':qual.category_name, 'quaName':degree.degree_short_name, 'board':scq.school_college, 'quaDisc':disc.discipline_name, 'startYear':scq.start_year, 'endYear':scq.completion_year, 'percentage':scq.percentage_marks_cgpa, 'outoff':scq.cpga_outoff, 'other_degree':scq.other_degree, 'other_discipline':scq.other_discipline, }) @login_required def del_qualification(request): if request.is_ajax() and request.method == 'POST': data = json.loads(request.body.decode('utf-8')) scq = StudentCandidateQualification.objects.get(application__login_email=request.user, id=data['id']) scq.delete() return JsonResponse({'success': True}) @login_required def get_qualification(request): if request.is_ajax() and request.method == 'GET': data = request.GET.get('id', None) scq = StudentCandidateQualification.objects.get(application__login_email=request.user, id=data) return JsonResponse({ "quaLevel": scq.degree.qualification_category_id, "quaName": scq.degree_id, "board": scq.school_college, "quaDisc": scq.discipline_id, "startYear": scq.start_year, "endYear": scq.completion_year, "percentage": scq.percentage_marks_cgpa, "outoff": scq.cpga_outoff, "other_degree": scq.other_degree, "other_discipline": scq.other_discipline, }) @login_required def add_or_edit_exp(request): if request.is_ajax() and request.method == 'POST': data = json.loads(request.body.decode('utf-8')) sca = StudentCandidateApplication.objects.get(login_email=request.user) if data['name'] == 'EditAndSave': scwp = StudentCandidateWorkExperience.objects.get(application=sca, id=data['id']) scwp.organization=data['organization'] scwp.designations=data['designations'] scwp.start_date=data['start_date'] scwp.end_date=data['end_date'] scwp.save() start_date = datetime.strptime(scwp.start_date, "%Y-%m-%d").strftime("%d %b %Y") end_date = datetime.strptime(scwp.end_date, "%Y-%m-%d").strftime("%d %b %Y") return JsonResponse({ 'id':False, 'organization':scwp.organization, 'designations':scwp.designations, 'start_date':start_date, 'end_date':end_date }) else: scwp = StudentCandidateWorkExperience.objects.create( application=sca, organization=data['organization'], designations=data['designations'], start_date=data['start_date'], end_date=data['end_date'], ) start_date = datetime.strptime(scwp.start_date, "%Y-%m-%d").strftime("%d %b %Y") end_date = datetime.strptime(scwp.end_date, "%Y-%m-%d").strftime("%d %b %Y") return JsonResponse({ 'id':scwp.id, 'organization':scwp.organization, 'designations':scwp.designations, 'start_date':start_date, 'end_date':end_date }) @login_required def del_exp(request): if request.is_ajax() and request.method == 'POST': data = json.loads(request.body.decode('utf-8')) scwp = StudentCandidateWorkExperience.objects.get(application__login_email=request.user, id=data['id']) scwp.delete() return JsonResponse({'success': True}) @login_required def get_exp(request): if request.is_ajax() and request.method == 'GET': data = request.GET.get('id', None) scwp = StudentCandidateWorkExperience.objects.get(application__login_email=request.user, id=data) return JsonResponse({ 'organization':scwp.organization, 'designations':scwp.designations, 'start_date':scwp.start_date, 'end_date':scwp.end_date })
Editor is loading...
Leave a Comment