From 4a012a152b803fba0a8a5224135a162829c27c86 Mon Sep 17 00:00:00 2001 From: "J.-S. Caux" <J.S.Caux@uva.nl> Date: Sun, 18 Nov 2018 19:55:15 +0100 Subject: [PATCH] Add counter for topic top experts --- ontology/templates/ontology/_topic_card.html | 4 ++-- profiles/models.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ontology/templates/ontology/_topic_card.html b/ontology/templates/ontology/_topic_card.html index 977868b95..b10236689 100644 --- a/ontology/templates/ontology/_topic_card.html +++ b/ontology/templates/ontology/_topic_card.html @@ -126,9 +126,9 @@ {% get_profiles topic.slug as profiles %} {% for profile in profiles %} {% if profile.contributor %} - <li><a href="{{ profile.contributor.get_absolute_url }}">{{ profile }}</a></li> + <li><a href="{{ profile.contributor.get_absolute_url }}">{{ profile }}</a> ({{ profile.count }})</li> {% else %} - <li>{{ profile }}</li> + <li>{{ profile }} ({{ profile.count }})</li> {% endif %} {% empty %} <li>No Profile found</li> diff --git a/profiles/models.py b/profiles/models.py index ae6ae3ffa..711eeb20d 100644 --- a/profiles/models.py +++ b/profiles/models.py @@ -140,7 +140,8 @@ def get_profiles(slug): unreg_id_list = [tbl.unregistered_author.id for tbl in publications.all() \ if tbl.unregistered_author is not None] return Profile.objects.filter(models.Q(contributor__id__in=cont_id_list) | - models.Q(unregisteredauthor__id__in=unreg_id_list)) + models.Q(unregisteredauthor__id__in=unreg_id_list + )).annotate(count=models.Count('id')).distinct().order_by('-count') class ProfileNonDuplicates(models.Model): -- GitLab