Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ippidb-web
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
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
fa14d5d8
Commit
fa14d5d8
authored
7 years ago
by
Hervé MENAGER
Browse files
Options
Downloads
Patches
Plain Diff
save objects in Wizard steps to escape storage hell.
Former-commit-id: 7f39a04b19e82c358a9cf5d3bb7a1f3aeacf22b3
parent
9d86faa8
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
+14
-20
14 additions, 20 deletions
ippisite/ippidb/views.py
with
15 additions
and
21 deletions
ippisite/db.sqlite3.REMOVED.git-id
+
1
−
1
View file @
fa14d5d8
ea2455328a1ef5effe52858804d0c303950ec7cf
cbc5368d062b8764f1b0d652691f17cd132d699f
\ No newline at end of file
\ No newline at end of file
This diff is collapsed.
Click to expand it.
ippisite/ippidb/views.py
+
14
−
20
View file @
fa14d5d8
...
@@ -2,11 +2,10 @@ import ippidb
...
@@ -2,11 +2,10 @@ 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
,
Bibliography
,
Taxonomy
from
.models
import
Protein
,
Bibliography
from
.ws
import
get_pdb_uniprot_mapping
from
.ws
import
get_pdb_uniprot_mapping
def
index
(
request
):
def
index
(
request
):
...
@@ -40,25 +39,17 @@ TEMPLATES = {"IdForm": "IdForm.html",
...
@@ -40,25 +39,17 @@ TEMPLATES = {"IdForm": "IdForm.html",
"
ProteinDomainComplexForm
"
:
"
ProteinDomainComplexForm.html
"
,
"
ProteinDomainComplexForm
"
:
"
ProteinDomainComplexForm.html
"
,
"
PpiForm
"
:
"
PpiForm.html
"
}
"
PpiForm
"
:
"
PpiForm.html
"
}
class
Ol
(
list
):
ordered
=
True
class
IppiWizard
(
NamedUrlSessionWizardView
):
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
):
def
get_form_instance
(
self
,
step
):
if
self
.
steps
.
current
==
'
BibliographyForm
'
:
if
self
.
steps
.
current
==
'
BibliographyForm
'
:
data
=
self
.
storage
.
get_step_data
(
'
IdForm
'
)
pk
=
self
.
storage
.
get_step_data
(
'
IdForm
'
).
get
(
'
pk
'
)
obj
=
Bibliography
(
**
data
)
return
Bibliography
.
objects
.
get
(
pk
=
pk
)
return
obj
if
self
.
steps
.
current
==
'
ProteinForm
'
:
if
self
.
steps
.
current
==
'
ProteinForm
'
:
data
=
self
.
storage
.
get_step_data
(
'
PDBForm
'
).
getlist
(
'
set
'
)
pks
=
self
.
storage
.
get_step_data
(
'
PDBForm
'
).
get
(
'
pks
'
)
proteins
=
[]
return
Protein
.
objects
.
filter
(
id__in
=
pks
)
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
):
"""
"""
...
@@ -66,22 +57,25 @@ class IppiWizard(NamedUrlSessionWizardView):
...
@@ -66,22 +57,25 @@ class IppiWizard(NamedUrlSessionWizardView):
The added code just sets the form model for use in later forms
The added code just sets the form model for use in later forms
when appropriate
when appropriate
"""
"""
data
=
super
(
IppiWizard
,
self
).
process_step
(
form
).
copy
()
if
self
.
steps
.
current
==
'
IdForm
'
:
if
self
.
steps
.
current
==
'
IdForm
'
:
form
.
instance
.
autofill
()
form
.
instance
.
autofill
()
return
model_to_dict
(
form
.
instance
)
if
self
.
steps
.
current
in
[
'
IdForm
'
,
'
Bibliography
'
]:
form
.
instance
.
save
()
data
[
'
pk
'
]
=
form
.
instance
.
id
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
=
[]
protein
_id
s
=
[]
for
uniprot_id
in
uniprot_ids
:
for
uniprot_id
in
uniprot_ids
:
try
:
try
:
p
=
Protein
.
objects
.
get
(
uniprot_id
=
uniprot_id
)
p
=
Protein
.
objects
.
get
(
uniprot_id
=
uniprot_id
)
except
Protein
.
DoesNotExist
:
except
Protein
.
DoesNotExist
:
p
=
Protein
()
p
=
Protein
()
p
.
uniprot_id
=
uniprot_ids
[
0
]
p
.
uniprot_id
=
uniprot_ids
[
0
]
p
.
autofill
()
p
.
save
()
proteins
.
append
(
p
)
protein
_id
s
.
append
(
p
.
id
)
return
{
'
set
'
:
[
model_to_dict
(
p
,
exclude
=
[
'
molecular_functions
'
])
for
p
in
protein
s
]}
data
[
'
pks
'
]
=
protein
_ids
return
self
.
get_form_step_data
(
form
)
return
data
def
done
(
self
,
form_list
,
**
kwargs
):
def
done
(
self
,
form_list
,
**
kwargs
):
return
render
(
self
.
request
,
'
/admin-session/add.html
'
,
{
return
render
(
self
.
request
,
'
/admin-session/add.html
'
,
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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