Skip to content

Commit 7f87f1a

Browse files
feat: Add gold members on pages foundation and community
1 parent d5e2d08 commit 7f87f1a

File tree

8 files changed

+95
-3
lines changed

8 files changed

+95
-3
lines changed

aggregator/tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def setUp(self, mocker):
9292
def test_community_index_number_of_queries(self):
9393
"""Intended to prevent an n+1 issue on the community index view"""
9494
url = reverse("community-index")
95-
with self.assertNumQueries(6):
95+
with self.assertNumQueries(7):
9696
self.client.get(url)
9797

9898
def test_empty_feed_type_not_rendered(self):

djangoproject/templates/aggregator/index.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{% extends "base_community.html" %}
2-
{% load i18n %}
2+
{% load fundraising_extras i18n %}
33

44
{% block layout_class %}column-container sidebar-right{% endblock %}
55

@@ -97,3 +97,7 @@ <h2 class="bullet-icon"><i class="icon icon-rss blue"></i> {{ feedtype.name }}</
9797
{% endfor %}
9898
</ul>
9999
{% endblock %}
100+
101+
{% block content-related-extra %}
102+
{% gold_corporate_members %}
103+
{% endblock %}

djangoproject/templates/base_community.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
{% block content-related %}
2424
<div role="complementary">
2525
<h2 class="visuallyhidden" id="aside-header">{% translate "Additional Information" %}</h2>
26+
27+
{% block content-related-extra %}{% endblock %}
28+
2629
{% donation_snippet %}
2730

2831
<h3>{% translate "More Help" %}</h3>

djangoproject/templates/base_foundation.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
{# Always include <h2> label and <div> with aria role. #}
1616
<div role="complementary">
1717
<h2 class="visuallyhidden" id="aside-header">{% translate "Additional Information" %}</h2>
18+
19+
{% block content-related-extra %}{% endblock %}
20+
1821
{% donation_snippet %}
1922

2023
<h3>About the foundation</h3>
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{% extends "base_foundation.html" %}
2-
2+
{% load fundraising_extras %}
33
{% block og_title %}{{ flatpage.title }}{% endblock %}
44

55
{% block title %}{{ flatpage.title }}{% endblock %}
@@ -8,3 +8,7 @@
88
<h1>{{ flatpage.title }}</h1>
99
{{ flatpage.content }}
1010
{% endblock %}
11+
12+
{% block content-related-extra %}
13+
{% gold_corporate_members %}
14+
{% endblock %}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{% if members %}
2+
<div class="corporate-members">
3+
<h3>Gold Members</h3>
4+
{% for obj in members %}
5+
<div class="clearfix">
6+
<div class="member-logo">
7+
<a href="{{ obj.url }}" title="{{ obj.display_name }}">
8+
<img src="{{ obj.thumbnail.url }}" alt="{{ obj.display_name }}" />
9+
</a>
10+
</div>
11+
<div class="small-cta">
12+
<ul class="list-links-small">
13+
<li><strong>{{ obj.display_name }}</strong></li>
14+
<li><a href="{{ obj.url }}" title="{{ obj.display_name }}">
15+
{{ obj.description }}
16+
</a></li>
17+
</ul>
18+
</div>
19+
</div>
20+
{% endfor %}
21+
</div>
22+
{% endif %}

fundraising/templatetags/fundraising_extras.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,10 @@ def top_corporate_members():
118118
members = CorporateMember.objects.by_membership_level()
119119

120120
return {"members": members["diamond"] + members["platinum"]}
121+
122+
123+
@register.inclusion_tag("fundraising/includes/gold_corporate_members.html")
124+
def gold_corporate_members():
125+
members = CorporateMember.objects.by_membership_level()
126+
127+
return {"members": members["gold"]}

fundraising/tests/test_templatetags.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from ..templatetags.fundraising_extras import (
1818
display_django_heroes,
1919
donation_form_with_heart,
20+
gold_corporate_members,
2021
top_corporate_members,
2122
)
2223

@@ -167,3 +168,51 @@ def test_with_diamond_members_and_platinum_members(self):
167168
expected = [member_5, member_4, member_6, member_2, member_1, member_3]
168169

169170
self.assertEqual(members, expected)
171+
172+
173+
class TestGoldCorporateMembers(TestCase):
174+
past_date = date(2000, 1, 1)
175+
future_date = date(3000, 1, 1)
176+
177+
def test_with_no_gold_members(self):
178+
members = gold_corporate_members()["members"]
179+
self.assertEqual(members, [])
180+
181+
def test_with_gold_members(self):
182+
member_1 = CorporateMember.objects.create(membership_level=3)
183+
member_2 = CorporateMember.objects.create(membership_level=3)
184+
member_3 = CorporateMember.objects.create(membership_level=3)
185+
186+
member_1.invoice_set.create(amount=4, expiration_date=self.future_date)
187+
member_2.invoice_set.create(amount=8, expiration_date=self.future_date)
188+
member_3.invoice_set.create(amount=2, expiration_date=self.future_date)
189+
190+
members = gold_corporate_members()["members"]
191+
192+
self.assertEqual(members, [member_2, member_1, member_3])
193+
194+
def test_with_gold_members_and_other_members(self):
195+
member_1 = CorporateMember.objects.create(membership_level=3)
196+
member_2 = CorporateMember.objects.create(membership_level=3)
197+
member_3 = CorporateMember.objects.create(membership_level=4)
198+
199+
member_1.invoice_set.create(amount=4, expiration_date=self.future_date)
200+
member_2.invoice_set.create(amount=8, expiration_date=self.future_date)
201+
member_3.invoice_set.create(amount=2, expiration_date=self.future_date)
202+
203+
members = gold_corporate_members()["members"]
204+
self.assertEqual(members, [member_2, member_1])
205+
self.assertNotIn(member_3, members)
206+
207+
def test_with_gold_members_and_expired_invoice(self):
208+
member_1 = CorporateMember.objects.create(membership_level=3)
209+
member_2 = CorporateMember.objects.create(membership_level=3)
210+
member_3 = CorporateMember.objects.create(membership_level=4)
211+
212+
member_1.invoice_set.create(amount=4, expiration_date=self.future_date)
213+
member_2.invoice_set.create(amount=8, expiration_date=self.future_date)
214+
member_3.invoice_set.create(amount=2, expiration_date=self.past_date)
215+
216+
members = gold_corporate_members()["members"]
217+
self.assertEqual(members, [member_2, member_1])
218+
self.assertNotIn(member_3, members)

0 commit comments

Comments
 (0)