Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b4fa8b6

Browse files
committed
Accept update doc request in POST rather than GET
1 parent 0068a5e commit b4fa8b6

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

doc_tasks/views.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
from django.core.urlresolvers import reverse
44
from django.conf import settings
55
from django.shortcuts import render, get_object_or_404
6-
from django.views.decorators.http import require_GET
6+
from django.views.decorators.csrf import csrf_exempt
7+
from django.views.decorators.http import require_GET, require_POST
78
from django.http import Http404, HttpResponse
89
from django.utils.timezone import activate
910
from django_q.tasks import async, Task
@@ -32,12 +33,18 @@ def decode_cmd_out(completed_cmd):
3233
)
3334

3435

35-
@require_GET
36+
@csrf_exempt
37+
@require_POST
3638
def run_task_update_one_source(request):
37-
source_path = request.GET.get('source_path', None)
39+
source_path = request.POST.get('source_path', None)
3840
if source_path is None:
3941
raise Http404('No given source_path')
40-
task_id = async('doc_tasks.tasks.update_one_page', page=source_path)
42+
# converting source_path to Transifex sources
43+
if source_path == 'glossary':
44+
tx_page = 'glossary-1'
45+
else:
46+
tx_page = source_path.replace('/', '--').replace('.', '_')
47+
task_id = async('doc_tasks.tasks.update_one_page', page=tx_page)
4148
return HttpResponse(
4249
'Submitted as task %s. See <a href="%s">task queue</a>.'
4350
% (task_id, reverse('home'))

0 commit comments

Comments
 (0)