SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit e677b7fb authored by Jean-Sébastien Caux's avatar Jean-Sébastien Caux
Browse files

Improve sponsors

parent c28226c1
No related branches found
No related tags found
No related merge requests found
...@@ -9,7 +9,16 @@ from django.db import models ...@@ -9,7 +9,16 @@ from django.db import models
class OrganizationQuerySet(models.QuerySet): 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): 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()) return self.filter(subsidy__date_until__gte=datetime.date.today())
def with_subsidy_above_and_up_to(self, min_amount, max_amount=None): def with_subsidy_above_and_up_to(self, min_amount, max_amount=None):
...@@ -21,3 +30,9 @@ class OrganizationQuerySet(models.QuerySet): ...@@ -21,3 +30,9 @@ class OrganizationQuerySet(models.QuerySet):
if max_amount: if max_amount:
qs = qs.filter(max_subsidy__lt=max_amount) qs = qs.filter(max_subsidy__lt=max_amount)
return qs 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')
...@@ -154,7 +154,7 @@ class Organization(models.Model): ...@@ -154,7 +154,7 @@ class Organization(models.Model):
""" """
return self.subsidy_set.filter(date_until__gte=datetime.date.today()).exists() 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 Computes the total amount received by SciPost, in the form
of subsidies from this Organization. of subsidies from this Organization.
......
...@@ -90,28 +90,28 @@ ...@@ -90,28 +90,28 @@
<div class="col-12"> <div class="col-12">
<h1 class="highlight">Our current Sponsors</h1> <h1 class="highlight">Our current Sponsors</h1>
<h3 class="highlight">Platinum sponsors (&euro;20k and above):</h3> <h3 class="highlight">&euro;20k and above:</h3>
<div class="card-columns"> <div class="card-columns">
{% for sponsor in sponsors_20kplus %} {% for sponsor in sponsors_20kplus %}
{% include 'sponsors/_sponsor_card.html' with sponsor=sponsor %} {% include 'sponsors/_sponsor_card.html' with sponsor=sponsor %}
{% endfor %} {% endfor %}
</div> </div>
<h3 class="highlight">Gold sponsors (&euro;10k and above):</h3> <h3 class="highlight">&euro;10k and above:</h3>
<div class="card-columns"> <div class="card-columns">
{% for sponsor in sponsors_10kplus %} {% for sponsor in sponsors_10kplus %}
{% include 'sponsors/_sponsor_card.html' with sponsor=sponsor %} {% include 'sponsors/_sponsor_card.html' with sponsor=sponsor %}
{% endfor %} {% endfor %}
</div> </div>
<h3 class="highlight">Silver sponsors (&euro;5k and above):</h3> <h3 class="highlight">&euro;5k and above:</h3>
<div class="card-columns"> <div class="card-columns">
{% for sponsor in sponsors_5kplus %} {% for sponsor in sponsors_5kplus %}
{% include 'sponsors/_sponsor_card.html' with sponsor=sponsor %} {% include 'sponsors/_sponsor_card.html' with sponsor=sponsor %}
{% endfor %} {% endfor %}
</div> </div>
<h3 class="highlight">All current Sponsors</h3> <h3 class="highlight">Our other current Sponsors:</h3>
<div class="card-columns"> <div class="card-columns">
{% for sponsor in current_sponsors %} {% for sponsor in current_sponsors %}
{% include 'sponsors/_sponsor_card.html' with sponsor=sponsor %} {% include 'sponsors/_sponsor_card.html' with sponsor=sponsor %}
......
...@@ -11,11 +11,11 @@ def sponsors(request): ...@@ -11,11 +11,11 @@ def sponsors(request):
sponsors_20kplus = Organization.objects.with_subsidy_above_and_up_to(20000) sponsors_20kplus = Organization.objects.with_subsidy_above_and_up_to(20000)
sponsors_10kplus = Organization.objects.with_subsidy_above_and_up_to(10000, 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) 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 = { context = {
'sponsors_20kplus': sponsors_20kplus, 'sponsors_20kplus': sponsors_20kplus,
'sponsors_10kplus': sponsors_10kplus, 'sponsors_10kplus': sponsors_10kplus,
'sponsors_5kplus': sponsors_5kplus, 'sponsors_5kplus': sponsors_5kplus,
'current_sponsors': current_sponsors, 'current_sponsors': current_sponsors.order_by_total_amount_received(),
} }
return render(request, 'sponsors/sponsors.html', context) return render(request, 'sponsors/sponsors.html', context)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment