def createaccount(request): if request.user.is_authenticated(): return HttpResponseRedirect(reverse('profile')) if request.method == 'POST': form = CreateAccountForm(request.POST) if form.is_valid(): email = form.cleaned_data.get('email') password = form.cleaned_data.get('password') retype_password = form.cleaned_data.get('retype_password') if len(email)>30: username = email[0:30] else: username = email user = User.objects.create_user(username, email, password) user.first_name = form.cleaned_data.get('first_name') user.last_name = form.cleaned_data.get('last_name') user.save() applicant = Applicant(user = user, role = 1) applicant.save() user = authenticate(username=username, password=password) login(request, user) application_created(user.id) return HttpResponseRedirect(reverse('index')) else: form = CreateAccountForm() return render(request, 'create_account.html', {'form':form})
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 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 view_applicant_page(applicant_id): applicant = Applicant.find_applicant(applicant_id) if not applicant: flash('Applicant does not exist', 'danger') return redirect(url_for('admin.candidates_page')) return render_template('pages/account/view_applicant.html', applicant=applicant)
def no_additional_info(value): default_datetime = datetime.strptime('0001-01-01 12:00 AM', '%Y-%m-%d %I:%M %p') from app.models import Applicant applicant = Applicant.find_applicant(value) return (not applicant.source and applicant.interview_datetime == default_datetime)
def full_name(value): from app.models import Applicant applicant = Applicant.find_applicant(value) if applicant.middle_name != '': return f'{applicant.first_name} {applicant.middle_name} {applicant.last_name}' else: return f'{applicant.first_name} {applicant.last_name}'
def call_applicant_page(applicant_id): form = CalloutForm(request.form) applicant = Applicant.find_applicant(applicant_id) form.personal.address.data = applicant.address form.call.remarks.data = applicant.remarks if not applicant: flash('Applicant does not exist', 'danger') return redirect(url_for('hr.home_page')) return render_template('pages/account/hr/call_applicant.html', form=form, applicant=applicant)
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 edit_applicant_page(applicant_id): form = CalloutForm(request.form) applicant = Applicant.find_applicant(applicant_id) form.call.hr.validators.append(DataRequired()) form.personal.address.data = applicant.address form.call.remarks.data = applicant.remarks form.call.hr.choices = list() callers = Account.get_all_active_hr() for caller in callers: form.call.hr.choices.append((caller.id, caller.username)) if not applicant: flash('Applicant does not exist', 'danger') return redirect(url_for('admin.candidates_page')) return render_template('pages/account/edit_applicant.html', form=form, applicant=applicant)
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()
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'))
def call_applicant(applicant_id): form = CalloutForm(request.form) applicant = Applicant.find_applicant(applicant_id) form.personal.address.data = applicant.address form.call.remarks.data = applicant.remarks if form.validate_on_submit(): applicant.last_name = request.form.get('personal-last_name') applicant.first_name = request.form.get('personal-first_name') applicant.middle_name = request.form.get('personal-middle_name') applicant.email = request.form.get('personal-email') applicant.mobile1 = request.form.get('personal-mobile1') applicant.mobile2 = request.form.get('personal-mobile2') applicant.landline = request.form.get('personal-landline') applicant.address = request.form.get('personal-address') applicant.marital_status = request.form.get('personal-marital_status') applicant.course = request.form.get('education-course') applicant.graduation_year = request.form.get( 'education-graduation_year') applicant.applied_position = request.form.get( 'preference-applied_position') applicant.expected_salary = request.form.get( 'preference-expected_salary') applicant.preferred_shift = request.form.get('preference-shift') applicant.preferred_location = request.form.get('preference-location') applicant.status = request.form.get('call-disposition') applicant.remarks = request.form.get('call-remarks') applicant.source = request.form.get('additional-source') applicant.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 call = CallHistory(hr_id=current_user.id, applicant_id=applicant.id) db.session.add(call) db.session.commit() call_date_str = datetime.strftime(call.datetime, '%B %d, %Y %I:%M %p') flash( 'You called applicant {0} {1} on {2}'.format( applicant.first_name, applicant.last_name, call_date_str), 'success') return redirect(url_for('hr.home_page')) else: flash('Applicant not modified', '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/hr/call_applicant.html', form=form, applicant=applicant) return redirect( url_for('hr.call_applicant_page', applicant_id=applicant_id))
def no_scholastic_info(value): from app.models import Applicant applicant = Applicant.find_applicant(value) return (not applicant.educational_attainment and not applicant.course and not applicant.graduation_year)
def no_call_info(value): from app.models import Applicant applicant = Applicant.find_applicant(value) return (not applicant.status and not applicant.remarks)
def no_preference(value): from app.models import Applicant applicant = Applicant.find_applicant(value) return (not applicant.applied_position and not applicant.expected_salary and not applicant.preferred_shift and not applicant.preferred_location)