def register(): try: applicant = Applicant.query.filter_by( email=request.json['email']).first() if applicant is None: password = hash_password(request.json['password']) applicant = Applicant(email=request.json['email'], fname=request.json['fname'], lname=request.json['lname'], password=password) db.session.add(applicant) db.session.commit() return jsonify({ 'status': status.HTTP_201_CREATED, 'message': 'Congratulations, you are now a registered user' }) else: return jsonify({ 'status': status.HTTP_409_CONFLICT, 'message': 'Please use a different email' }) except Exception as e: return jsonify({ 'status': status.HTTP_500_INTERNAL_SERVER_ERROR, 'message': str(e) })
def apply(): form = BabySitterApplicationForm() if form.validate_on_submit(): upload_result = upload(form.id_document.data) applicant = Applicant(full_name=form.full_name.data, email=form.email.data, gender=form.gender.data, date_of_birth=form.date_of_birth.data, secure_token=token_urlsafe(16)) db.session.add(applicant) db.session.commit() applicant_id = ApplicantID(applicant_id=applicant.id, secure_token=token_urlsafe(16), url=upload_result['url']) db.session.add(applicant_id) db.session.commit() flash("Check your inbox new email has been sent!") return redirect( url_for('application.resend_confirm', email=applicant.email)) return render_template('application/application.html', form=form, title='Apply')
def import_from_csv(): callers = Account.get_all_active_hr() iterator = 0 if 'csv-input' not in request.files: flash('No File Uploaded') return redirect(url_for('admin.candidates_page')) csv_file = request.files.get('csv-input') if csv_file: directory = upload_file(csv_file) with open(directory, 'r', encoding='utf-8-sig') as file: headers = file.readline().strip().split(',') line = file.readline() while line: data = line.strip().split(',') applicant = Applicant(**dict(zip(headers,data))) applicant.hr_id = callers[iterator].id if iterator == len(callers)-1: iterator = 0 else: ++iterator db.session.add(applicant) line = file.readline() db.session.commit() file.close() return redirect(url_for('admin.candidates_page'))
def register(request): """ registration function """ keys = ['name', 'email', 'phone', 'recommender', 'reason'] data = request.POST new_applicant = Applicant(name=data['name'], email=data['email'], phone=data['phone'], recommender=data['recommender'], reason=data['reason'], date=timezone.now(), time=timezone.now()) new_applicant.save() request.session['registed'] = True return redirect('/#contact')
def create_applicant(user_id, name, student_id, college, major, gpa, language_type, language_reading, language_listening, language_speaking, language_writing, gre_verbal, gre_quantitative, gre_writing, research_id, project_id, recommendation_id, email=None): # TODO: add the authentication of power. # TODO: verify the repeation of datas. applicant = Applicant(name=name, student_id=student_id, college=college, major=major, gpa=gpa, language_type=language_type, language_reading=language_reading, language_listening=language_listening, language_speaking=language_speaking, language_writing=language_writing, gre_verbal=gre_verbal, gre_quantitative=gre_quantitative, gre_writing=gre_writing, research_id=research_id, project_id=project_id, recommendation_id=recommendation_id, email=email) db.session.add(applicant) db.session.commit() user = User.query.filter_by(id=user_id).first() user.applicant_id = applicant.id db.session.commit() db.session.add(applicant) db.session.commit() return {'success': 1, 'id': applicant.id}
def add_applicant(): form = CalloutForm(request.form) if form.validate_on_submit(): applicant = Applicant( last_name=request.form.get('personal-last_name'), first_name=request.form.get('personal-first_name'), middle_name=request.form.get('personal-middle_name'), email=request.form.get('personal-email'), mobile1=request.form.get('personal-mobile1'), mobile2=request.form.get('personal-mobile2'), landline=request.form.get('personal-landline'), address=request.form.get('personal-address'), marital_status=request.form.get('personal-marital_status'), course=request.form.get('education-course'), graduation_year=request.form.get('education-graduation_year'), applied_position=request.form.get('preference-applied_position'), expected_salary=request.form.get('preference-expected_salary'), preferred_shift=request.form.get('preference-shift'), preferred_location=request.form.get('preference-location'), status=request.form.get('call-disposition'), remarks=request.form.get('call-remarks'), source=request.form.get('additional-source'), hr_id=current_user.id) birthdate = request.form.get('personal-birthdate') if birthdate != '': applicant.birthdate = datetime.strptime('{0}'.format(birthdate), '%Y-%m-%d') educational_attainment = request.form.get('education-attainment') if educational_attainment != '': applicant.educational_attainment = educational_attainment interview_date = request.form.get('additional-interview_date') interview_time = request.form.get('additional-interview_time') if interview_date != '' and interview_time != '': timepiece = interview_time.split(" ") try: hour = timepiece[0].split(":")[0] minute = timepiece[0].split(":")[1] except IndexError as e: minute = '00' locale_time = timepiece[1] interview_datetime = datetime.strptime( '{0} {1}:{2} {3}'.format(interview_date, hour, minute, locale_time), '%Y-%m-%d %I:%M %p') applicant.interview_datetime = interview_datetime db.session.add(applicant) db.session.commit() flash( 'Applicant {0} {1} added successfully'.format( applicant.first_name, applicant.last_name), 'success') return redirect(url_for('hr.home_page')) else: flash('Applicant not created', 'danger') print('==================== ERRORS: add_applicant() ================') for err in form.errors: print(err) print('=============================================================') for err in form.personal.errors: print(err) print('=============================================================') for err in form.education.errors: print(err) print('=============================================================') for err in form.preference.errors: print(err) print('=============================================================') for err in form.call.errors: print(err) print('=============================================================') for err in form.additional.errors: print(err) return render_template('pages/account/add_applicant.html', form=form) return redirect(url_for('hr.add_applicant_page'))
course = session.query(Course).filter( Course.title == group_item.get('course')).first() group = Group(id=group_item.get('id'), title=group_item.get('title'), status=group_item.get('status'), course=course, seats=group_item.get('seats'), start_at=date.date()) session.add(group) session.commit() for applicant_item in applicants_data: course = session.query(Course).filter( Course.title == applicant_item.get('course')).first() group = session.query(Group).filter( Group.title == applicant_item.get('group')).first() applicant = Applicant(name=applicant_item.get('name'), phone=applicant_item.get('phone'), email=applicant_item.get('email'), status=applicant_item.get('status'), course=course, group=group) session.add(applicant) session.commit()