SciPost Code Repository

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

Improve sponsors

parent 250fcbdf
No related branches found
No related tags found
No related merge requests found
...@@ -60,6 +60,9 @@ class SubsidyListView(ListView): ...@@ -60,6 +60,9 @@ class SubsidyListView(ListView):
def get_queryset(self): def get_queryset(self):
qs = super().get_queryset() qs = super().get_queryset()
org = self.request.GET.get('org')
if org:
qs = qs.filter(organization__pk=org)
order_by = self.request.GET.get('order_by') order_by = self.request.GET.get('order_by')
ordering = self.request.GET.get('ordering') ordering = self.request.GET.get('ordering')
if order_by == 'amount': if order_by == 'amount':
......
...@@ -11,3 +11,13 @@ class OrganizationQuerySet(models.QuerySet): ...@@ -11,3 +11,13 @@ class OrganizationQuerySet(models.QuerySet):
def current_sponsors(self): def current_sponsors(self):
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):
"""
List of sponsors with at least one subsidy above parameter:amount.
"""
qs = self.annotate(max_subsidy=models.Max('subsidy__amount')
).filter(max_subsidy__gte=min_amount)
if max_amount:
qs = qs.filter(max_subsidy__lt=max_amount)
return qs
<div class="card">
<img class="card-img-top {{ sponsor.css_class }} p-2" src="{% if sponsor.logo %}{{ sponsor.logo.url }}{% endif %}" alt="{{ sponsor.name }} logo">
<div class="card-body bg-light">
<h4 class="card-title">
{% if sponsor.name_original %}{{ sponsor.name_original }}{% else %}{{ sponsor.name }}{% endif %}</h4>
{% if sponsor.name_original %}
<p class="card-text">({{ sponsor.name }})</p>
{% endif %}
<img src="{{ sponsor.country.flag }}" alt="{{ sponsor.country }} flag"/>&nbsp;<span class="text-muted"><small>[{{ sponsor.country }}]</small></span>&nbsp;&nbsp;{{ sponsor.get_country_display }}
&nbsp;&nbsp;<a href="{% url 'finances:subsidies' %}?org={{ sponsor.id }}">See subsidies</a>
</div>
</div>
...@@ -90,19 +90,31 @@ ...@@ -90,19 +90,31 @@
<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;20000 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 (&euro;10000 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 (&euro;5000 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>
<div class="card-columns"> <div class="card-columns">
{% for sponsor in current_sponsors %} {% for sponsor in current_sponsors %}
<div class="card"> {% include 'sponsors/_sponsor_card.html' with sponsor=sponsor %}
<img class="card-img-top {{ sponsor.css_class }} p-2" src="{% if sponsor.logo %}{{ sponsor.logo.url }}{% endif %}" alt="{{ sponsor.name }} logo">
<div class="card-body bg-light">
<h4 class="card-title">
{% if sponsor.name_original %}{{ sponsor.name_original }}{% else %}{{ sponsor.name }}{% endif %}</h4>
{% if sponsor.name_original %}
<p class="card-text">({{ sponsor.name }})</p>
{% endif %}
<img src="{{ sponsor.country.flag }}" alt="{{ sponsor.country }} flag"/>&nbsp;<span class="text-muted"><small>[{{ sponsor.country }}]</small></span>&nbsp;&nbsp;{{ sponsor.get_country_display }}
</div>
</div>
{% endfor %} {% endfor %}
</div> </div>
......
...@@ -8,8 +8,14 @@ from organizations.models import Organization ...@@ -8,8 +8,14 @@ from organizations.models import Organization
def sponsors(request): 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()
context = { context = {
'sponsors_20kplus': sponsors_20kplus,
'sponsors_10kplus': sponsors_10kplus,
'sponsors_5kplus': sponsors_5kplus,
'current_sponsors': current_sponsors, 'current_sponsors': current_sponsors,
} }
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