Commit 7089df08 authored by Hamza Dely's avatar Hamza Dely

Fusion des fonctions get_boutons et search_boutons

parent ae26d0d2
......@@ -114,7 +114,7 @@ def search_readhesion(request):
@csrf_exempt
def get_boutons(request):
def get_boutons(request, flags=""):
"""Renvoie l'objet JSON résultat d'un get_boutons,
destiné à être chargé par javascript"""
if (request.method == "GET") or (request.session.get("logged", None) != "ok"):
......@@ -127,7 +127,7 @@ def get_boutons(request):
success, sock_ou_response = nk.socket_still_alive(request)
if success:
sock = sock_ou_response
data = [asked, ""]
data = [asked, "", flags]
sock.write(json.dumps(["get_boutons", data]))
out = nk.full_read(sock)["msg"]
return HttpResponse(json.dumps(out))
......@@ -135,28 +135,6 @@ def get_boutons(request):
response = sock_ou_response
return response
@csrf_exempt
def search_boutons(request):
"""Renvoie l'objet JSON résultat d'un get_boutons,
destiné à être chargé par javascript"""
if (request.method == "GET") or (request.session.get("logged", None) != "ok"):
return HttpResponse("Get the fuck out of here", status=444)
else:
try:
asked = request.POST["asked"]
except:
return HttpResponse("")
success, sock_ou_response = nk.socket_still_alive(request)
if success:
sock = sock_ou_response
data = [asked, u"all"]
sock.write(json.dumps(["search_boutons", data]))
out = nk.full_read(sock)["msg"]
return HttpResponse(json.dumps(out))
else:
response = sock_ou_response
return response
@csrf_exempt
def do_conso(request):
"""Effectue les consos envoyées en POST par javascript"""
......
......@@ -77,8 +77,7 @@ urlpatterns += patterns('note.ajaj',
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'),
url(ur'^/search_boutons/*$', 'search_boutons'),
url(ur'^/get_boutons/(?P<flags>[^/]*)/*$', 'get_boutons'),
url(ur'^/get_display_info/*$', 'get_display_info'),
url(ur'^/get_photo/(?P<idbde>[^/]*)/*$', 'get_photo'),
url(ur'^/do_conso/*$', 'do_conso'),
......
......@@ -38,7 +38,7 @@ function request(asked, callback) {
};
/* On envoie la requête en POST */
xhr.open("POST", NOTE_ROOT_URL + "search_boutons/", true);
xhr.open("POST", NOTE_ROOT_URL + "get_boutons/a/", 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