From 90db9d31109ed121e998a79a8b6518b2c83f75d4 Mon Sep 17 00:00:00 2001 From: Rachel TORCHET <racheltorchet@users.noreply.github.com> Date: Tue, 16 May 2017 17:14:39 +0200 Subject: [PATCH] Add Wizard form functionalities to generate successive forms & update css according to the new forms. --- ippisite/ippidb/static/css/ippidb.css | 20 +++++++++-- .../ippidb/templates/BibliographyForm.html | 34 +++++++++++++++++++ ippisite/ippidb/templates/IdForm.html | 33 ++++++++++++++++++ ippisite/ippidb/templates/PDBForm.html | 33 ++++++++++++++++++ ippisite/ippidb/templates/PpiForm.html | 33 ++++++++++++++++++ .../templates/ProteinDomainComplexForm.html | 33 ++++++++++++++++++ ippisite/ippidb/templates/add.html | 11 ++---- ippisite/ippidb/templates/wizard_form.html | 28 --------------- ippisite/ippidb/urls.py | 15 ++++++-- ippisite/ippidb/views.py | 24 ++++++++++++- ippisite/ippisite/settings.py | 6 +++- ippisite/requirements.txt | 3 +- 12 files changed, 229 insertions(+), 44 deletions(-) create mode 100644 ippisite/ippidb/templates/BibliographyForm.html create mode 100644 ippisite/ippidb/templates/IdForm.html create mode 100644 ippisite/ippidb/templates/PDBForm.html create mode 100644 ippisite/ippidb/templates/PpiForm.html create mode 100644 ippisite/ippidb/templates/ProteinDomainComplexForm.html delete mode 100644 ippisite/ippidb/templates/wizard_form.html diff --git a/ippisite/ippidb/static/css/ippidb.css b/ippisite/ippidb/static/css/ippidb.css index 152e4d21..b4fff454 100644 --- a/ippisite/ippidb/static/css/ippidb.css +++ b/ippisite/ippidb/static/css/ippidb.css @@ -595,11 +595,12 @@ display:block; /* FORMS */ #Form{ - width: 70%; + width: 80%; border: 1px solid; - padding: 10px; + padding: 15px; min-height: 150px; text-align: center; + min-height: 350px; } form { @@ -627,6 +628,21 @@ button, input, select, textarea { width: inherit; } +.step { + width: 20%; + background-color: rgb(0, 0, 0); + color: rgb(255, 255, 255); + padding-left: 15px; + font-family: "PlayfairDisplayReg"; + font-size: 24px; + display: block; +} + +.step_desc { + padding: 15px; + margin-bottom: 15px; +} + /* CONTENT */ #content{ diff --git a/ippisite/ippidb/templates/BibliographyForm.html b/ippisite/ippidb/templates/BibliographyForm.html new file mode 100644 index 00000000..7838aa76 --- /dev/null +++ b/ippisite/ippidb/templates/BibliographyForm.html @@ -0,0 +1,34 @@ +{% extends "add.html" %} +{% load i18n %} + +{% block form %} +<div class="step">{{ wizard.steps.step1 }}. Bibliography </div> +<div id="Form"> + <div class="step_desc"> + <p>Based on the ID you have provided, we have iden2fied the following informa2on concerning your bibliographic source. +Please check that the information below is correct (Title, authors etc. ) and answer the few questions about the content of your bibliographic source.</p> + </div> + <form action="" method="post"> + {% csrf_token %} + <table> + {{ wizard.management_form }} + {{ wizard.form.errors}} + {{ wizard.form.non_field_errors}} + {% block custom_form %}{% endblock %} + </form> +{% if wizard.form.forms %} + {{ wizard.form.management_form }} + {% for form in wizard.form.forms %} + {{ form }} + {% endfor %} +{% else %} + {{ wizard.form }} +{% endif %} +</table> +{% if wizard.steps.prev %} + <button name="wizard_goto_step" type="submit" value="{{ wizard.steps.first }}">{% trans "first step" %}</button> + <button name="wizard_goto_step" type="submit" value="{{ wizard.steps.prev }}">{% trans "previous step" %}</button> +{% endif %} + <input type="submit" value="{% trans "submit" %}"/> +</div> +{% endblock %} \ No newline at end of file diff --git a/ippisite/ippidb/templates/IdForm.html b/ippisite/ippidb/templates/IdForm.html new file mode 100644 index 00000000..ff7e2655 --- /dev/null +++ b/ippisite/ippidb/templates/IdForm.html @@ -0,0 +1,33 @@ +{% extends "add.html" %} +{% load i18n %} + +{% block form %} +<div class="step">{{ wizard.steps.step1 }}. Id </div> +<div id="Form"> + <div class="step_desc"> + <p> Please provide a valid ID for your bibliographic source, either a PubMed ID or WIPO ID. This ID should correspond to a bibliographic source in its final format. Therefore, PubMed articles in « Just Accepted » format should not be used as a source of data as they are not considered the official version of record. </p> + </div> + <form action="" method="post"> + {% csrf_token %} + <table> + {{ wizard.management_form }} + {{ wizard.form.errors}} + {{ wizard.form.non_field_errors}} + {% block custom_form %}{% endblock %} + </form> +{% if wizard.form.forms %} + {{ wizard.form.management_form }} + {% for form in wizard.form.forms %} + {{ form }} + {% endfor %} +{% else %} + {{ wizard.form }} +{% endif %} +</table> +{% if wizard.steps.prev %} + <button name="wizard_goto_step" type="submit" value="{{ wizard.steps.first }}">{% trans "first step" %}</button> + <button name="wizard_goto_step" type="submit" value="{{ wizard.steps.prev }}">{% trans "previous step" %}</button> +{% endif %} + <input type="submit" value="{% trans "submit" %}"/> +</div> +{% endblock %} \ No newline at end of file diff --git a/ippisite/ippidb/templates/PDBForm.html b/ippisite/ippidb/templates/PDBForm.html new file mode 100644 index 00000000..f0dc266f --- /dev/null +++ b/ippisite/ippidb/templates/PDBForm.html @@ -0,0 +1,33 @@ +{% extends "add.html" %} +{% load i18n %} + +{% block form %} +<div class="step">{{ wizard.steps.step1 }}. PDB id </div> +<div id="Form"> + <div class="step_desc"> + <p>Please provide a valid PDB code that contains the structure of the full PPI complex for which you have data. If you have several PDB codes please list them all as they may contain information about homologous protein partners. The information within the PDB file will be used to prefill information of the corresponding proteins and domains participating to the PPI.</p> + </div> + <form action="" method="post"> + {% csrf_token %} + <table> + {{ wizard.management_form }} + {{ wizard.form.errors}} + {{ wizard.form.non_field_errors}} + {% block custom_form %}{% endblock %} + </form> +{% if wizard.form.forms %} + {{ wizard.form.management_form }} + {% for form in wizard.form.forms %} + {{ form }} + {% endfor %} +{% else %} + {{ wizard.form }} +{% endif %} +</table> +{% if wizard.steps.prev %} + <button name="wizard_goto_step" type="submit" value="{{ wizard.steps.first }}">{% trans "first step" %}</button> + <button name="wizard_goto_step" type="submit" value="{{ wizard.steps.prev }}">{% trans "previous step" %}</button> +{% endif %} + <input type="submit" value="{% trans "submit" %}"/> +</div> +{% endblock %} \ No newline at end of file diff --git a/ippisite/ippidb/templates/PpiForm.html b/ippisite/ippidb/templates/PpiForm.html new file mode 100644 index 00000000..047deb95 --- /dev/null +++ b/ippisite/ippidb/templates/PpiForm.html @@ -0,0 +1,33 @@ +{% extends "add.html" %} +{% load i18n %} + +{% block form %} +<div class="step">{{ wizard.steps.step1 }}. PPI </div> +<div id="Form"> + <div class="step_desc"> + <p>Now that you have created ALL complexes that participate to the formation of the PPI, you need to constuct your PPI by selecting your complex bound and if necessary you partner complex along with their stoichiometry in the PPI.</p> + </div> + <form action="" method="post"> + {% csrf_token %} + <table> + {{ wizard.management_form }} + {{ wizard.form.errors}} + {{ wizard.form.non_field_errors}} + {% block custom_form %}{% endblock %} + </form> +{% if wizard.form.forms %} + {{ wizard.form.management_form }} + {% for form in wizard.form.forms %} + {{ form }} + {% endfor %} +{% else %} + {{ wizard.form }} +{% endif %} +</table> +{% if wizard.steps.prev %} + <button name="wizard_goto_step" type="submit" value="{{ wizard.steps.first }}">{% trans "first step" %}</button> + <button name="wizard_goto_step" type="submit" value="{{ wizard.steps.prev }}">{% trans "previous step" %}</button> +{% endif %} + <input type="submit" value="{% trans "submit" %}"/> +</div> +{% endblock %} \ No newline at end of file diff --git a/ippisite/ippidb/templates/ProteinDomainComplexForm.html b/ippisite/ippidb/templates/ProteinDomainComplexForm.html new file mode 100644 index 00000000..9a210d4d --- /dev/null +++ b/ippisite/ippidb/templates/ProteinDomainComplexForm.html @@ -0,0 +1,33 @@ +{% extends "add.html" %} +{% load i18n %} + +{% block form %} +<div class="step">{{ wizard.steps.step1 }}. Proteins </div> +<div id="Form"> + <div class="step_desc"> + <p>Based on the PDB code(s) you have provided, we have identified a list of proteins and PFAM domains that may participate to the PPI. Please select ALL the proteins and PFAM domains that do participate to the formation of the full PPI complex.</p> + </div> + <form action="" method="post"> + {% csrf_token %} + <table> + {{ wizard.management_form }} + {{ wizard.form.errors}} + {{ wizard.form.non_field_errors}} + {% block custom_form %}{% endblock %} + </form> +{% if wizard.form.forms %} + {{ wizard.form.management_form }} + {% for form in wizard.form.forms %} + {{ form }} + {% endfor %} +{% else %} + {{ wizard.form }} +{% endif %} +</table> +{% if wizard.steps.prev %} + <button name="wizard_goto_step" type="submit" value="{{ wizard.steps.first }}">{% trans "first step" %}</button> + <button name="wizard_goto_step" type="submit" value="{{ wizard.steps.prev }}">{% trans "previous step" %}</button> +{% endif %} + <input type="submit" value="{% trans "submit" %}"/> +</div> +{% endblock %} \ No newline at end of file diff --git a/ippisite/ippidb/templates/add.html b/ippisite/ippidb/templates/add.html index b6d14762..1b46a6c9 100644 --- a/ippisite/ippidb/templates/add.html +++ b/ippisite/ippidb/templates/add.html @@ -3,7 +3,7 @@ {% block title %}inhibitors of Protein-Protein Interaction Database{% endblock %} -{% block content %} +{% block content%} <div id="mainnav"> <nav class="secondary-nav"> <div class="inner-wrap"> @@ -55,13 +55,8 @@ <div class="block block-system block-system-main"> <div class="content"> <div class="view-content"> - <div id="Form"> - <form action="/admin-session/add" method="post"> - {% csrf_token %} - {{ ID.as_p}} - <input type="submit" value="Next" /> - </form> - </div> + + {% block form %}{% endblock %} </div> </div> diff --git a/ippisite/ippidb/templates/wizard_form.html b/ippisite/ippidb/templates/wizard_form.html deleted file mode 100644 index db6e3d7c..00000000 --- a/ippisite/ippidb/templates/wizard_form.html +++ /dev/null @@ -1,28 +0,0 @@ -{% extends "base.html" %} -{% load i18n %} - -{% block head %} -{{ wizard.form.media }} -{% endblock %} - -{% block content %} -<p>Step {{ wizard.steps.step1 }} of {{ wizard.steps.count }}</p> -<form action="" method="post">{% csrf_token %} -<table> -{{ wizard.management_form }} -{% if wizard.form.forms %} - {{ wizard.form.management_form }} - {% for form in wizard.form.forms %} - {{ form }} - {% endfor %} -{% else %} - {{ wizard.form }} -{% endif %} -</table> -{% if wizard.steps.prev %} -<button name="wizard_goto_step" type="submit" value="{{ wizard.steps.first }}">{% trans "first step" %}</button> -<button name="wizard_goto_step" type="submit" value="{{ wizard.steps.prev }}">{% trans "prev step" %}</button> -{% endif %} -<input type="submit" value="{% trans "submit" %}"/> -</form> -{% endblock %} \ No newline at end of file diff --git a/ippisite/ippidb/urls.py b/ippisite/ippidb/urls.py index d6f30609..e5e4269b 100644 --- a/ippisite/ippidb/urls.py +++ b/ippisite/ippidb/urls.py @@ -1,6 +1,7 @@ -from django.conf.urls import url +from django.conf.urls import include,url from . import views - +from ippidb.forms import IdForm, BibliographyForm,PDBForm,ProteinDomainComplexForm,PpiForm +from ippidb.views import IppiWizard,FORMS urlpatterns = [ url(r'^$', views.index, name='index'), @@ -8,5 +9,13 @@ urlpatterns = [ url(r'^query$', views.query, name='query'), url(r'^tutorials$', views.tutorials, name='tutorials'), url(r'^admin-session$', views.adminSession, name='admin-session'), - url(r'^admin-session/add$', views.add, name='add'), + url(r'^admin-session/add/$', IppiWizard.as_view(FORMS)), ] + +from django.conf import settings + +if settings.DEBUG: + import debug_toolbar + urlpatterns = [ + url(r'^__debug__/', include(debug_toolbar.urls)), + ] + urlpatterns diff --git a/ippisite/ippidb/views.py b/ippisite/ippidb/views.py index e97b18c3..4f04a070 100644 --- a/ippisite/ippidb/views.py +++ b/ippisite/ippidb/views.py @@ -1,6 +1,7 @@ +import ippidb from django.shortcuts import render -from formtools.wizard.views import SessionWizardView from django.http import HttpResponseRedirect +from formtools.wizard.views import SessionWizardView from .forms import IdForm, BibliographyForm, PDBForm, ProteinForm, ProteinDomainComplexForm, PpiForm def index(request): @@ -37,6 +38,27 @@ def add(request): return render(request, 'add.html', {'ID': form}) +FORMS = [("IdForm", ippidb.forms.IdForm), + ("BibliographyForm", ippidb.forms.BibliographyForm), + ("PDBForm", ippidb.forms.PDBForm), + ("ProteinDomainComplexForm", ippidb.forms.ProteinDomainComplexForm), + ("PpiForm", ippidb.forms.PpiForm)] + +TEMPLATES = {"IdForm": "IdForm.html", + "BibliographyForm": "BibliographyForm.html", + "PDBForm": "PDBForm.html", + "ProteinDomainComplexForm": "ProteinDomainComplexForm.html", + "PpiForm": "PpiForm.html"} + +class IppiWizard(SessionWizardView): + def get_template_names(self): + return [TEMPLATES[self.steps.current]] + + def done(self, form_list, **kwargs): + return render(self.request, '/admin-session/add.html', { + 'form_data': [form.cleaned_data for form in form_list], + }) + # def add(request): # # if this is a POST request we need to process the form data # if request.method == 'POST': diff --git a/ippisite/ippisite/settings.py b/ippisite/ippisite/settings.py index 9d773ace..f022fe76 100644 --- a/ippisite/ippisite/settings.py +++ b/ippisite/ippisite/settings.py @@ -25,8 +25,10 @@ SECRET_KEY = '&qc$2x5p&!qwvu2r=)sjp*jgg8a7ss97g8lwpennmu(q9ty4o$' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True -ALLOWED_HOSTS = [] +SHOW_TOOLBAR_CALLBACK = True +ALLOWED_HOSTS = ["127.0.0.1","localhost",] +INTERNAL_IPS= ["127.0.0.1","localhost",] # Application definition @@ -41,6 +43,7 @@ INSTALLED_APPS = [ 'bootstrap3', 'ippidb', 'formtools', + 'debug_toolbar', ] MIDDLEWARE = [ @@ -51,6 +54,7 @@ MIDDLEWARE = [ 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', + 'debug_toolbar.middleware.DebugToolbarMiddleware', ] ROOT_URLCONF = 'ippisite.urls' diff --git a/ippisite/requirements.txt b/ippisite/requirements.txt index 21aad820..ab4ff146 100644 --- a/ippisite/requirements.txt +++ b/ippisite/requirements.txt @@ -5,4 +5,5 @@ django-extensions pygraphviz pydot pyparsing -django-formtools \ No newline at end of file +django-formtools +django-debug-toolbar \ No newline at end of file -- GitLab