From 797fe3da727b08aa254f7b776d922acb09b6de90 Mon Sep 17 00:00:00 2001
From: "J.-S. Caux" <J.S.Caux@uva.nl>
Date: Sun, 30 Sep 2018 17:22:44 +0200
Subject: [PATCH] Compactify code

---
 profiles/views.py   | 5 +++--
 scipost/managers.py | 3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/profiles/views.py b/profiles/views.py
index 334db0c74..be6a8327f 100644
--- a/profiles/views.py
+++ b/profiles/views.py
@@ -102,9 +102,10 @@ class ProfileListView(PermissionsMixin, ListView):
     def get_context_data(self, **kwargs):
         context = super().get_context_data(**kwargs)
         context['subject_areas'] = SCIPOST_SUBJECT_AREAS
+        contributors_dup_email = Contributor.objects.have_duplicate_email()
+        context['nr_contributors_w_duplicate_email'] = contributors_dup_email.count()
+        context['contributors_w_duplicate_email'] = contributors_dup_email
         contributors_wo_profile = Contributor.objects.filter(profile=None)
-        context['nr_contributors_w_duplicate_email'] = Contributor.objects.have_duplicate_email().count()
-        context['contributors_w_duplicate_email'] = Contributor.objects.have_duplicate_email()
         context['nr_contributors_wo_profile'] = contributors_wo_profile.count()
         #context['next_contributor_wo_profile'] = random.choice(contributors_wo_profile)
         context['next_contributor_wo_profile'] = contributors_wo_profile.first()
diff --git a/scipost/managers.py b/scipost/managers.py
index 80b23c65f..8d698f401 100644
--- a/scipost/managers.py
+++ b/scipost/managers.py
@@ -32,7 +32,8 @@ class ContributorQuerySet(models.QuerySet):
         """ Return Contributors having duplicate emails. """
         duplicates = self.values(lower_email=Lower('user__email')).annotate(
             Count('id')).order_by('user__last_name').filter(id__count__gt=1)
-        return self.annotate(lower_email=Lower('user__email')).filter(lower_email__in=[dup['lower_email'] for dup in duplicates])
+        return self.annotate(lower_email=Lower('user__email')
+        ).filter(lower_email__in=[dup['lower_email'] for dup in duplicates])
 
     def available(self):
         """Filter out the Contributors that have active unavailability periods."""
-- 
GitLab