Beispiel #1
0
def newtask():

	data = request.get_json()
	msg = Task.checkData(data)

	
	if not msg == "":
		return jsonify({"code" : "err", "msg" : msg})

	else :
		task = Task.newTask(data)


		return jsonify({"code" : "success", "task" : task.dict()})
Beispiel #2
0
def task():
	data = request.get_json()
	task = Task.getTask(data["prefix"])
	if task :
		return jsonify({"task" : task.getInfo()})
	else :
		return jsonify({"code" : "err", "msg" : "No task"})
Beispiel #3
0
def submitters():
	data = request.get_json()
	task = Task.getTask(data["prefix"])
	if task :
		return jsonify({"submitters" : task.getSubmitters()})
	else :
		return jsonify({"code" : "err", "msg" : "No task"})
Beispiel #4
0
def sbsubmitoriginal():
    data = request.form
    task = Task.getTask(data["prefix"])
    user = User.getUser(session["userid"])
    original = task.getOriginal(data["id"])

    try:
        if request.files["file"].filename[-3:] == "csv":
            csv = request.files["file"].stream
            original.loadcsv(
                user,
                csv,
                original.getNextnth(user),
                datetime.strptime(data["duration_start"], "%a %b %d %Y").date(),
                datetime.strptime(data["duration_end"], "%a %b %d %Y").date(),
            )
        elif request.files["file"].filename[-4:] == "xlsx":
            xlsx = request.files["file"].stream
            original.loadxlsx(
                user,
                xlsx,
                original.getNextnth(user),
                datetime.strptime(data["duration_start"], "%a %b %d %Y").date(),
                datetime.strptime(data["duration_end"], "%a %b %d %Y").date(),
            )

        else:
            return jsonify({"code": "err", "msg": "Wrong extension"})
    except:
        return jsonify({"code": "err", "msg": "Wrong extension"})

    return jsonify({"code": "success"})
Beispiel #5
0
def changesubmitterstatus():
	data = request.get_json()
	task = Task.getTask(data["prefix"])
	if task :
		task.changeSubmitterStatus(data["id"],data["status"])
		return jsonify({"code" :"success"})
	else :
		return jsonify({"code" : "err", "msg" : "No task"})
Beispiel #6
0
def evparsed():
    data = request.get_json()

    task = Task.getTask(data["prefix"])

    parsed = task.getParsed(data["id"])

    return jsonify({"parsed": parsed.dict(), "task": task.dict()})
Beispiel #7
0
def neworiginal():

	data = request.get_json()
	task = Task.getTask(data["prefix"]) 

	if task :
		msg = Task.checkOriginal(data)
		if msg != "" :
			return jsonify({"code" : "err", "msg" : msg})
		else :
			original = task.newOriginal(data["length"],data["name"],data["schemas"])
			return jsonify({"code" : "success", "task" : original.dict()})

	else :
		return jsonify({"code" : "err", "msg" : "No task"})

	return ""
Beispiel #8
0
def taskstatus():
	data = request.get_json()
	task = Task.getTask(data["prefix"])
	if task :
		task.setStatus(data["status"])

		return jsonify({"code" : "success","task" : task.getInfo()})
	else :
		return jsonify({"code" : "err", "msg" : "No task"})
Beispiel #9
0
def sbparsedlist():
    data = request.get_json()
    task = Task.getTask(data["prefix"])
    user = User.getUser(session["userid"])
    parsedlist = task.getParsedBySubmitter(user)
    if task:
        return jsonify({"code": "success", "parsedlist": map(lambda x: x.dict(), parsedlist)})
    else:
        return jsonify({"code": "err", "msg": "No task"})
Beispiel #10
0
def getfile(prefix, id):
    task = Task.getTask(prefix)

    parsed = task.getParsed(id)

    response = make_response(parsed.file)
    response.headers["Content-type"] = "text/csv"
    response.headers["Content-Disposition"] = "attachment; filename=parsingdatasequence.csv"
    return response
