From 724c8b3f4a4f5c3122d0761ec8cd572b75381d96 Mon Sep 17 00:00:00 2001 From: Navan Chauhan Date: Tue, 7 Jul 2020 22:20:03 +0530 Subject: added job status form --- app/forms.py | 5 ++++- app/templates/base.html | 3 +++ app/templates/home.html | 3 ++- app/templates/job_status.html | 10 ++++++++++ app/templates/job_status_error.html | 6 ++++++ app/templates/job_status_form.html | 15 +++++++++++++++ app/views.py | 32 +++++++++++++++++++++++++++++++- 7 files changed, 71 insertions(+), 3 deletions(-) create mode 100644 app/templates/job_status.html create mode 100644 app/templates/job_status_error.html create mode 100644 app/templates/job_status_form.html diff --git a/app/forms.py b/app/forms.py index e0f7bc1..47f423d 100644 --- a/app/forms.py +++ b/app/forms.py @@ -29,4 +29,7 @@ class curieForm(FlaskForm): center_y = DecimalField('Center Y',default=0) center_z = DecimalField('Center Z',default=0) - email = StringField('Email', validators=[DataRequired(), Email()]) \ No newline at end of file + email = StringField('Email', validators=[DataRequired(), Email()]) + +class statusForm(FlaskForm): + jobID = StringField('Job ID',validators=[DataRequired()]) \ No newline at end of file diff --git a/app/templates/base.html b/app/templates/base.html index e8adc2e..3e43671 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -35,6 +35,9 @@ + diff --git a/app/templates/home.html b/app/templates/home.html index f7a7c78..02c71dd 100644 --- a/app/templates/home.html +++ b/app/templates/home.html @@ -2,8 +2,9 @@ {% block main %}

Curie Web Demo

-

The dock and report demo performs molecular docking using AutoDock Vina and then finds protein-ligand interactions using PLIP

+

Dock and Report performs molecular docking using AutoDock Vina, generates visualisations using PyMOL and then finds protein-ligand interactions using PLIP. It then compiles all of this into a PDF report and emails it to you.

{% endblock %} \ No newline at end of file diff --git a/app/templates/job_status.html b/app/templates/job_status.html new file mode 100644 index 0000000..e113650 --- /dev/null +++ b/app/templates/job_status.html @@ -0,0 +1,10 @@ +{% extends 'base.html' %} + +{% block main %} +

Job ID: {{ ID }}

+ Submitted On: {{subDate}}
+ Target Name: {{pn}}
+ Ligand Name: {{ln}}
+ Description: {{desc}}
+ Status: {{status}} +{% endblock %} \ No newline at end of file diff --git a/app/templates/job_status_error.html b/app/templates/job_status_error.html new file mode 100644 index 0000000..633e347 --- /dev/null +++ b/app/templates/job_status_error.html @@ -0,0 +1,6 @@ +{% extends 'base.html' %} + +{% block main %} +

Job ID: {{ job }}

+

This Job ID does not exist 😠. If you think this is an error, please contact us.

+{% endblock %} \ No newline at end of file diff --git a/app/templates/job_status_form.html b/app/templates/job_status_form.html new file mode 100644 index 0000000..f940a6d --- /dev/null +++ b/app/templates/job_status_form.html @@ -0,0 +1,15 @@ +{% extends 'base.html' %} + +{% block main %} +

Get Job Status

+
+ {% include 'flash_messages.html' %} + {{ form.csrf_token }} +
+ {{ form.jobID.label }} + {{ form.jobID(class="form-control") }} +
+ + +
+{% endblock %} \ No newline at end of file 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(): -- cgit v1.2.3