def view_scholarship(request, scholarship_key):
    if not scholarship_key:
        scholarship_key = request.GET.get('sk')
    scholarship_id = request_utils.decrypt_sk(scholarship_key)

    scholarship = Scholarship.objects.get(id=scholarship_id)
    # get description html ready
    if '<div>' in scholarship.description:
        description = scholarship.description
    else:
        description = linebreaks(scholarship.description)
    if scholarship.additional_restriction and '<div>' in scholarship.additional_restriction:
        additional_restriction = scholarship.additional_restriction
    else:
        additional_restriction = linebreaks(scholarship.additional_restriction)

    context = {'scholarship_model': scholarship,
               'scholarship_key': scholarship_key,
               'page_title': scholarship.title,
               'description': description,
               'additional_restriction': additional_restriction,
               'environment': settings.ENVIRONMENT
    }
    return render_to_response('view_scholarship.html',
                              context,
                              context_instance=RequestContext(request))
def view_scholarship(request, scholarship_key):
    if not scholarship_key:
        scholarship_key = request.GET.get('sk')
    scholarship_id = request_utils.decrypt_sk(scholarship_key)

    scholarship = Scholarship.objects.get(id=scholarship_id)
    context = {'scholarship_model':ain. scholarship,
               'scholarship_key': scholarship_key,
               'page_title': scholarship.title
    }
    return render_to_response('view_scholarship.html',
                              context,
                              context_instance=RequestContext(request))
Exemple #3
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')