Permalink
Browse files

Add the csrf_exempt decorator to the add_result functions

Fixes #131
  • Loading branch information...
tobami committed Oct 28, 2012
1 parent 511001e commit 26b37c53657774ba58c3afda784887c3885d0623
Showing with 5 additions and 2 deletions.
  1. +3 −0 codespeed/views.py
  2. +2 −2 tools/save_single_result_via_api.py
View
@@ -11,6 +11,7 @@
from django.core.exceptions import ValidationError
from django.core.urlresolvers import reverse
from django.conf import settings
+from django.views.decorators.csrf import csrf_exempt
from codespeed.models import (Environment, Report, Project, Revision, Result,
Executable, Benchmark, Branch)
@@ -921,6 +922,7 @@ def save_result(data):
return (rev, exe, env), False
+@csrf_exempt
def add_result(request):
if request.method != 'POST':
return HttpResponseNotAllowed('POST')
@@ -936,6 +938,7 @@ def add_result(request):
return HttpResponse("Result data saved successfully", status=202)
+@csrf_exempt
def add_json_results(request):
if request.method != 'POST':
return HttpResponseNotAllowed('POST')
@@ -1,7 +1,5 @@
#!/usr/bin/env python
-
# -*- coding: utf-8 -*-
-
"""
Submit a single result via the RESTful API using requests
@@ -12,7 +10,9 @@
import json
import requests
+
def get_data():
+ """Helper function to build a valid POST request to save a result"""
result_data = {
'commitid': '/api/v1/revision/2/',
'branch': '/api/v1/branch/1/', # Always use default for trunk/master/tip

0 comments on commit 26b37c5

Please sign in to comment.