Beispiel #11
0
def sboriginal():
    data = request.get_json()
    task = Task.getTask(data["prefix"])
    user = User.getUser(session["userid"])
    original = task.getOriginal(data["id"])

    if task:
        json = original.getInfoByUser(user)
        return jsonify({"code": "success", "original": json})
    else:
        return jsonify({"code": "err", "msg": "No task"})
Beispiel #12
0
def showparseds():

	data = request.get_json()
	task = Task.getTask(data["prefix"]) 

	if task :
		return jsonify({"code" : "success", "parsedlist" : map(lambda x : x.dict(), task.getParseds())})

	else :
		return jsonify({"code" : "err", "msg" : "No task"})

	return ""
Beispiel #13
0
def showoriginals():

	data = request.get_json()
	task = Task.getTask(data["prefix"]) 

	if task :
		originallist = map(lambda x : x.getInfo(), task.getOriginals())
		return jsonify({"code" : "success", "originallist" : originallist})

	else :
		return jsonify({"code" : "err", "msg" : "No task"})

	return ""
Beispiel #14
0
def userparsds():
	data = request.get_json()
	return jsonify({"parsedlist" : Task.getEvaluateAll(data["id"])})









	
Beispiel #15
0
def evsubmitevaluate():
    data = request.get_json()
    task = Task.getTask(data["prefix"])

    parsed = task.getParsed(data["id"])

    if data["pass"]:
        parsed.evaluate(data["score"], "Pass")
        user = User.getUser(parsed.submitterid).setScore()
        parsed.insertcsv()
    else:
        parsed.evaluate(data["score"], "Nonpass")

    return jsonify({"code": "success"})
Beispiel #16
0
def showtupples():

	data = request.get_json()
	task = Task.getTask(data["prefix"]) 

	if task :
		tupples = task.getTupples()
		tupples["code"] = "success"
		return jsonify(tupples)

	else :
		return jsonify({"code" : "err", "msg" : "No task"})

	return ""
Beispiel #17
0
def sbapply():
    data = request.get_json()
    task = Task.getTask(data["prefix"])
    user = User.getUser(session["userid"])

    if task:
        task.addUser(user)
        json = task.dict()
        json["originals"] = map(lambda x: x.dict(), task.getOriginals())
        json["originalnum"] = len(json["originals"])
        json["enrolled"] = task.checkUser(session["userid"])
        return jsonify({"code": "success", "task": json})
    else:
        return jsonify({"code": "err", "msg": "No task"})
Beispiel #18
0
def sbtask():
    data = request.get_json()
    task = Task.getTask(data["prefix"])
    user = User.getUser(session["userid"])
    if task:
        json = task.dict()

        status = task.checkUserStatus(session["userid"])
        if task.status == "Stop":
            status = "Stop"
        json["originals"] = map(lambda x: x.dict(), task.getOriginals())
        json["originalnum"] = len(json["originals"])
        json["enrolled"] = task.checkUser(session["userid"])
        json["status"] = status
        json["parsednum"] = task.getParsedNumBySubmitter(user)
        json["submitok"] = status == "Approved"
        return jsonify({"code": "success", "task": json})
    else:
        return jsonify({"code": "err", "msg": "No task"})
Beispiel #19
0
def evparsedsdone():
    return jsonify({"parsedlist": Task.getEvaluateDone(session["userid"])})
Beispiel #20
0
def evparseds():
    return jsonify({"parsedlist": Task.getEvaluateReady(session["userid"])})
Beispiel #21
0
def sbtasks(start=0, end=10):
    tasklist = Task.getTasks(start, end)
    return jsonify({"tasks": map(lambda x: x.dict(), tasklist)})
Beispiel #22
0
def gettaskcsv(prefix):

	task = Task.getTask(prefix)
	csv = task.getCSV()

	return send_file(csv, attachment_filename="taskdata.csv", as_attachment=True,mimetype="text/csv")