コード例 #1
0
def update_status_internal_endpoint():
  """
  Updates the status of a job application

  Request body:
  - `id`: Job application ID
  - `new_status`: New status of the job application
  """
  content = request.json
  headers = request.headers

  application_id = content.get('id', '')
  if not application_id:
    return jsonify(missing_application_id_error)

  application = Application.query.filter_by(id=application_id).first()
  if not application:
    return jsonify(application_not_found_error)

  if not validate_authentication(headers):
    return jsonify({"status": auth_error_admin})

  user_id = query_auth(headers['Authorization'])['_id']
  new_status = content.get('new_status', '')
  return jsonify(update_status(application_id, new_status, user_id))
コード例 #2
0
def get_application_by_job_endpoint(job_id):
  """
  Gets all job postings to an internal job
  """
  headers = request.headers

  if not validate_authentication(headers, admin=True):
    return jsonify({"status": auth_error_admin})

  return jsonify(get_applications_internal(job_id, 'job'))
コード例 #3
0
def get_interview_questions_endpoint(application_id):
  """
  Gets all interview questions
  """
  headers = request.headers

  if not validate_authentication(headers):
    return jsonify({"status": auth_error})

  user_id = query_auth(headers['Authorization'])['_id']
  return jsonify(get_interview_questions(application_id, user_id))
コード例 #4
0
def get_application(application_id):
  """
  Gets a single application by its unique ID
  """
  headers = request.headers

  if not validate_authentication(headers):
    return jsonify({"status": auth_error})

  user_id = query_auth(headers['Authorization'])['_id']
  return jsonify(get_application_by_id(application_id, user_id))
コード例 #5
0
def get_application_by_user_endpoint(application_type=None):
  """
  Gets job postings for a specific user.
  """
  headers = request.headers

  if not validate_authentication(headers):
    return jsonify({"status": auth_error})

  user_id = query_auth(headers['Authorization'])['_id']

  applications_external, applications_internal = [], []
  if application_type == "external" or not application_type:
    applications_external = get_applications_external(user_id)
  if application_type == "internal" or not application_type:
    applications_internal = get_applications_internal(user_id, 'user')
  return jsonify(applications_external + applications_internal)
コード例 #6
0
def update_interview_questions_endpoint():
  """
  Updates an interview question

  Request body:
  - `id`: Question ID
  - `new_question`: New question for that interview
  """
  content = request.json
  headers = request.headers

  if not validate_authentication(headers):
    return jsonify({"status": auth_error})

  if 'new_question' not in content or 'id' not in content:
    return jsonify(missing_question_or_id_error)
  return jsonify(update_interview_question(content['id'], content['new_question']))
コード例 #7
0
def update_comment_endpoint():
  """
  Updates the comment of a job application

  Request body:
  - `id`: Job application ID
  - `new_comment`: New comment for the application
  """
  content = request.json
  headers = request.headers

  if not validate_authentication(headers):
    return jsonify({"status": auth_error_admin})

  user_id = query_auth(headers['Authorization'])['_id']
  application_id = content.get('id', '')
  new_comment = content.get('new_comment', '')
  return jsonify(update_comment(application_id, new_comment, user_id))
コード例 #8
0
def apply_internal_endpoint():
  """
  Enables user to apply to an external job posting.

  Request body:
  - `job_id`: ID of the job the user is applying to
  - `resume`: Handy tool for applying to jobs
  """
  content = request.json
  headers = request.headers

  if not validate_authentication(headers):
    return jsonify({"status": auth_error})

  user_id = query_auth(headers['Authorization'])['_id']
  job_id = content.get('job_id', '')
  resume = content.get('resume', '')
  comment = content.get('comment', '')
  return jsonify(apply_internal(user_id, job_id, resume, comment))
コード例 #9
0
def withdraw_internal_application_endpoint():
  """
  Withdraws an application to a given job posting

  Request body:
  - `id`: Job application ID
  """
  content = request.json
  headers = request.headers

  if not validate_authentication(headers):
    return jsonify({"status": auth_error})

  if 'id' not in content:
    return jsonify(missing_application_id_error)

  application_id = content['id']
  user_id = query_auth(headers['Authorization'])['_id']

  return jsonify(withdraw_application(application_id, user_id))
コード例 #10
0
def check_if_application_exists():
  """
  Created at the request of Camilo, simply returns whether an application
  exists or not given a URL and an authentication token.
  """
  headers = request.headers

  if not validate_authentication(headers):
    return jsonify({"status": auth_error})

  user_id = query_auth(headers['Authorization'])['_id']
  url = request.args.get('url')
  if not url:
    return jsonify({"status": False})
  applications = Application.query.filter_by(user_id=user_id).all()
  for application in applications:
    external_application = External.query.filter_by(application_id=application.id, url=url).first()
    if external_application:
      return jsonify({"status": True})
  return jsonify({"status": False})
コード例 #11
0
def add_interview_question_endpoint():
  """
  Enables user to track interview questions

  Request body:
  - `application_id`: ID of the application to which the question maps to
  - `question`: Interview question
  """
  content = request.json
  headers = request.headers

  if not validate_authentication(headers):
    return jsonify({"status": auth_error})

  user_id = query_auth(headers['Authorization'])['_id']
  try:
    application_id = content['application_id']
    question = content['question']
    title = content['title']
  except Exception as e:
    print(e)
    return jsonify(add_interview_question_error)
  return jsonify(add_interview_question(application_id, question, title, user_id))
コード例 #12
0
def apply_external_endpoint():
  """
  Enables user to apply to an external job posting.

  Request body:
  - `url`: URL of the external posting
  - `position`: Job position of the external posting
  - `company`: Company where job takes place
  - `resume`: Handy tool for applying to jobs
  - `date_posted`: When the application was posted
  - `deadline`: Deadline to apply for the job
  """
  content = request.json
  headers = request.headers

  if not validate_authentication(headers):
    return jsonify({"status": auth_error})

  url, position, company = content.get("url", ""), content.get('position', ""), content.get('company', "")
  date_posted, deadline = content.get('date_posted', ""), content.get('deadline', "")
  resume, status, comment = content.get('resume', ""), content.get("status", "Applied"), content.get('comment', '')
  user_id = query_auth(headers['Authorization'])['_id']
  return jsonify(apply_external(user_id, url, position, company, resume,
                                date_posted, deadline, comment, status=status))