예제 #1
0
def download_transcript(
):  # pylint: disable-msg=inconsistent-return-statements
    """Request for viewing unofficial transcript"""
    try:
        req_json = request.get_json(force=True)
    except TypeError:
        return jsonify(message="Invalid json input"), 400

    student = req_json['student']
    client_user_id = req_json['client_user_id']
    args = {'clickwrap_id': req_json['clickwrap_id']}

    try:
        # Gets all the users that have agreed to the clickwrap
        user_agreements = Clickwrap.get_user_agreements(args, session)
    except ApiException as exc:
        return process_error(exc)

    if client_user_id not in user_agreements:
        abort(404)

    student_name = f"{student['first_name']} {student['last_name']}"
    transcript = render_transcript(student_name)
    response = Response(transcript, mimetype='text/html')
    response.headers['Content-Disposition'] = (
        'attachment;filename=Unofficial_transcript.html')
    return response
예제 #2
0
def insurance_renewal():
    """Create a clickwrap for submitting insurance policy renewal"""
    try:
        try:
            req_json = request.get_json(force=True)
            clickwrap_args = {
                'terms_name': req_json['terms-name'],
                'display_name': req_json['display-name'],
            }
        except TypeError:
            return jsonify(message='Invalid JSON input'), 400
        clickwrap = Clickwrap.create(clickwrap_args)
    except ApiException as ex:
        return process_error(ex)
    return jsonify(clickwrap=clickwrap)
def transcript_clickwrap():
    """Create clickwrap for an unofficial transcript"""
    try:
        try:
            req_json = request.get_json(force=True)
            clickwrap_args = {
                'terms_name': req_json['terms-name'],
                'terms_transcript': req_json['terms-transcript'],
                'display_name': req_json['display-name'],
            }
        except TypeError:
            return jsonify(message='Invalid json input'), 400
        clickwrap = Clickwrap.create(clickwrap_args)
    except ApiException as ex:
        return process_error(ex)
    return jsonify(clickwrap=clickwrap)