Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
7.0 kB
3
Indexable
Never
def post(self, request, *args, **kwargs):
        pg_code = self.kwargs.get('pg_code', None)
        pg=Program.objects.get(program_code=pg_code)
        current_step = self.steps.current
        form = self.get_form(data=request.POST, files=request.FILES)
        if form.is_valid():
            # instance = form.save(commit=False)
            if current_step == '0':                                             #Personal_Details
                try:
                    instance = StudentCandidateApplication.objects.get(login_email=request.user)
                except StudentCandidateApplication.DoesNotExist:
                    instance.login_email = request.user
                instance.login_email = request.user
                instance.program = pg
                instance.full_name = form.cleaned_data['full_name']
                instance.gender = form.cleaned_data['gender']
                instance.date_of_birth = form.cleaned_data['date_of_birth']
                instance.address_line_1 = form.cleaned_data['address_line_1']
                instance.address_line_2 = form.cleaned_data['address_line_2']
                instance.address_line_3 = form.cleaned_data['address_line_3']
                instance.city = form.cleaned_data['city']
                instance.state = form.cleaned_data['state']
                instance.country = form.cleaned_data['country']
                instance.pin_code = form.cleaned_data['pin_code']
                instance.fathers_name = form.cleaned_data['fathers_name']
                instance.mothers_name = form.cleaned_data['mothers_name']
                instance.nationality = form.cleaned_data['nationality']
                instance.phone = form.cleaned_data['phone']
                instance.mobile = form.cleaned_data['mobile']
                instance.email_id = form.cleaned_data['email_id']
                instance.alternate_email_id = form.cleaned_data['alternate_email_id']
                instance.current_location = form.cleaned_data['current_location']
                instance.save()
                if form.cleaned_data['signature_file']:
                    instance.signature_file.save(form.cleaned_data['signature_file'].name, form.cleaned_data['signature_file'])
                instance.linkedin_profile = form.cleaned_data['linkedin_profile']
                instance.teaching_mode = form.cleaned_data['teaching_mode']
                instance.save()
                if form.cleaned_data['photo_file']:
                    photo_file = form.cleaned_data['photo_file']
                    photo_instance = ApplicationDocument.objects.filter(application=instance, document_id=38).first()

                    if photo_instance:
                        photo_instance.file.save(photo_file.name, photo_file)
                    else:
                        photo_instance = ApplicationDocument.objects.create(
						    application=instance,
						    document_id=38,
						    file=photo_file)

            # if current_step == '1':                                         #Educational_Details
			# 	# need to save in SCQ model in loop
            #     sca = StudentCandidateApplication.objects.get(email_id = request.user.email)
            #     instance = StudentCandidateQualification.objects.get(application = sca)  # 
            #     instance.other_degree = form.cleaned_data['other_degree']
            #     instance.other_discipline = form.cleaned_data['other_discipline']
            #     instance.cpga_outoff = form.cleaned_data['cpga_outoff']
            #     instance.school_college = form.cleaned_data['school_college']
            #     instance.start_year = form.cleaned_data['start_year']
            #     instance.completion_year = form.cleaned_data['completion_year']
            #     instance.percentage_marks_cgpa = form.cleaned_data['percentage_marks_cgpa']
            #     instance.cpga_outoff = form.cleaned_data['cpga_outoff']
            #     instance.degree = form.cleaned_data['degree']
            #     instance.discipline = form.cleaned_data['discipline']
            #     instance.save()

			# 	# need to save in SCA  
            #     instance = sca
            #     instance.programming_flag = form.cleaned_data['programming_flag']
            #     instance.math_proficiency_level = form.cleaned_data['math_proficiency_level']
            #     instance.prior_student_flag = form.cleaned_data['prior_student_flag']
            #     instance.bits_student_id = form.cleaned_data['bits_student_id']
            #     instance.parallel_studies_flag = form.cleaned_data['parallel_studies_flag']
            #     instance.other_bits_prog_flag = form.cleaned_data['other_bits_prog_flag']
            #     instance.other_uni_name = form.cleaned_data['other_uni_name']
            #     instance.other_uni_prog = form.cleaned_data['other_uni_prog']
            #     instance.present_bits_student_id = form.cleaned_data['present_bits_student_id']

            # if current_step == '2':                                                 #Employment_Details
            #     instance = StudentCandidateApplication.objects.get(email_id = request.user.email)
            #     instance.current_employment_status = self.cleaned_data['current_employment_status']
            #     instance.current_organization = self.cleaned_data['current_organization']
            #     instance.work_location = self.cleaned_data['work_location']
            #     instance.current_designation = self.cleaned_data['current_designation']
            #     instance.current_org_industry = self.cleaned_data['current_org_industry']
            #     instance.current_org_employment_date = self.cleaned_data['current_org_employment_date']
            #     instance.save()
	
            #     instance = StudentCandidateWorkExperience.objects.get(application = instance)
            #     instance.organization = self.cleaned_data['organization']
            #     instance.start_date = self.cleaned_data['start_date']
            #     instance.end_date = self.cleaned_data['end_date']
            #     instance.designations = self.cleaned_data['designations']
			
            # if current_step == '3':                                                 #Undertaking
            #     instance = StudentCandidateApplication.objects.get(email_id = request.user.email)
            #     instance.cc_backend_progr = form.cleaned_data['cc_backend_progr']
            #     instance.cc_rdbms = form.cleaned_data['cc_rdbms']
            #     instance.cc_comp_nw = form.cleaned_data['cc_comp_nw']
            #     instance.cc_prog_course = form.cleaned_data['cc_prog_course']
            #     instance.cc_co_os_course = form.cleaned_data['cc_co_os_course']
            #     instance.cc_ds_algo_course = form.cleaned_data['cc_ds_algo_course'] 
            # instance.save() 
            return self.render_next_step(form)
        else:
			#if error render same form
            return self.render(form, **kwargs)
Leave a Comment