diff --git a/organizations/managers.py b/organizations/managers.py index c45a475bdffb9077f3a4ed04eb81af637d2d8499..50803e1393b32bfe574b9fdf0953826b9e90dbbc 100644 --- a/organizations/managers.py +++ b/organizations/managers.py @@ -9,7 +9,16 @@ from django.db import models class OrganizationQuerySet(models.QuerySet): + def all_sponsors(self): + """ + All Organizations which have subsidized SciPost at least once in the past. + """ + return self.filter(subsidy__amount__gte=0) + def current_sponsors(self): + """ + Organizations which have a Subsidy which is ongoing (date_until <= today). + """ return self.filter(subsidy__date_until__gte=datetime.date.today()) def with_subsidy_above_and_up_to(self, min_amount, max_amount=None): @@ -21,3 +30,9 @@ class OrganizationQuerySet(models.QuerySet): if max_amount: qs = qs.filter(max_subsidy__lt=max_amount) return qs + + def order_by_total_amount_received(self): + """ + Order by (decreasing) total amount received. + """ + return self.annotate(total=models.Sum('subsidy__amount')).order_by('-total') diff --git a/organizations/models.py b/organizations/models.py index efca90455dcb05833ac17a3d437db5868893682b..f47a81b1210f0a44306228ae95a01b089c9928f4 100644 --- a/organizations/models.py +++ b/organizations/models.py @@ -154,7 +154,7 @@ class Organization(models.Model): """ return self.subsidy_set.filter(date_until__gte=datetime.date.today()).exists() - def get_total_subsidies_obtained(self, n_years_part=None): + def get_total_subsidies_obtained(self, n_years_past=None): """ Computes the total amount received by SciPost, in the form of subsidies from this Organization. diff --git a/sponsors/templates/sponsors/sponsors.html b/sponsors/templates/sponsors/sponsors.html index d45e9f02af0e7aed7753d6d8bd9a9e45752ad210..adb2a3589fa0d90d735dc6cfb1718451cd5f8021 100644 --- a/sponsors/templates/sponsors/sponsors.html +++ b/sponsors/templates/sponsors/sponsors.html @@ -90,28 +90,28 @@ <div class="col-12"> <h1 class="highlight">Our current Sponsors</h1> - <h3 class="highlight">Platinum sponsors (€20k and above):</h3> + <h3 class="highlight">€20k and above:</h3> <div class="card-columns"> {% for sponsor in sponsors_20kplus %} {% include 'sponsors/_sponsor_card.html' with sponsor=sponsor %} {% endfor %} </div> - <h3 class="highlight">Gold sponsors (€10k and above):</h3> + <h3 class="highlight">€10k and above:</h3> <div class="card-columns"> {% for sponsor in sponsors_10kplus %} {% include 'sponsors/_sponsor_card.html' with sponsor=sponsor %} {% endfor %} </div> - <h3 class="highlight">Silver sponsors (€5k and above):</h3> + <h3 class="highlight">€5k and above:</h3> <div class="card-columns"> {% for sponsor in sponsors_5kplus %} {% include 'sponsors/_sponsor_card.html' with sponsor=sponsor %} {% endfor %} </div> - <h3 class="highlight">All current Sponsors</h3> + <h3 class="highlight">Our other current Sponsors:</h3> <div class="card-columns"> {% for sponsor in current_sponsors %} {% include 'sponsors/_sponsor_card.html' with sponsor=sponsor %} diff --git a/sponsors/views.py b/sponsors/views.py index 7768f060da06f698398bbad1691a85d3b6e72f3a..1d7a6a7fa4416bd958321113cd8e8c89c18a8a0f 100644 --- a/sponsors/views.py +++ b/sponsors/views.py @@ -11,11 +11,11 @@ def sponsors(request): sponsors_20kplus = Organization.objects.with_subsidy_above_and_up_to(20000) sponsors_10kplus = Organization.objects.with_subsidy_above_and_up_to(10000, 20000) sponsors_5kplus = Organization.objects.with_subsidy_above_and_up_to(5000, 10000) - current_sponsors = Organization.objects.current_sponsors() + current_sponsors = Organization.objects.current_sponsors().with_subsidy_above_and_up_to(0, 5000) context = { 'sponsors_20kplus': sponsors_20kplus, 'sponsors_10kplus': sponsors_10kplus, 'sponsors_5kplus': sponsors_5kplus, - 'current_sponsors': current_sponsors, + 'current_sponsors': current_sponsors.order_by_total_amount_received(), } return render(request, 'sponsors/sponsors.html', context)