def get_job_list(self, filters=None): params = None if filters: params = self._validate_and_parse_filters(filters) # print 'params: ', params ## debug try: response = self.connection.get('', params) except Exception as e: # Do not try to make a second request without parameters here, # because cannot call self.connection.get() a second time and reusing the connection # without calling a getresponse() or close() or something beforehand. # (This would lead to a httplib CannotSendRequest() error!) # Let's just raise the error immediately. raise UWSError(str(e)) raw = response.read() try: job_list = models.Jobs(raw) except XMLSyntaxError as e: raise UWSError( "Malformatted response. Are you sure the host you specified is a IVOA UWS service?", raw) except Exception as e: raise e return job_list
def add_Applied(): """this function is called in jobs.js and adds an APPLIED job to jobs tables""" temp_list = [] data = request.get_json() #data = request.args['favorite'].split(',') appl_job_title = data['title'] appl_job_location = data['location'] appl_job_salary = data['salary'] appl_job_id = str(data['id']) appl_job_link = str(data['link']) #all_fav = models.Person.query.filter_by(id=user_id).first() all_applied = db.session.query( # pylint: disable=E1101 models.Person).filter_by(id=records[0]).first() if all_applied is None: print("Record is not founded") new_entry = models.Person(id=records[0], email=records[1], favorites=[], applied=[appl_job_id]) db.session.add(new_entry) db.session.commit() else: if appl_job_id not in all_applied.applied: temp_list = all_applied.applied client_id = all_applied.id temp_email = all_applied.email temp_fav = all_applied.favorites db.session.delete(all_applied) db.session.commit() temp_list.append(str(appl_job_id)) #if all_fav.favorites is None: new_entry = models.Person(id=client_id, email=temp_email, favorites=temp_fav, applied=temp_list) db.session.add(new_entry) db.session.commit() else: print("ID is already in applied list") applied = db.session.query( # pylint: disable=E1101 models.Jobs).filter_by(job_id=appl_job_id).first() if applied is None: print("Job is not founded") new_entry = models.Jobs(job_id=appl_job_id, job_title=appl_job_title, job_location=appl_job_location, job_salary=appl_job_salary, job_link=appl_job_link) db.session.add(new_entry) db.session.commit() else: print("Job is already in the database") return "Something went wrong"
def add_favourites(): """this function is called in jobs.js and adds a FAVORITED job to jobs tables""" temp_list = [] data = request.get_json() #data = request.args['favorite'].split(',') print("Returned dictionay from jobs.js") print() print(data) uni_id = data['user_id'] fav_job_title = data['title'] fav_job_location = data['location'] fav_job_salary = data['salary'] fav_job_id = str(data['id']) fav_job_link = data['link'] #all_fav = models.Person.query.filter_by(id=user_id).first() all_fav = db.session.query( # pylint: disable=E1101 models.Person).filter_by(id= uni_id ).first() if all_fav is None: print("Record is not founded") new_entry = models.Person(id=uni_id, email=global_email, favorites=[fav_job_id], applied=[]) db.session.add(new_entry) db.session.commit() else: if fav_job_id not in all_fav.favorites: temp_list = all_fav.favorites client_id = all_fav.id temp_email = all_fav.email temp_applied = all_fav.applied db.session.delete(all_fav) db.session.commit() temp_list.append(str(fav_job_id)) #if all_fav.favorites is None: new_entry = models.Person(id=client_id, email=temp_email,favorites=temp_list,applied=temp_applied) db.session.add(new_entry) db.session.commit() else: print("ID is already favorited") favorited = db.session.query( # pylint: disable=E1101 models.Jobs).filter_by(job_id= fav_job_id ).first() if favorited is None: print("Job is not founded") new_entry = models.Jobs(job_id=str(fav_job_id), job_title=fav_job_title, job_location=fav_job_location, job_salary=fav_job_salary, job_link=fav_job_link) db.session.add(new_entry) db.session.commit() else: print("Job is already in the database") return "Something went wrong"
def makeJobPosting(poster_id): job = models.Jobs() job.title = fake.text(50) job.description = fake.text(500) job.skills = fake.text(50) job.url = fake.url() job.poster_id = poster_id try: db.session.add(job) db.session.commit() except: db.session.rollback()
def addJob(): if not login.current_user.is_authenticated(): return redirect(url_for('index')) form = eforms.jobsForm(request.form) job = models.Jobs() form.populate_obj(job) try: db.session.add(job) db.session.commit() search.addJob(job.id) flash('Successfully added job!') return redirect(url_for('home')) except Exception as e: flash('Error posting job: %s' % e) return redirect(url_for('home'))
def get_job_list(self): try: response = self.connection.get('') except Exception as e: raise UWSError(str(e)) raw = response.read() try: job_list = models.Jobs(raw) except XMLSyntaxError as e: raise UWSError( "Malformatted response. Are you sure the host you specified is a IVOA UWS service?", raw) except Exception as e: raise e return job_list
def __init__(self): self.spiders_model = models.Spiders() self.jobs_model = models.Jobs()
def __init__(self): self.jobs_model = models.Jobs() self.webpages_model = models.Webpages()
def __init__(self): self.webpages_model = models.Webpages() self.spiders_model = models.Spiders() jobs_model = models.Jobs() self.job_id = jobs_model.get_id()