class JobTestCase(TestCase): def setUp(self): self.org = Organization() self.org.save() self.org2 = Organization() self.org2.save() self.project = Project(organization=self.org) self.project.save() self.workstream = Workstream(project=self.project) self.workstream.save() self.status1 = JobStatus(organization=self.org) self.status1.save() self.status2 = JobStatus(organization=self.org2) self.status2.save() self.job = Job(workstream=self.workstream, status=self.status1) self.job.save() def tearDown(self): self.org.delete() self.org2.delete() def test__job_workstream__matches(self): self.assertEqual(self.workstream, self.job.workstream) def test__save__throws_when_org_doesnt_match_workstream(self): job = Job(workstream=self.workstream, status=self.status2) self.assertRaises(PermissionDenied, lambda: job.save())
def seed_db(): """Seeds the database.""" worker= User( email='*****@*****.**', ) db.session.add(worker) boss = User( email='*****@*****.**', ) db.session.add(boss) db.session.commit() job1 = Job( name='Mowing the Lawn', description="""I need someone to help me mow the lawn during the timetime that I will be away during the summer. My garden is approximately 20 square meters, and I have all the required machinery for doing so""", status="Available", start_time="2018-07-15T15:00:00", end_time="2018-07-15T16:00:00", worker_rating=3.7, employer_rating=5.0, hourly_bitcoin_rate=0.02 ) job2 = Job( name='Clean Apartment', description="Looking for someone to clean my apartment! I live in" + " the Upper East Side and have no cleaning supplies at my place." " However I will offer great company while cleaning, and will provide" + " lunch.", status="Pending", start_time="2018-07-21T11:00:00", end_time="2018-07-21T12:30:00", worker_rating=3.7, employer_rating=4.0, hourly_bitcoin_rate=0.01 ) job3 = Job( name='Baby Sitting', description="Hello guys, me and my husband are going on a date," + " and are looking for a babysitter. We live in the Brooklyn, and" + " would prefer someone from the area. Ideally, if you speak spanish" + " However I will offer great company while cleaning, and will provide" + " lunch.", status="Pending", start_time="2018-07-21T11:00:00", end_time="2018-07-21T12:30:00", worker_rating=3.7, employer_rating=4.0, hourly_bitcoin_rate=0.01, worker=1 ) db.session.add(job1) db.session.add(job2) db.session.add(job3) db.session.commit()
def setUp(self): self.org = Organization() self.org.save() self.org2 = Organization() self.org2.save() self.project = Project(organization=self.org) self.project.save() self.workstream = Workstream(project=self.project) self.workstream.save() self.status1 = JobStatus(organization=self.org) self.status1.save() self.status2 = JobStatus(organization=self.org2) self.status2.save() self.job = Job(workstream=self.workstream, status=self.status1) self.job.save()
def post_job(): details = request.json job = Job() for key, value in details.items(): try: setattr(job, key, value) except: pass db.session.add(job) db.session.commit() job_object = db_object_as_dict(job) response_object = {'status': 'success', 'data': job_object} return jsonify(response_object), 200
def add(event_id): form = JobForm(request.form) if form.validate_on_submit(): try: job = Job(name=form.name.data, hour=form.hour.data, minute=form.minute.data, second=form.second.data, event_id=event_id, weekdays_only=form.weekdays_only.data) job_dao.create_job(job) flash('Job added.', 'success') return redirect(url_for("job.view", event_id=event_id)) except Exception as e: flash('Job add fail {}'.format(e), 'danger') print(e) return render_template('job/add_edit.html', form=form) return render_template('job/add_edit.html', form=form)
db.session.commit() logging.info('Recruiter Created') emp_obj = Employee.query.filter_by(email='*****@*****.**').first() emp_user_obj = Users(emplid=emp_obj.emplid, deptid=2, type='Recruiter', psw=generate_password_hash('r1')) db.session.add(emp_user_obj) db.session.commit() ######################################################################################################################## jobs_obj = Job(title='Job Title 1', salary_min=30000, salary_max=60000, open_dt=datetime.date.today(), location='New York', descr='Job Description 1', status='Open', visibility=1, deptid=2) db.session.add(jobs_obj) db.session.commit() logging.info('Job 1 Created') jobs_obj = Job(title='Job Title 2', salary_min=35000, salary_max=70000, open_dt=datetime.date.today(), location='California', descr='Job Description 2', status='Open',
def staff_jobs_view_create(): current_emp_obj = Employee.query.filter_by( email=current_user.__dict__['email']).first() current_user_obj = Users.query.filter_by( emplid=current_emp_obj.emplid).first() isRecruiter = current_user_obj.type dept_names = Department.query.all() department_list = [x.name for x in dept_names] if isRecruiter == 'Recruiter': final_display_list = [] all_application_obj = Application.query.all() if all_application_obj != []: for application in all_application_obj: application = application.__dict__ job_id = application['jobid'] applicant_id = application['app_id'] job_obj = Job.query.filter_by(jobid=job_id).first() user_obj = Applicant.query.filter_by( app_id=applicant_id).first() resume_obj = Resume.query.filter_by( app_id=applicant_id).first() temp_dict = {} temp_dict["job_id"] = job_id temp_dict["job_title"] = job_obj.title temp_dict["user_name"] = user_obj.name temp_dict["applicant_id"] = applicant_id temp_dict["user_resume"] = resume_obj.resume temp_dict["status"] = application["status"] temp_dict["applied_date"] = datetime.datetime.strftime( application["appl_dt"], '%d %b %Y') final_display_list.append(temp_dict) elif isRecruiter == 'Hiring Manager': final_display_list = [] all_application_obj = Application.query.all() list_of_jobs = Job.query.filter_by( deptid=current_emp_obj.__dict__['deptid']).all() if all_application_obj != []: for application in all_application_obj: application = application.__dict__ job_id = application['jobid'] applicant_id = application['app_id'] for jobs in list_of_jobs: if jobs.jobid == job_id: user_obj = Applicant.query.filter_by( app_id=applicant_id).first() resume_obj = Resume.query.filter_by( app_id=applicant_id).first() temp_dict = {} temp_dict["job_id"] = job_id temp_dict["job_title"] = jobs.title temp_dict["user_name"] = user_obj.name temp_dict["applicant_id"] = applicant_id temp_dict["user_resume"] = resume_obj.resume temp_dict["status"] = application["status"] temp_dict["applied_date"] = datetime.datetime.strftime( application["appl_dt"], '%d %b %Y') final_display_list.append(temp_dict) if request.method == 'POST': form = request.form.get('action', None) if form == 'create_job': status = request.form.get('status', None) desc = request.form.get('job_desc', None) title = request.form.get('job_title', None) location = request.form.get('location', None) min_sal = request.form.get('min_salary', None) max_sal = request.form.get('max_salary', None) visibility = request.form.get('gridRadios', None) department = request.form.get('department', None) if visibility == 'visible': visibility = '1' else: visibility = '0' dept_obj = Department.query.filter_by(name=department).first() if title == None or title == '': return render_template('staff_jobs_view_create.html', warning='Job Title cannot be empty') if desc == None or desc == '': return render_template( 'staff_jobs_view_create.html', warning='Job Description cannot be empty') if visibility == None or visibility == '': return render_template( 'staff_jobs_view_create.html', warning='Job Visibility cannot be empty') if location == None or location == '': return render_template('staff_jobs_view_create.html', warning='Job Location cannot be empty') new_job_obj = Job(title=title, status=status, descr=desc, location=location, salary_min=min_sal, salary_max=max_sal, deptid=dept_obj.deptid, visibility=visibility, open_dt=datetime.date.today()) db.session.add(new_job_obj) db.session.commit() logging.debug('New Job {title} Created'.format(title=title)) return redirect(url_for('staff.staff_jobs_view_create')) else: if request.method == 'POST': res = request.form.to_dict() res = res["action"].replace("'", '"') ap = res[1:-8] action = res[-6:-1] res = json.loads(ap) if action == '"rev"': app_name = Applicant.query.filter_by( app_id=res['applicant_id']).first().name job_name = Job.query.filter_by( jobid=res['job_id']).first().title logging.debug('{aname} Reviewed for Job {jname}'.format( aname=app_name, jname=job_name)) department_list, final_display_list = commonSaveLogic( "Reviewed", res) if action == '"rej"': app_name = Applicant.query.filter_by( app_id=res['applicant_id']).first().name job_name = Job.query.filter_by( jobid=res['job_id']).first().title logging.debug('{aname} Rejected for Job {jname}'.format( aname=app_name, jname=job_name)) department_list, final_display_list = commonSaveLogic( "Rejected", res) if action == '"int"': app_name = Applicant.query.filter_by( app_id=res['applicant_id']).first().name job_name = Job.query.filter_by( jobid=res['job_id']).first().title logging.debug('{aname} Interviewed for Job {jname}'.format( aname=app_name, jname=job_name)) department_list, final_display_list = commonSaveLogic( "Interviewed", res) email_thread = threading.Thread( target=email_sending_logic_interview, args=(res['job_id'], res['applicant_id'])) email_thread.start() if action == '"off"': app_name = Applicant.query.filter_by( app_id=res['applicant_id']).first().name job_name = Job.query.filter_by( jobid=res['job_id']).first().title logging.debug('{aname} Offered for Job {jname}'.format( aname=app_name, jname=job_name)) department_list, final_display_list = commonSaveLogic( "Offer", res) email_thread = threading.Thread( target=email_sending_logic_offer, args=(res['job_id'], res['applicant_id'])) email_thread.start() if action == '"hir"': app_name = Applicant.query.filter_by( app_id=res['applicant_id']).first().name job_name = Job.query.filter_by( jobid=res['job_id']).first().title logging.debug('{aname} Hired for Job {jname}'.format( aname=app_name, jname=job_name)) rejectOtherCandidates(res['job_id'], res['applicant_id']) department_list, final_display_list = commonSaveLogic( "Hired", res) email_thread = threading.Thread(target=email_send, args=(res['job_id'], res['applicant_id'])) email_thread.start() return render_template('staff_jobs_view_create.html', department_list=department_list, final_display_list=final_display_list)
def test__save__throws_when_org_doesnt_match_workstream(self): job = Job(workstream=self.workstream, status=self.status2) self.assertRaises(PermissionDenied, lambda: job.save())