Skip to content
Snippets Groups Projects
Commit ca4c0627 authored by Rachel TORCHET's avatar Rachel TORCHET
Browse files

Change ProteinForm into a ModelFormSet to vizualize multiple protein forms infos based on a PDBid

Former-commit-id: 27ae7360f18eb52e0e420f331681945c6ac9b142
parent dfae7102
No related branches found
No related tags found
No related merge requests found
from django.forms import ModelForm
from django.forms import ModelForm,modelformset_factory
from django import forms
from django.db import models
from .models import Bibliography, Protein, ProteinDomainComplex, Ppi, PpiComplex
......@@ -26,6 +26,7 @@ class BibliographyForm(ModelForm):
class PDBForm(forms.Form):
pdb_id = forms.CharField(label="PDB ID",max_length=4, widget=forms.TextInput(attrs={'placeholder': 'e.g 4HHB'}))
class ProteinForm(ModelForm):
class Meta:
model = Protein
......@@ -36,6 +37,10 @@ class ProteinForm(ModelForm):
'entry_name' : forms.TextInput(attrs={'placeholder':'e.g KMT2A_HUMAN'}),
}
ProteinFormSet = modelformset_factory(Protein, exclude=('recommended_name_long', 'short_name'))
formset=ProteinFormSet()
for form in formset:
print(form.as_table())
ARCHI_TYPE = (
('inhibited', 'Inhibited'),
......
......@@ -614,8 +614,15 @@ form {
overflow: hidden;
white-space: nowrap;
padding: 5px;
width: 80%;
margin: 2px;
}
.readonlyfields label{
display: block;
width: 150px;
float: left;
}
div label input {
margin-right:100px;
......
......@@ -31,13 +31,15 @@ Please check that the information below is correct (Title, Authors etc. ) and an
{{ form }}
{% endfor %}
{% else %}
<div id="ck-button">{{ wizard.form.source.label }} {{ wizard.form.source }}</div>
<div id="ck-button">{{ wizard.form.id_source.label }} {{ wizard.form.id_source }}</div>
<div id="ck-button">{{ wizard.form.title.label }} {{ wizard.form.title }}</div>
<div id="ck-button">{{ wizard.form.journal_name.label }} {{ wizard.form.journal_name }}</div>
<div class="readonlyfields">
{{ wizard.form.source }}<br/>
{{ wizard.form.id_source }}<br/>
{{ wizard.form.title }}<br/>
{{ wizard.form.journal_name }}<br/>
</div>
<div id="ck-button">
<label>
<input type="checkbox" value="True"><span>{{ wizard.form.cytotox.label }}</span>
<input type="checkbox"><span>{{ wizard.form.cytotox.label }}</span>
</label>
<label>
<input type="checkbox"><span>{{ wizard.form.in_silico.label }}</span>
......
......@@ -32,7 +32,7 @@
{{ form }}
{% endfor %}
{% else %}
{{ wizard.form }}
{{ wizard.form}}
{% endif %}
</table>
<input type="submit" value="{% trans "Next step" %}"/>
......
......@@ -30,7 +30,12 @@
{{ form }}
{% endfor %}
{% else %}
{{ wizard.form }}
{{ formset.management_form }}
{% for form in formset %}
{% for field in form %}
{{ field.label_tag }} {{ field }}
{% endfor %}
{% endfor %}
{% endif %}
</table>
<input type="submit" value="{% trans "Next step" %}"/>
......
......@@ -2,7 +2,7 @@ import ippidb
from django.shortcuts import render
from django.http import HttpResponseRedirect
from formtools.wizard.views import SessionWizardView,NamedUrlSessionWizardView
from .forms import IdForm, BibliographyForm, PDBForm, ProteinForm, ProteinDomainComplexTypeForm, ProteinDomainComplexForm, PpiForm
from .forms import IdForm, BibliographyForm, PDBForm, ProteinForm, ProteinDomainComplexTypeForm, ProteinDomainComplexForm, PpiForm, ProteinFormSet
def index(request):
return render(request, 'index.html')
......@@ -22,7 +22,7 @@ def adminSession(request):
FORMS = [("IdForm", ippidb.forms.IdForm),
("BibliographyForm", ippidb.forms.BibliographyForm),
("PDBForm", ippidb.forms.PDBForm),
("ProteinForm",ippidb.forms.ProteinForm),
("ProteinForm",ippidb.forms.ProteinFormSet),
("ProteinDomainComplexTypeForm", ippidb.forms.ProteinDomainComplexTypeForm),
("ProteinDomainComplexForm", ippidb.forms.ProteinDomainComplexForm),
("PpiForm", ippidb.forms.PpiForm)]
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment