Commit e1e2eb31 authored by Hervé  MENAGER's avatar Hervé MENAGER
Browse files

add contributor detail page (first draft, WIP)

parent 3d2695de
Pipeline #72633 failed with stage
in 11 minutes and 28 seconds
{% extends "about.html" %}
{% block title %}inhibitors of Protein-Protein Interaction Database{% endblock %}
{% block pagetitle %}Contributors{% endblock%}
{% block view_content %}
<div class="row">
{{ object.get_contributor_firstname | capfirst }} {{ object.get_contributor_lastname | capfirst }} || {{ object.get_orcid_url }}
</div>
{% endblock %}
\ No newline at end of file
......@@ -16,7 +16,7 @@
<tbody>
{% for contributor in object_list %}
<tr>
<td>{{ contributor.get_contributor_firstname | capfirst }} {{ contributor.get_contributor_lastname | capfirst }}</td>
<td><a href="{{ contributor.id }}">{{ contributor.get_contributor_firstname | capfirst }} {{ contributor.get_contributor_lastname | capfirst }}</a></td>
<td><a href="{{ contributor.get_orcid_url }}" target="_blank">{{ contributor.get_orcid }}</a></td>
</tr>
{% endfor %}
......
......@@ -61,7 +61,8 @@ 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"^about-contributors/$", views.ContributorListView.as_view(), name="contributors"),
re_path(r"^about-contributors/(?P<pk>\d+)$", views.ContributorDetailView.as_view(), name="contributor_card"),
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)),
......
......@@ -32,7 +32,8 @@ from .about import (
about_pca,
about_pharmacology,
about_physicochemistry,
ContributorsListView,
ContributorListView,
ContributorDetailView,
)
from django.conf import settings
......@@ -103,7 +104,8 @@ __all__ = [
about_pca,
about_pharmacology,
about_physicochemistry,
ContributorsListView,
ContributorListView,
ContributorDetailView,
PdbViewSet,
DistanceViewSet,
PDBView,
......
......@@ -2,11 +2,11 @@
iPPI-DB global statistics views
"""
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.detail import DetailView
from django.views.generic.list import ListView
import json
......@@ -324,7 +324,7 @@ def get_contributor_firstname(self):
orcid = self.get_orcid()
if orcid is not None:
data = self.__orcid_json
return data['first_name']
return data["first_name"]
@cached_orcid_json
......@@ -335,7 +335,7 @@ def get_contributor_lastname(self):
orcid = self.get_orcid()
if orcid is not None:
data = self.__orcid_json
return data['last_name']
return data["last_name"]
User.add_to_class("get_orcid", get_orcid)
......@@ -345,9 +345,11 @@ User.add_to_class("get_contributor_firstname", get_contributor_firstname)
User.add_to_class("get_contributor_lastname", get_contributor_lastname)
class ContributorsListView(ListView):
class ContributorListView(ListView):
"""
Contributors list view
This view lists the users with at least one accepted contribution
"""
model = User
......@@ -359,3 +361,20 @@ class ContributorsListView(ListView):
socialaccount__isnull=False, contributions_count__gt=0
)
return qs
class ContributorDetailView(DetailView):
"""
Contributor detail view
"""
model = User
template_name = "about-contributor-card.html"
def get_queryset(self):
qs = super().get_queryset()
qs = qs.annotate(contributions_count=Count("contribution")).filter(
socialaccount__isnull=False, contributions_count__gt=0
)
return qs
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment