Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
iPPIDB
ippidb-web
Commits
3d2695de
Commit
3d2695de
authored
Jan 04, 2022
by
Hervé MENAGER
Browse files
add list of contributors in the about page
TODO: contributor detail page
parent
465ca1d8
Changes
6
Hide whitespace changes
Inline
Side-by-side
ippisite/ippidb/templates/about-contributors.html
0 → 100644
View file @
3d2695de
{% extends "about.html" %}
{% block title %}inhibitors of Protein-Protein Interaction Database{% endblock %}
{% block pagetitle %}Contributors{% endblock%}
{% block view_content %}
<div
class=
"row"
>
<table
class=
"table table-striped"
>
<thead>
<tr>
<th
scope=
"col"
title=
"Contributor Name"
>
Name
</th>
<th
scope=
"col"
title=
"Contributor ORCID Link"
>
ORCID
</th>
</tr>
</thead>
<tbody>
{% for contributor in object_list %}
<tr>
<td>
{{ contributor.get_contributor_firstname | capfirst }} {{ contributor.get_contributor_lastname | capfirst }}
</td>
<td><a
href=
"{{ contributor.get_orcid_url }}"
target=
"_blank"
>
{{ contributor.get_orcid }}
</a></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %}
\ No newline at end of file
ippisite/ippidb/templates/about.html
View file @
3d2695de
...
...
@@ -27,6 +27,9 @@
<li>
<a
href=
"/about-pca"
>
Chemical space
</a>
</li>
<li>
<a
href=
"/contributors"
>
Contributors
</a>
</li>
</ul>
</div>
</nav>
...
...
ippisite/ippidb/urls.py
View file @
3d2695de
...
...
@@ -44,7 +44,7 @@ class IppiDbStaticSitemap(Sitemap):
sitemaps
=
{
"static"
:
IppiDbStaticSitemap
,
"compounds"
:
views
.
site
.
IppiDbCompoundSitemap
,
"compounds"
:
views
.
IppiDbCompoundSitemap
,
}
urlpatterns
=
[
...
...
@@ -61,6 +61,7 @@ urlpatterns = [
name
=
"physicochemistry"
,
),
re_path
(
r
"^about-pca/$"
,
views
.
about_pca
,
name
=
"pca"
),
re_path
(
r
"^about-contributors/$"
,
views
.
ContributorsListView
.
as_view
(),
name
=
"contributors"
),
re_path
(
r
"^targetcentric/$"
,
views
.
PDBView
.
as_view
(),
name
=
"cavities"
),
re_path
(
r
"^targetcentric/networks$"
,
views
.
NetworkView
.
as_view
(),
name
=
"networks"
),
re_path
(
r
"^api/"
,
include
(
ROUTER
.
urls
)),
...
...
ippisite/ippidb/views/__init__.py
View file @
3d2695de
...
...
@@ -32,6 +32,7 @@ from .about import (
about_pca
,
about_pharmacology
,
about_physicochemistry
,
ContributorsListView
,
)
from
django.conf
import
settings
...
...
@@ -102,6 +103,7 @@ __all__ = [
about_pca
,
about_pharmacology
,
about_physicochemistry
,
ContributorsListView
,
PdbViewSet
,
DistanceViewSet
,
PDBView
,
...
...
ippisite/ippidb/views/about.py
View file @
3d2695de
...
...
@@ -2,9 +2,12 @@
iPPI-DB global statistics views
"""
from
django.db.models
import
F
,
Count
,
FloatField
import
re
from
django.contrib.auth
import
get_user_model
from
django.db.models
import
F
,
Count
,
FloatField
,
QuerySet
from
django.db.models.functions
import
Cast
,
Floor
from
django.shortcuts
import
render
from
django.views.generic.list
import
ListView
import
json
...
...
@@ -19,6 +22,8 @@ from ippidb.models import (
Protein
,
)
from
ippidb.ws
import
get_orcid_user_details
def
about_general
(
request
):
compounds_count
=
Compound
.
objects
.
count
()
...
...
@@ -278,3 +283,79 @@ def about_pca(request):
except
PcaBiplotData
.
DoesNotExist
:
context
=
{}
return
render
(
request
,
"about-pca.html"
,
context
=
context
)
User
=
get_user_model
()
def
cached_orcid_json
(
getter_function
):
def
new_function
(
self
):
if
self
.
__orcid_json
is
None
:
self
.
__orcid_json
=
get_orcid_user_details
(
self
.
get_orcid
())
ret
=
getter_function
(
self
)
return
ret
return
new_function
def
get_orcid
(
self
):
"""
Get contributor ORCID from their allauth social account
"""
if
self
.
socialaccount_set
.
count
()
>
0
:
return
self
.
socialaccount_set
.
all
()[
0
].
uid
return
None
def
get_orcid_url
(
self
):
"""
Get contributor ORCID fURL from their allauth profile
"""
if
self
.
socialaccount_set
.
count
()
>
0
:
return
self
.
socialaccount_set
.
all
()[
0
].
get_profile_url
()
return
None
@
cached_orcid_json
def
get_contributor_firstname
(
self
):
"""
Get contributor full name from their ORCID profile
"""
orcid
=
self
.
get_orcid
()
if
orcid
is
not
None
:
data
=
self
.
__orcid_json
return
data
[
'first_name'
]
@
cached_orcid_json
def
get_contributor_lastname
(
self
):
"""
Get contributor full name from their ORCID profile
"""
orcid
=
self
.
get_orcid
()
if
orcid
is
not
None
:
data
=
self
.
__orcid_json
return
data
[
'last_name'
]
User
.
add_to_class
(
"get_orcid"
,
get_orcid
)
User
.
add_to_class
(
"get_orcid_url"
,
get_orcid_url
)
User
.
add_to_class
(
"__orcid_json"
,
None
)
User
.
add_to_class
(
"get_contributor_firstname"
,
get_contributor_firstname
)
User
.
add_to_class
(
"get_contributor_lastname"
,
get_contributor_lastname
)
class
ContributorsListView
(
ListView
):
"""
Contributors list view
"""
model
=
User
template_name
=
"about-contributors.html"
def
get_queryset
(
self
)
->
QuerySet
[
User
]:
qs
=
super
().
get_queryset
()
qs
=
qs
.
annotate
(
contributions_count
=
Count
(
"contribution"
)).
filter
(
socialaccount__isnull
=
False
,
contributions_count__gt
=
0
)
return
qs
ippisite/ippidb/ws.py
View file @
3d2695de
...
...
@@ -598,6 +598,6 @@ def get_orcid_user_details(orcid: str) -> str:
)
data
=
resp
.
json
()
return
{
"first"
:
data
[
"name"
][
"given-names"
][
"value"
],
"last"
:
data
[
"name"
][
"family-name"
][
"value"
],
"first
_name
"
:
data
[
"name"
][
"given-names"
][
"value"
],
"last
_name
"
:
data
[
"name"
][
"family-name"
][
"value"
],
}
Write
Preview
Supports
Markdown
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!
Cancel
Please
register
or
sign in
to comment