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
3ff9fc18
Commit
3ff9fc18
authored
6 years ago
by
Hervé MENAGER
Browse files
Options
Downloads
Patches
Plain Diff
allow sort on number of publications
cf #67 Former-commit-id: 9947d6f75f74085131ce6952cf4f1e0a2510e41f
parent
4935bcb8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ippisite/ippidb/views.py
+12
-6
12 additions, 6 deletions
ippisite/ippidb/views.py
with
12 additions
and
6 deletions
ippisite/ippidb/views.py
+
12
−
6
View file @
3ff9fc18
import
json
import
json
import
math
import
math
from
django.db.models
import
Max
,
Min
from
django.db.models
import
Max
,
Min
,
Count
from
django.shortcuts
import
render
from
django.shortcuts
import
render
from
django.http
import
HttpResponseRedirect
,
Http404
from
django.http
import
HttpResponseRedirect
,
Http404
from
django.core.paginator
import
Paginator
,
EmptyPage
,
PageNotAnInteger
from
django.core.paginator
import
Paginator
,
EmptyPage
,
PageNotAnInteger
...
@@ -153,7 +153,7 @@ def compound_list(request):
...
@@ -153,7 +153,7 @@ def compound_list(request):
Display the list of compounds
Display the list of compounds
"""
"""
context
=
{}
context
=
{}
compounds
=
Compound
.
objects
.
order_by
(
'
id
'
)
compounds
=
Compound
.
objects
.
all
(
)
if
request
.
GET
.
get
(
'
family
'
):
if
request
.
GET
.
get
(
'
family
'
):
compounds
=
compounds
.
filter
(
compoundaction__ppi__family__id__in
=
request
.
GET
.
getlist
(
'
family
'
))
compounds
=
compounds
.
filter
(
compoundaction__ppi__family__id__in
=
request
.
GET
.
getlist
(
'
family
'
))
# if filtering on "action on PPI"
# if filtering on "action on PPI"
...
@@ -179,8 +179,10 @@ def compound_list(request):
...
@@ -179,8 +179,10 @@ def compound_list(request):
taxonomies
=
Taxonomy
.
objects
.
exclude
(
id__in
=
request
.
GET
.
getlist
(
'
taxonomy
'
))
taxonomies
=
Taxonomy
.
objects
.
exclude
(
id__in
=
request
.
GET
.
getlist
(
'
taxonomy
'
))
selected_boundcomplexes
=
ProteinDomainBoundComplex
.
objects
.
filter
(
id__in
=
request
.
GET
.
getlist
(
'
boundcomplex
'
))
selected_boundcomplexes
=
ProteinDomainBoundComplex
.
objects
.
filter
(
id__in
=
request
.
GET
.
getlist
(
'
boundcomplex
'
))
boundcomplexes
=
ProteinDomainBoundComplex
.
objects
.
exclude
(
id__in
=
request
.
GET
.
getlist
(
'
boundcomplex
'
))
boundcomplexes
=
ProteinDomainBoundComplex
.
objects
.
exclude
(
id__in
=
request
.
GET
.
getlist
(
'
boundcomplex
'
))
sort_by_option_ids
=
[
'
id
'
,
'
molecular_weight
'
,
'
a_log_p
'
,
'
nb_aromatic_sssr
'
,
'
nb_chiral_centers
'
]
sort_by_option_ids
=
[
'
id
'
,
'
molecular_weight
'
,
'
a_log_p
'
,
'
nb_aromatic_sssr
'
,
'
nb_chiral_centers
'
,
'
pubs
'
]
sort_by
=
request
.
GET
.
get
(
'
sort_by
'
,
'
id
'
)
sort_by
=
request
.
GET
.
get
(
'
sort_by
'
,
'
id
'
)
if
sort_by
in
[
'
pubs
'
,
'
-pubs
'
]:
context
[
'
compounds
'
]
=
context
[
'
compounds
'
].
annotate
(
pubs
=
Count
(
'
refcompoundbiblio
'
))
context
[
'
compounds
'
]
=
context
[
'
compounds
'
].
order_by
(
sort_by
)
context
[
'
compounds
'
]
=
context
[
'
compounds
'
].
order_by
(
sort_by
)
context
[
'
compounds
'
]
=
context
[
'
compounds
'
].
distinct
()
context
[
'
compounds
'
]
=
context
[
'
compounds
'
].
distinct
()
# handle pagination in compounds list
# handle pagination in compounds list
...
@@ -201,10 +203,14 @@ def compound_list(request):
...
@@ -201,10 +203,14 @@ def compound_list(request):
compound_fields
=
{
f
.
name
:
f
.
verbose_name
for
f
in
Compound
.
_meta
.
get_fields
()
if
not
(
f
.
is_relation
)}
compound_fields
=
{
f
.
name
:
f
.
verbose_name
for
f
in
Compound
.
_meta
.
get_fields
()
if
not
(
f
.
is_relation
)}
sort_by_options
=
{}
sort_by_options
=
{}
for
sort_by_option_id
in
sort_by_option_ids
:
for
sort_by_option_id
in
sort_by_option_ids
:
sort_by_options
[
sort_by_option_id
]
=
{
'
name
'
:
compound_fields
[
sort_by_option_id
],
'
order
'
:
'
ascending
'
,
'
id
'
:
sort_by_option_id
}
if
sort_by_option_id
==
'
pubs
'
:
sort_by_options
[
'
-
'
+
sort_by_option_id
]
=
{
'
name
'
:
compound_fields
[
sort_by_option_id
],
'
order
'
:
'
descending
'
,
'
id
'
:
sort_by_option_id
}
name
=
'
Number of publications
'
else
:
name
=
compound_fields
.
get
(
sort_by_option_id
)
sort_by_options
[
sort_by_option_id
]
=
{
'
name
'
:
name
,
'
order
'
:
'
ascending
'
,
'
id
'
:
sort_by_option_id
}
sort_by_options
[
'
-
'
+
sort_by_option_id
]
=
{
'
name
'
:
name
,
'
order
'
:
'
descending
'
,
'
id
'
:
sort_by_option_id
}
fields
=
request
.
GET
.
getlist
(
'
fields
'
,[
'
id
'
,
'
common_name
'
,
'
molecular_weight
'
,
'
a_log_p
'
,
'
compound_action_pdb_ids
'
,
'
biblio_ref
s
'
])
fields
=
request
.
GET
.
getlist
(
'
fields
'
,[
'
id
'
,
'
common_name
'
,
'
molecular_weight
'
,
'
a_log_p
'
,
'
compound_action_pdb_ids
'
,
'
pub
s
'
])
if
'
id
'
not
in
fields
:
if
'
id
'
not
in
fields
:
fields
.
append
(
'
id
'
)
fields
.
append
(
'
id
'
)
context
[
'
selected_ppis
'
]
=
selected_ppis
context
[
'
selected_ppis
'
]
=
selected_ppis
...
...
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