Beispiel #1
0
def create_event(institute_id, case_id):
    institute = validate_user(current_user, institute_id)
    case_model = store.case(institute_id, case_id)

    link = request.form.get('link')
    content = request.form.get('content')
    variant_id = request.args.get('variant_id')

    if variant_id:
        # create a variant comment
        variant_model = store.variant(variant_id)
        level = request.form.get('level', 'specific')
        store.comment(institute,
                      case_model,
                      current_user,
                      link,
                      variant=variant_model,
                      content=content,
                      comment_level=level)

    else:
        # create a case comment
        store.comment(institute,
                      case_model,
                      current_user,
                      link,
                      content=content)

    return redirect(request.referrer)
Beispiel #2
0
def cases(institute_id):
    """Fetch all cases belonging to a specific institute.

  Args:
    institute_id (str): unique institute display name

  Returns:
    Response: jsonified MongoDB objects as a list
  """
    institute = validate_user(current_user, institute_id)
    case_models = store.cases(collaborator=institute_id)
    non_archived = (case for case in case_models if case.status != 'archived')
Beispiel #3
0
def case_synopsis(institute_id, case_id):
  """Update (PUT) synopsis of a specific case."""
  institute = validate_user(current_user, institute_id)
  case_model = store.case(institute_id, case_id)
  new_synopsis = request.json.get('synopsis', case_model.synopsis)

  if case_model.synopsis != new_synopsis:
    # create event only if synopsis was actually changed
    link = url_for('core.case', institute_id=institute_id, case_id=case_id)
    store.update_synopsis(institute, case_model, current_user, link,
                          content=new_synopsis)

  return jsonify(synopsis=case_model.synopsis, ok=True)
Beispiel #4
0
def case_status(institute_id, case_id):
  """Update status of a specific case."""
  institute = validate_user(current_user, institute_id)
  case_model = store.case(institute_id, case_id)

  status = request.form.get('status', case_model.status)
  link = url_for('core.case', institute_id=institute_id, case_id=case_id)

  if status == 'archive':
    store.archive_case(institute, case_model, current_user, status, link)
  else:
    store.update_status(institute, case_model, current_user, status, link)

  return redirect(request.referrer)
Beispiel #5
0
def cases(institute_id):
  """Fetch all cases belonging to a specific institute.

  Args:
    institute_id (str): unique institute display name

  Returns:
    Response: jsonified MongoDB objects as a list
  """
  institute = validate_user(current_user, institute_id)
  case_models = store.cases(collaborator=institute_id)
  non_archived = (case for case in case_models if case.status != 'archived')
  raw_models = [model.to_mongo() for model in case_models]
  return Response(dumps(raw_models), mimetype='application/json; charset=utf-8')
Beispiel #6
0
def manual_rank(institute_id, case_id, variant_id):
  """Update the manual variant rank for a variant."""
  institute = validate_user(current_user, institute_id)
  case_model = store.case(institute_id, case_id)
  variant_model = store.variant(document_id=variant_id)

  # update the manual rank
  new_manual_rank = int(request.json.get('manual_rank'))
  link = request.referrer

  store.update_manual_rank(institute, case_model, current_user, link,
                           variant_model, new_manual_rank)

  return jsonify(manual_rank=variant_model.manual_rank, ok=True)
Beispiel #7
0
def case_status(institute_id, case_id):
    """Update status of a specific case."""
    institute = validate_user(current_user, institute_id)
    case_model = store.case(institute_id, case_id)

    status = request.form.get('status', case_model.status)
    link = url_for('core.case', institute_id=institute_id, case_id=case_id)

    if status == 'archive':
        store.archive_case(institute, case_model, current_user, status, link)
    else:
        store.update_status(institute, case_model, current_user, status, link)

    return redirect(request.referrer)
Beispiel #8
0
def manual_rank(institute_id, case_id, variant_id):
    """Update the manual variant rank for a variant."""
    institute = validate_user(current_user, institute_id)
    case_model = store.case(institute_id, case_id)
    variant_model = store.variant(document_id=variant_id)

    # update the manual rank
    new_manual_rank = int(request.json.get('manual_rank'))
    link = request.referrer

    store.update_manual_rank(institute, case_model, current_user, link,
                             variant_model, new_manual_rank)

    return jsonify(manual_rank=variant_model.manual_rank, ok=True)
Beispiel #9
0
def case_synopsis(institute_id, case_id):
    """Update (PUT) synopsis of a specific case."""
    institute = validate_user(current_user, institute_id)
    case_model = store.case(institute_id, case_id)
    new_synopsis = request.json.get('synopsis', case_model.synopsis)

    if case_model.synopsis != new_synopsis:
        # create event only if synopsis was actually changed
        link = url_for('core.case', institute_id=institute_id, case_id=case_id)
        store.update_synopsis(institute,
                              case_model,
                              current_user,
                              link,
                              content=new_synopsis)

    return jsonify(synopsis=case_model.synopsis, ok=True)
Beispiel #10
0
def create_event(institute_id, case_id):
  institute = validate_user(current_user, institute_id)
  case_model = store.case(institute_id, case_id)

  link = request.form.get('link')
  content = request.form.get('content')
  variant_id = request.args.get('variant_id')

  if variant_id:
    # create a variant comment
    variant_model = store.variant(variant_id)
    level = request.form.get('level', 'specific')
    store.comment(institute, case_model, current_user, link, variant=variant_model,
                  content=content, comment_level=level)

  else:
    # create a case comment
    store.comment(institute, case_model, current_user, link, content=content)

  return redirect(request.referrer)
Beispiel #11
0
def delete_event(institute_id, case_id, event_id=None):
  validate_user(current_user, institute_id)
  store.delete_event(event_id)
  return redirect(request.referrer)
Beispiel #12
0
def delete_event(institute_id, case_id, event_id=None):
    validate_user(current_user, institute_id)
    store.delete_event(event_id)
    return redirect(request.referrer)