Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ippidb-web
Manage
Activity
Members
Labels
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
iPPIDB
ippidb-web
Commits
9d86faa8
Commit
9d86faa8
authored
7 years ago
by
Hervé MENAGER
Browse files
Options
Downloads
Patches
Plain Diff
experiment in trying to save Model objects as json for the wizard
Former-commit-id: b2181d605c00bb890226f2c4213d22f2498aa534
parent
24f2716d
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ippisite/db.sqlite3.REMOVED.git-id
+1
-1
1 addition, 1 deletion
ippisite/db.sqlite3.REMOVED.git-id
ippisite/ippidb/views.py
+18
-4
18 additions, 4 deletions
ippisite/ippidb/views.py
with
19 additions
and
5 deletions
ippisite/db.sqlite3.REMOVED.git-id
+
1
−
1
View file @
9d86faa8
067f156ca37c93920f1a15dac26337a9956fccbb
ea2455328a1ef5effe52858804d0c303950ec7cf
\ No newline at end of file
\ No newline at end of file
This diff is collapsed.
Click to expand it.
ippisite/ippidb/views.py
+
18
−
4
View file @
9d86faa8
...
@@ -2,10 +2,11 @@ import ippidb
...
@@ -2,10 +2,11 @@ import ippidb
from
django.shortcuts
import
render
from
django.shortcuts
import
render
from
django.http
import
HttpResponseRedirect
from
django.http
import
HttpResponseRedirect
from
django.forms.models
import
model_to_dict
from
formtools.wizard.views
import
SessionWizardView
,
NamedUrlSessionWizardView
from
formtools.wizard.views
import
SessionWizardView
,
NamedUrlSessionWizardView
from
.forms
import
IdForm
,
BibliographyForm
,
PDBForm
,
ProteinForm
,
ProteinDomainComplexTypeForm
,
ProteinDomainComplexForm
,
PpiForm
,
ProteinFormSet
from
.forms
import
IdForm
,
BibliographyForm
,
PDBForm
,
ProteinForm
,
ProteinDomainComplexTypeForm
,
ProteinDomainComplexForm
,
PpiForm
,
ProteinFormSet
from
.models
import
Protein
from
.models
import
Protein
,
Bibliography
,
Taxonomy
from
.ws
import
get_pdb_uniprot_mapping
from
.ws
import
get_pdb_uniprot_mapping
def
index
(
request
):
def
index
(
request
):
...
@@ -46,6 +47,19 @@ class IppiWizard(NamedUrlSessionWizardView):
...
@@ -46,6 +47,19 @@ class IppiWizard(NamedUrlSessionWizardView):
def
get_template_names
(
self
):
def
get_template_names
(
self
):
return
[
TEMPLATES
[
self
.
steps
.
current
]]
return
[
TEMPLATES
[
self
.
steps
.
current
]]
def
get_form_instance
(
self
,
step
):
if
self
.
steps
.
current
==
'
BibliographyForm
'
:
data
=
self
.
storage
.
get_step_data
(
'
IdForm
'
)
obj
=
Bibliography
(
**
data
)
return
obj
if
self
.
steps
.
current
==
'
ProteinForm
'
:
data
=
self
.
storage
.
get_step_data
(
'
PDBForm
'
).
getlist
(
'
set
'
)
proteins
=
[]
for
data_item
in
data
:
data_item
[
'
organism
'
]
=
Taxonomy
.
objects
.
get
(
pk
=
data_item
[
'
organism
'
])
proteins
.
append
(
Protein
(
**
data_item
))
return
Ol
(
proteins
)
def
process_step
(
self
,
form
):
def
process_step
(
self
,
form
):
"""
"""
This method overrides the one used to postprocess the form data.
This method overrides the one used to postprocess the form data.
...
@@ -54,8 +68,8 @@ class IppiWizard(NamedUrlSessionWizardView):
...
@@ -54,8 +68,8 @@ class IppiWizard(NamedUrlSessionWizardView):
"""
"""
if
self
.
steps
.
current
==
'
IdForm
'
:
if
self
.
steps
.
current
==
'
IdForm
'
:
form
.
instance
.
autofill
()
form
.
instance
.
autofill
()
self
.
instance_dict
[
'
BibliographyForm
'
]
=
form
.
instance
return
model_to_dict
(
form
.
instance
)
el
if
self
.
steps
.
current
==
'
PDBForm
'
:
if
self
.
steps
.
current
==
'
PDBForm
'
:
uniprot_ids
=
get_pdb_uniprot_mapping
(
form
.
cleaned_data
[
'
pdb_id
'
])
uniprot_ids
=
get_pdb_uniprot_mapping
(
form
.
cleaned_data
[
'
pdb_id
'
])
proteins
=
[]
proteins
=
[]
for
uniprot_id
in
uniprot_ids
:
for
uniprot_id
in
uniprot_ids
:
...
@@ -66,7 +80,7 @@ class IppiWizard(NamedUrlSessionWizardView):
...
@@ -66,7 +80,7 @@ class IppiWizard(NamedUrlSessionWizardView):
p
.
uniprot_id
=
uniprot_ids
[
0
]
p
.
uniprot_id
=
uniprot_ids
[
0
]
p
.
autofill
()
p
.
autofill
()
proteins
.
append
(
p
)
proteins
.
append
(
p
)
self
.
instance_dict
[
'
ProteinForm
'
]
=
Ol
(
proteins
)
return
{
'
set
'
:
[
model_to_dict
(
p
,
exclude
=
[
'
molecular_functions
'
])
for
p
in
proteins
]}
return
self
.
get_form_step_data
(
form
)
return
self
.
get_form_step_data
(
form
)
def
done
(
self
,
form_list
,
**
kwargs
):
def
done
(
self
,
form_list
,
**
kwargs
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment