Add login_required to task APIs
This commit is contained in:
@@ -6,9 +6,15 @@ $(function() {
|
|||||||
$(".pkg_meta").show()
|
$(".pkg_meta").show()
|
||||||
}
|
}
|
||||||
|
|
||||||
function getJSON(url) {
|
function getJSON(url, method) {
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
fetch(url).then(function(response) {
|
fetch(new Request(url, {
|
||||||
|
method: method || "get",
|
||||||
|
credentials: "same-origin",
|
||||||
|
headers: {
|
||||||
|
"Accept": "application/json",
|
||||||
|
},
|
||||||
|
})).then(function(response) {
|
||||||
response.text().then(function(txt) {
|
response.text().then(function(txt) {
|
||||||
resolve(JSON.parse(txt))
|
resolve(JSON.parse(txt))
|
||||||
}).catch(reject)
|
}).catch(reject)
|
||||||
@@ -18,7 +24,7 @@ $(function() {
|
|||||||
|
|
||||||
function performTask(url) {
|
function performTask(url) {
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
getJSON(url).then(function(startResult) {
|
getJSON(url, "post").then(function(startResult) {
|
||||||
console.log(startResult)
|
console.log(startResult)
|
||||||
if (typeof startResult.poll_url == "string") {
|
if (typeof startResult.poll_url == "string") {
|
||||||
var tries = 0;
|
var tries = 0;
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ from .utils import shouldReturnJson
|
|||||||
|
|
||||||
from .utils import *
|
from .utils import *
|
||||||
|
|
||||||
@app.route("/tasks/getmeta/new/")
|
@app.route("/tasks/getmeta/new/", methods=["POST"])
|
||||||
|
@login_required
|
||||||
def new_getmeta_page():
|
def new_getmeta_page():
|
||||||
aresult = getMeta.delay(request.args.get("url"))
|
aresult = getMeta.delay(request.args.get("url"))
|
||||||
return jsonify({
|
return jsonify({
|
||||||
@@ -18,6 +19,7 @@ def new_getmeta_page():
|
|||||||
})
|
})
|
||||||
|
|
||||||
@app.route("/tasks/<id>/")
|
@app.route("/tasks/<id>/")
|
||||||
|
@login_required
|
||||||
def check_task(id):
|
def check_task(id):
|
||||||
result = celery.AsyncResult(id)
|
result = celery.AsyncResult(id)
|
||||||
status = result.status
|
status = result.status
|
||||||
|
|||||||
Reference in New Issue
Block a user