Skip to content
Snippets Groups Projects
Commit 30c64f44 authored by Hervé  MENAGER's avatar Hervé MENAGER
Browse files

adapt PDB form and wizard view to formsets

Former-commit-id: 3e00d4f63a45634e2261241a682b38d80525058f
parent af713094
No related branches found
No related tags found
No related merge requests found
......@@ -25,11 +25,13 @@
{% block custom_form %}{% endblock %}
{% if wizard.form.forms %}
{{ wizard.form.management_form }}
{{ formset.management_form }}
{% for form in wizard.form.forms %}
{{ form }}
{% endfor %}
{% else %}
{{ wizard.form.management_form }}
{{ formset.management_form }}
{% for form in formset %}
{% for field in form %}
......@@ -41,4 +43,4 @@
<input type="submit" value="{% trans "Next step" %}"/>
</form>
</div>
{% endblock %}
\ No newline at end of file
{% endblock %}
......@@ -64,14 +64,18 @@ class IppiWizard(NamedUrlSessionWizardView):
form.instance.save()
data['pk'] = form.instance.id
if self.steps.current=='PDBForm':
uniprot_ids = get_pdb_uniprot_mapping(form.cleaned_data['pdb_id'])
pdb_ids = [form['pdb_id'] for form in form.cleaned_data]
uniprot_ids = []
protein_ids = []
for pdb_id in pdb_ids:
uniprot_ids += get_pdb_uniprot_mapping(pdb_id)
for uniprot_id in uniprot_ids:
try:
p = Protein.objects.get(uniprot_id=uniprot_id)
except Protein.DoesNotExist:
p = Protein()
p.uniprot_id = uniprot_ids[0]
p.autofill()
p.save()
protein_ids.append(p.id)
data['pks'] = protein_ids
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment