diff options
author | Navan Chauhan <navanchauhan@gmail.com> | 2020-07-07 22:20:03 +0530 |
---|---|---|
committer | Navan Chauhan <navanchauhan@gmail.com> | 2020-07-07 22:20:03 +0530 |
commit | 724c8b3f4a4f5c3122d0761ec8cd572b75381d96 (patch) | |
tree | b266986834069afcd6c0b856c25c136b778d4ad6 /app/views.py | |
parent | f8c389102242736f620968a1d280092ce6fe6434 (diff) |
added job status form
Diffstat (limited to 'app/views.py')
-rw-r--r-- | app/views.py | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/app/views.py b/app/views.py index fd1f466..3769d75 100644 --- a/app/views.py +++ b/app/views.py @@ -12,7 +12,7 @@ from string import digits, ascii_lowercase # Note: that when using Flask-WTF we need to import the Form Class that we created # in forms.py -from .forms import MyForm, curieForm +from .forms import MyForm, curieForm, statusForm def gen_word(N, min_N_dig, min_N_low): choose_from = [digits]*min_N_dig + [ascii_lowercase]*min_N_low @@ -47,6 +47,36 @@ def visualise(): """Render visualisation page.""" return render_template('visualise.html') +@app.route('/Status',methods=['GET','POST']) +def status(): + taskStatusForm = statusForm() + + if request.method == 'POST': + if taskStatusForm.validate_on_submit(): + jobID = taskStatusForm.jobID.data + import mysql.connector as con + mycon = con.connect(host=app.config['DB_HOST'],user=app.config['DB_USER'],password=app.config['DB_PASSWORD'],port=app.config['DB_PORT'],database=app.config['DB_NAME']) + mycursor = mycon.cursor() + sqlQuery = 'select id, protein_name, ligand_name, date, description, done from curieweb where id="%s"' % (jobID) + mycursor.execute(sqlQuery) + records = mycursor.fetchall() + if records == []: + return render_template('job_status_error.html',job=jobID) + else: + r = records[0] + protein_name = r[1] + ligand_name = r[2] + date = r[3] + description = r[4] + done = r[5] + if done==1: + done="Completed" + elif done==0: + done="Queued" + return render_template('job_status.html',ID=jobID,pn=protein_name,ln=ligand_name,subDate=date,desc=description,status=done) + flash_errors(taskStatusForm) + return render_template('job_status_form.html',form=taskStatusForm) + @app.route('/basic-form', methods=['GET', 'POST']) def basic_form(): |