Exemple #1
0
def save_report(req):
    if req.method != 'POST':
        return HttpResponse('ya gotta send a post request')
    form = json.loads(req.body)

    problem = form['problem']
    explanation = form['explanation']
    report = Report()
    report.problem = problem
    report.explanation = explanation
    report.ip_address = get_client_ip(req)
    scholarship_id = decrypt_sk(form['sk'])
    scholarship = Scholarship.objects.get(id=scholarship_id)
    report.scholarship = scholarship
    report.save()
    # tell sentry we got a report

    client.captureMessage("Scholarship problem reported.", problem=problem, explanation=explanation)

    return HttpResponse('{"msg": "thanks"}', content_type='application/json')