Skip to content

Commit 26b37c5

Browse files
committed
Add the csrf_exempt decorator to the add_result functions
Fixes tobami#131
1 parent 511001e commit 26b37c5

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

codespeed/views.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from django.core.exceptions import ValidationError
1212
from django.core.urlresolvers import reverse
1313
from django.conf import settings
14+
from django.views.decorators.csrf import csrf_exempt
1415

1516
from codespeed.models import (Environment, Report, Project, Revision, Result,
1617
Executable, Benchmark, Branch)
@@ -921,6 +922,7 @@ def save_result(data):
921922
return (rev, exe, env), False
922923

923924

925+
@csrf_exempt
924926
def add_result(request):
925927
if request.method != 'POST':
926928
return HttpResponseNotAllowed('POST')
@@ -936,6 +938,7 @@ def add_result(request):
936938
return HttpResponse("Result data saved successfully", status=202)
937939

938940

941+
@csrf_exempt
939942
def add_json_results(request):
940943
if request.method != 'POST':
941944
return HttpResponseNotAllowed('POST')

tools/save_single_result_via_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#!/usr/bin/env python
2-
32
# -*- coding: utf-8 -*-
4-
53
"""
64
Submit a single result via the RESTful API using requests
75
@@ -12,7 +10,9 @@
1210
import json
1311
import requests
1412

13+
1514
def get_data():
15+
"""Helper function to build a valid POST request to save a result"""
1616
result_data = {
1717
'commitid': '/api/v1/revision/2/',
1818
'branch': '/api/v1/branch/1/', # Always use default for trunk/master/tip

0 commit comments

Comments
 (0)