Commit 842d1fe2 authored by Hamza Dely's avatar Hamza Dely

[Bugfix] Il n'est plus possible de se choisir soi-même comme destinataire d'un don

parent 6b0206c5
......@@ -20,7 +20,7 @@ from django.views.decorators.csrf import csrf_exempt
# TODO: vérifier que les exempts suivants peuvent être retirés sans risques
@csrf_exempt
def quick_search(request):
def quick_search(request, mode="basic"):
"""Renvoie l'objet JSON résultat d'un quick_search,
destiné à être chargé par javascript"""
if (request.method == "GET") or (request.session.get("logged", None) != "ok"):
......@@ -33,7 +33,7 @@ def quick_search(request):
success, sock_ou_response = nk.socket_still_alive(request)
if success:
sock = sock_ou_response
data = [asked]
data = [asked, "x"] if mode == "dons" else [asked]
sock.write(json.dumps(["quick_search", data]))
out = nk.full_read(sock)["msg"]
return HttpResponse(json.dumps(out))
......
......@@ -74,7 +74,7 @@ urlpatterns = patterns('note.views',
urlpatterns += patterns('note.ajaj',
# les pages de requêtes AJAJ
url(ur'^/quick_search/*$', 'quick_search'),
url(ur'^/quick_search_(?P<mode>basic|dons)/*$', 'quick_search'),
url(ur'^/search/*$', 'search'),
url(ur'^/search_readhesion/*$', 'search_readhesion'),
url(ur'^/get_boutons/*$', 'get_boutons'),
......
......@@ -83,7 +83,12 @@ function request(type, asked, callback) {
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send("asked=" + encodeURIComponent(asked));
} else {
xhr.open("POST", NOTE_ROOT_URL + "quick_search/", true);
if (page_dons) {
target = "dons/";
} else {
target = "basic/";
}
xhr.open("POST", NOTE_ROOT_URL + "quick_search_" + target, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send("asked=" + encodeURIComponent(asked));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment