diff --git a/core/context_processors.py b/core/context_processors.py index 49108d24d..534916a8e 100644 --- a/core/context_processors.py +++ b/core/context_processors.py @@ -17,6 +17,7 @@ def statistics(request): gold = global_partners.filter(sponsor_level_annual=2500) platinum = global_partners.filter(sponsor_level_annual=5000) silver = global_partners.filter(sponsor_level_annual=1000) + bronze = global_partners.filter(sponsor_level_annual=500) return { "past_events_count": past_events.count(), @@ -31,4 +32,5 @@ def statistics(request): "gold": gold, "platinum": platinum, "silver": silver, + "bronze": bronze, } diff --git a/donations/urls.py b/donations/urls.py index 686f33df7..ccf965765 100644 --- a/donations/urls.py +++ b/donations/urls.py @@ -9,4 +9,5 @@ path("charge/", views.charge, name="charge"), path("success///", views.success, name="success"), path("error/", views.error, name="error"), + path("sponsors/", views.sponsors, name="sponsors"), ] diff --git a/donations/views.py b/donations/views.py index 284f23370..ab08f061a 100644 --- a/donations/views.py +++ b/donations/views.py @@ -59,9 +59,12 @@ def success(request, currency, amount): def error(request): - if "stripe_message" in request.session: error_message = request.session.get("stripe_message") del request.session["stripe_message"] return render(request, "donations/error.html", {"stripe_message": error_message}) + + +def sponsors(request): + return render(request, "donations/sponsors.html") diff --git a/globalpartners/migrations/0003_globalpartner_description.py b/globalpartners/migrations/0003_globalpartner_description.py new file mode 100644 index 000000000..41ca77aab --- /dev/null +++ b/globalpartners/migrations/0003_globalpartner_description.py @@ -0,0 +1,17 @@ +# Generated by Django 3.2.18 on 2023-03-08 20:38 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("globalpartners", "0002_alter_globalpartner_sponsor_level_annual"), + ] + + operations = [ + migrations.AddField( + model_name="globalpartner", + name="description", + field=models.TextField(blank=True, max_length=1000, null=True), + ), + ] diff --git a/globalpartners/models.py b/globalpartners/models.py index dd72da5db..13f8bee28 100644 --- a/globalpartners/models.py +++ b/globalpartners/models.py @@ -37,6 +37,7 @@ class GlobalPartner(models.Model): date_contacted = models.DateField(blank=True, null=True) next_renewal_date = models.DateField(blank=True, null=True) logo = models.ImageField(upload_to="uploads", blank=True, null=True) + description = models.TextField(max_length=1000, blank=True, null=True) is_displayed = models.BooleanField(default=False) website_url = models.URLField(blank=True, null=True) style = models.CharField(max_length=50, blank=True, null=True) diff --git a/templates/donations/sponsors.html b/templates/donations/sponsors.html new file mode 100644 index 000000000..dbfcf8f61 --- /dev/null +++ b/templates/donations/sponsors.html @@ -0,0 +1,116 @@ +{% extends 'global/base.html' %} +{% load i18n static %} + +{% block content %} +{% url 'contact:landing' as contact_url %} + +
+

{% trans "Our Global Partners" %}

+ +
+ {% blocktrans trimmed %} + Our global partners are companies who are supporting our work by donating to us either monthly through + Patreon or through annual sponsorships. + Want to join these amazing companies in sponsoring us? + Our corporate sponsorships + start at 100 USD per month. Contact us! 📨 + {% endblocktrans %} +
+ + {% if diamond %} +

{% trans "Diamond - $10,000+ per year 💞✨" %}

+ + {% for sponsor in diamond %} +
+
+

{{ sponsor.company_name }}

+ {% if sponsor.description %} +

{{ sponsor.description| safe }}

+ {% endif %} +
+
+ {{ sponsor.company_name }} +
+
+ {% endfor %} + {% endif %} + + {% if platinum %} +

{% trans "Platinum - $5,000+ per year 💝✨" %}

+ + {% for sponsor in platinum %} +
+
+

{{ sponsor.company_name }}

+ {% if sponsor.description %} +

{{ sponsor.description| safe }}

+ {% endif %} +
+
+ {{ sponsor.company_name }} +
+
+ {% endfor %} + {% endif %} + + {% if gold %} +

{% trans "Gold - $2,500+ per year 💖✨" %}

+ + {% for sponsor in gold %} +
+
+

{{ sponsor.company_name }}

+ {% if sponsor.description %} +

{{ sponsor.description| safe }}

+ {% endif %} +
+
+ {{ sponsor.company_name }} +
+
+ {% endfor %} + {% endif %} + + {% if silver %} +

{% trans "Silver - $1,000+ per year 💗✨" %}

+ + {% for sponsor in sliver %} +
+
+

{{ sponsor.company_name }}

+ {% if sponsor.description %} +

