diff --git a/core/userlists.py b/core/userlists.py index 2384a3b4..a31cea56 100644 --- a/core/userlists.py +++ b/core/userlists.py @@ -32,3 +32,12 @@ def work_list_users(work_list, how_many): else : user_list = work.wished_by()[0: how_many] return user_list + +def campaign_list_users(campaign_list, how_many): + users = User.objects.filter(wishlist__works__campaigns__in=campaign_list).distinct().reverse() + count = users.count() + if count <= how_many : + user_list = users[0: count] + else : + user_list = work.wished_by()[0: how_many] + return user_list diff --git a/frontend/templates/campaign_list.html b/frontend/templates/campaign_list.html index d0c86e47..cb480811 100644 --- a/frontend/templates/campaign_list.html +++ b/frontend/templates/campaign_list.html @@ -24,10 +24,11 @@
-
+
With your help we're trying to raise money to buy the right to give these books to the world.
-
+
diff --git a/frontend/views.py b/frontend/views.py index 8e7910e8..b901f375 100755 --- a/frontend/views.py +++ b/frontend/views.py @@ -185,6 +185,13 @@ class CampaignListView(ListView): return models.Campaign.objects.filter(activated__isnull = False, suspended__isnull = True, withdrawn__isnull = True).order_by('deadline') else: return models.Campaign.objects.all() + + def get_context_data(self, **kwargs): + context = super(CampaignListView, self).get_context_data(**kwargs) + qs=self.get_queryset() + context['ungluers'] = userlists.campaign_list_users(qs,5) + context['facet'] =self.kwargs['facet'] + return context class PledgeView(FormView): template_name="pledge.html"