Commit 31667a11 authored by Romain Loth's avatar Romain Loth

patch n° 1 Crawlers ISTEX PUBMED

parent db988a97
...@@ -30,7 +30,10 @@ def query( request ): ...@@ -30,7 +30,10 @@ def query( request ):
if request.method == "POST": if request.method == "POST":
query = request.POST["query"] query = request.POST["query"]
N = int(request.POST["N"]) if request.POST[N] == "NaN":
N = QUERY_SIZE_N_MAX
else:
N = int(request.POST["N"])
print ("LOG::TIME:_ "+datetime.datetime.now().isoformat()+" query =", query ) print ("LOG::TIME:_ "+datetime.datetime.now().isoformat()+" query =", query )
print ("LOG::TIME:_ "+datetime.datetime.now().isoformat()+" N =", N ) print ("LOG::TIME:_ "+datetime.datetime.now().isoformat()+" N =", N )
query_string = query.replace(" ","+") query_string = query.replace(" ","+")
...@@ -77,7 +80,7 @@ def save(request , project_id): ...@@ -77,7 +80,7 @@ def save(request , project_id):
if project.user_id != user.id: if project.user_id != user.id:
return HttpResponseForbidden() return HttpResponseForbidden()
query_string = ""
if request.method == "POST": if request.method == "POST":
query = "-" query = "-"
query_string = "-" query_string = "-"
...@@ -88,7 +91,10 @@ def save(request , project_id): ...@@ -88,7 +91,10 @@ def save(request , project_id):
query_string = query.replace(" ","+") # url encoded q query_string = query.replace(" ","+") # url encoded q
if "N" in request.POST: if "N" in request.POST:
N = int(request.POST["N"]) # query_size from views_opti if request.POST["N"] == "NaN":
N = QUERY_SIZE_N_MAX
else:
N = int(request.POST["N"]) # query_size from views_opti
if N > QUERY_SIZE_N_MAX: if N > QUERY_SIZE_N_MAX:
msg = "Invalid sample size N = %i (max = %i)" % (N, QUERY_SIZE_N_MAX) msg = "Invalid sample size N = %i (max = %i)" % (N, QUERY_SIZE_N_MAX)
print("ERROR (scrap: istex d/l ): ",msg) print("ERROR (scrap: istex d/l ): ",msg)
...@@ -133,7 +139,7 @@ def save(request , project_id): ...@@ -133,7 +139,7 @@ def save(request , project_id):
if filename!=False: if filename!=False:
# add the uploaded resource to the corpus # add the uploaded resource to the corpus
corpus.add_resource( corpus.add_resource(
type = get_resource_by_name('ISTex [ISI]')["type"] type = get_resource_by_name('ISTex')["type"]
, path = filename , path = filename
) )
dwnldsOK+=1 dwnldsOK+=1
......
...@@ -48,7 +48,10 @@ def query( request ): ...@@ -48,7 +48,10 @@ def query( request ):
if request.method == "POST": if request.method == "POST":
query = request.POST["query"] query = request.POST["query"]
N = int(request.POST["N"]) if request.POST["N"] == "NaN":
N = QUERY_SIZE_N_MAX
else:
N = int(request.POST["N"])
if N > QUERY_SIZE_N_MAX: if N > QUERY_SIZE_N_MAX:
msg = "Invalid sample size N = %i (max = %i)" % (N, QUERY_SIZE_N_MAX) msg = "Invalid sample size N = %i (max = %i)" % (N, QUERY_SIZE_N_MAX)
......
...@@ -364,6 +364,7 @@ ...@@ -364,6 +364,7 @@
} }
function getGlobalResults(value){ function getGlobalResults(value){
console.log("in getGlobalResults()") console.log("in getGlobalResults()")
// AJAX to django // AJAX to django
var pubmedquery = $("#id_name").val() var pubmedquery = $("#id_name").val()
...@@ -376,7 +377,7 @@ ...@@ -376,7 +377,7 @@
var theType = $("#id_type option:selected").html(); var theType = $("#id_type option:selected").html();
if(theType=="Pubmed (XML format)") { if(theType=="Pubmed [XML]") {
$.ajax({ $.ajax({
// contentType: "application/json", // contentType: "application/json",
url: window.location.origin+"/moissonneurs/pubmed/query", url: window.location.origin+"/moissonneurs/pubmed/query",
...@@ -388,7 +389,7 @@ ...@@ -388,7 +389,7 @@
success: function(data) { success: function(data) {
console.log("SUCCESS") console.log("SUCCESS")
console.log("in getGlobalResults") console.log("in getGlobalResults")
// console.log(data) console.log(data)
console.log("enabling "+"#"+value.id) console.log("enabling "+"#"+value.id)
$("#"+value.id).attr('onclick','getGlobalResults(this);'); $("#"+value.id).attr('onclick','getGlobalResults(this);');
// $("#submit_thing").prop('disabled' , false) // $("#submit_thing").prop('disabled' , false)
......
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