{{ sponsor.description| safe }}

+ {% endif %} +
+
+ {{ sponsor.company_name }} +
+
+ {% endfor %} + {% endif %} + + {% if bronze %} +
+
+

{% block trans %}Bronze - $500+ per year 💓✨{% endblock %}

+
+
+ + {% for sponsor in bronze %} +
+
+

{{ sponsor.company_name }}

+ {% if sponsor.description %} +

{{ sponsor.description| safe }}

+ {% endif %} +
+
+ {{ sponsor.company_name }} +
+
+ {% endfor %} + {% endif %} + +
+ +{% endblock %} \ No newline at end of file diff --git a/templates/global/footer.html b/templates/global/footer.html index 55c20f8b6..7eec9d539 100644 --- a/templates/global/footer.html +++ b/templates/global/footer.html @@ -22,7 +22,8 @@
  • {% trans "Make a donation" %}
  • {% trans "Donate on Patreon" %}
  • {% trans "Contribute" %}
  • -
  • {% trans "Sponsor us" %}
  • +
  • {% trans "Sponsor us" %}
  • +
  • {% trans "Our Sponsors" %}
  • diff --git a/templates/global/menu.html b/templates/global/menu.html index 16f6511fb..f8f3dca47 100644 --- a/templates/global/menu.html +++ b/templates/global/menu.html @@ -30,6 +30,7 @@ diff --git a/templates/includes/_main_sponsors.html b/templates/includes/_main_sponsors.html index fe3d3f760..5e0f00c0d 100644 --- a/templates/includes/_main_sponsors.html +++ b/templates/includes/_main_sponsors.html @@ -9,7 +9,7 @@ {% for partner in diamond %} {% if forloop.first %}
    {% endif %}
    - + {{ partner.company_name }} @@ -28,7 +28,7 @@ {% for partner in platinum %} {% if forloop.first %}
    {% endif %}
    - + {{ partner.company_name }} @@ -47,7 +47,7 @@ {% for partner in gold %} {% if forloop.first %}
    {% endif %}
    - + {{ partner.company_name }} @@ -66,7 +66,7 @@ {% for partner in silver %} {% if forloop.first %}
    {% endif %}
    - + {{ partner.company_name }} @@ -85,7 +85,7 @@ {% for partner in bronze %} {% if forloop.first %}
    {% endif %}
    - + {{ partner.company_name }} diff --git a/templates/includes/_main_supporters.html b/templates/includes/_main_supporters.html index 83515974f..a8f4f0730 100644 --- a/templates/includes/_main_supporters.html +++ b/templates/includes/_main_supporters.html @@ -2,13 +2,13 @@
    - + Sentry diff --git a/tests/conftest.py b/tests/conftest.py index 5bca93b1c..bd17725d2 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -8,7 +8,6 @@ from globalpartners.models import GlobalPartner from pictures.models import StockPicture from sponsor.models import Donor - from tests.mocks import * # noqa @@ -17,7 +16,6 @@ def default_mocks(slack_mock): """ Add mocks that should be accessible for all tests in this function signature. """ - pass @pytest.fixture(autouse=True) @@ -283,12 +281,22 @@ def remote_story(): @pytest.fixture def globalpartner(db): return GlobalPartner.objects.create( - company_name="Django", contact_person="Jane Doe", contact_email="jane@djangoproject.com", logo="django.png" + company_name="Django Software Foundation", + contact_person="Jane Doe", + contact_email="jane@djangoproject.com", + logo="django.png", + is_displayed=True, + sponsor_level_annual=5000, ) @pytest.fixture def globalpartner2(db): return GlobalPartner.objects.create( - company_name="Caktus Group", contact_person="Jane Doe", contact_email="jane@caktus.com", logo="caktus.png" + company_name="Caktus Group", + contact_person="Jane Doe", + contact_email="jane@caktus.com", + logo="caktus.png", + is_displayed=True, + sponsor_level_annual=2500, ) diff --git a/tests/donations/test_views.py b/tests/donations/test_views.py index 68b3b027e..f586c851e 100644 --- a/tests/donations/test_views.py +++ b/tests/donations/test_views.py @@ -3,6 +3,7 @@ import pytest from django.test import override_settings from django.urls import reverse +from pytest_django.asserts import assertContains from stripe.error import StripeError STRIPE_PUBLIC_KEY = os.environ.get("STRIPE_PUBLIC_KEY", "test_public") @@ -54,3 +55,10 @@ def test_charge_post_invalid_keys(client): with pytest.raises(StripeError): # This is missing stripe data client.post(reverse("donations:charge"), data=charge_data) + + +def test_sponsors(client, globalpartner, globalpartner2): + resp = client.get(reverse("donations:sponsors")) + assert resp.status_code == 200 + assertContains(resp, "Django Software Foundation") + assertContains(resp, "Caktus Group")