-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #947 from amakarudze/update-emails
Update email templates for global partners
- Loading branch information
Showing
16 changed files
with
332 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
24 changes: 24 additions & 0 deletions
24
globalpartners/management/commands/send_prospective_sponsor_email.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from datetime import date | ||
|
||
from django.core.management.base import BaseCommand | ||
|
||
from globalpartners.emails import send_prospective_sponsor_email | ||
from globalpartners.models import GlobalPartner | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Sends emails to prospective sponsors" | ||
|
||
def add_arguments(self, parser): | ||
pass | ||
|
||
def handle(self, *args, **kwargs): | ||
try: | ||
prospective_sponsors = GlobalPartner.objects.exclude(prospective_sponsor=False).filter(contacted=False) | ||
for sponsor in prospective_sponsors: | ||
send_prospective_sponsor_email(sponsor.contact_person, sponsor.contact_email) | ||
sponsor.contacted = True | ||
sponsor.date_contacted = date.today() | ||
sponsor.save(update_fields=["contacted", "date_contacted"]) | ||
except GlobalPartner.DoesNotExist: | ||
self.stdout.write(self.style.error("No prospective sponsors to email at this point.")) |
30 changes: 30 additions & 0 deletions
30
globalpartners/management/commands/send_sponsor_promotional_material_email.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from django.core.management.base import BaseCommand | ||
|
||
from globalpartners.emails import send_promotional_material_email | ||
from globalpartners.models import GlobalPartner | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Sends emails to sponsors asking them for promotional materials" | ||
|
||
def add_arguments(self, parser): | ||
pass | ||
|
||
def handle(self, *args, **kwargs): | ||
try: | ||
sponsors = ( | ||
GlobalPartner.objects.exclude(prospective_sponsor=True) | ||
.filter(promotional_materials_requested=False) | ||
.filter(is_active=True) | ||
) | ||
for sponsor in sponsors: | ||
send_promotional_material_email( | ||
sponsor.contact_person, | ||
sponsor.contact_email, | ||
sponsor.prospective_sponsor, | ||
sponsor.sponsor_level_annual, | ||
) | ||
sponsor.promotional_materials_requested = True | ||
sponsor.save(update_fields=["promotional_materials_requested"]) | ||
except GlobalPartner.DoesNotExist: | ||
self.stdout.write(self.style.error("No emails requesting promotional materials to send at this point.")) |
29 changes: 29 additions & 0 deletions
29
globalpartners/management/commands/send_sponsor_renewal_email.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from datetime import date | ||
|
||
from django.core.management.base import BaseCommand | ||
|
||
from globalpartners.emails import send_renewal_email | ||
from globalpartners.models import GlobalPartner | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Sends renewal emails to sponsors" | ||
|
||
def add_arguments(self, parser): | ||
pass | ||
|
||
def handle(self, *args, **kwargs): | ||
try: | ||
sponsors = ( | ||
GlobalPartner.objects.exclude(prospective_sponsor=True) | ||
.filter(patreon_sponsor=False) | ||
.filter(contacted=False) | ||
.filter(next_renewal_date__lte=date.today()) | ||
) | ||
for sponsor in sponsors: | ||
send_renewal_email(sponsor.contact_email, sponsor.contact_email) | ||
sponsor.contacted = True | ||
sponsor.date_contacted = date.today() | ||
sponsor.save(update_fields=["contacted", "date_contacted"]) | ||
except GlobalPartner.DoesNotExist: | ||
self.stdout.write(self.style.error("No sponsor renewal emails to email at this point.")) |
26 changes: 26 additions & 0 deletions
26
globalpartners/management/commands/send_sponsor_thank_you_email.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from datetime import date | ||
|
||
from django.core.management.base import BaseCommand | ||
|
||
from globalpartners.emails import send_thank_you_email | ||
from globalpartners.models import GlobalPartner | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Sends thank you emails to sponsors at the end of the year" | ||
|
||
def add_arguments(self, parser): | ||
pass | ||
|
||
def handle(self, *args, **kwargs): | ||
today = date.today() | ||
year = today.year | ||
if today == date(year, 12, 12): | ||
try: | ||
sponsors = GlobalPartner.objects.exclude(is_active=False).filter(is_displayed=True) | ||
for sponsor in sponsors: | ||
send_thank_you_email(sponsor.contact_person, sponsor.contact_email) | ||
sponsor.contacted = False | ||
sponsor.save(update_fields=["contacted"]) | ||
except GlobalPartner.DoesNotExist: | ||
self.stdout.write(self.style.error("No thank you emails to send at this point.")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Generated by Django 3.2.20 on 2024-02-26 21:19 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("globalpartners", "0003_globalpartner_description"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="globalpartner", | ||
name="is_active", | ||
field=models.BooleanField(default=False), | ||
), | ||
migrations.AddField( | ||
model_name="globalpartner", | ||
name="promotional_materials_requested", | ||
field=models.BooleanField(default=False), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,15 @@ | ||
from io import StringIO | ||
|
||
import pytest | ||
|
||
from globalpartners.models import GlobalPartner | ||
|
||
|
||
@pytest.fixture | ||
def out(): | ||
out = StringIO() | ||
return out | ||
|
||
|
||
@pytest.fixture | ||
def global_partner_data(): | ||
|
@@ -17,3 +27,107 @@ def global_partner_data(): | |
"website_url": "https://www.djangoproject.com", | ||
} | ||
return data | ||
|
||
|
||
@pytest.fixture | ||
def partners(): | ||
return GlobalPartner.objects.bulk_create( | ||
[ | ||
GlobalPartner( | ||
company_name="Sherpany", | ||
contact_person="Jane Doe", | ||
contact_email="[email protected]", | ||
prospective_sponsor=True, | ||
contacted=False, | ||
), | ||
GlobalPartner( | ||
company_name="DigitalOcean", | ||
contact_person="John Doe", | ||
contact_email="[email protected]", | ||
prospective_sponsor=True, | ||
contacted=True, | ||
), | ||
GlobalPartner( | ||
company_name="PythonAnywhere", | ||
contact_person="Jane Doe", | ||
contact_email="[email protected]", | ||
prospective_sponsor=False, | ||
patreon_sponsor=True, | ||
patreon_level_per_month=500, | ||
sponsor_level_annual=5000, | ||
contacted=False, | ||
promotional_materials_requested=False, | ||
is_active=True, | ||
), | ||
GlobalPartner( | ||
company_name="3YourMind", | ||
contact_person="John Doe", | ||
contact_email="[email protected]", | ||
prospective_sponsor=False, | ||
patreon_sponsor=True, | ||
patreon_level_per_month=500, | ||
sponsor_level_annual=5000, | ||
contacted=True, | ||
promotional_materials_requested=True, | ||
is_active=True, | ||
), | ||
GlobalPartner( | ||
company_name="Zapier", | ||
contact_person="John Doe", | ||
contact_email="[email protected]", | ||
prospective_sponsor=False, | ||
patreon_sponsor=True, | ||
patreon_level_per_month=500, | ||
sponsor_level_annual=5000, | ||
contacted=True, | ||
promotional_materials_requested=False, | ||
is_active=True, | ||
), | ||
GlobalPartner( | ||
company_name="PostHog", | ||
contact_person="Jane Tes", | ||
contact_email="[email protected]", | ||
prospective_sponsor=False, | ||
patreon_sponsor=False, | ||
sponsor_level_annual=1000, | ||
contacted=False, | ||
promotional_materials_requested=False, | ||
is_active=False, | ||
next_renewal_date="2024-02-15", | ||
), | ||
GlobalPartner( | ||
company_name="Torchbox", | ||
contact_person="John Test", | ||
contact_email="[email protected]", | ||
prospective_sponsor=False, | ||
patreon_sponsor=False, | ||
sponsor_level_annual=500, | ||
contacted=True, | ||
promotional_materials_requested=False, | ||
is_active=True, | ||
next_renewal_date="2024-02-15", | ||
), | ||
GlobalPartner( | ||
company_name="Mirumee", | ||
contact_person="Test Contact", | ||
contact_email="[email protected]", | ||
prospective_sponsor=False, | ||
sponsor_level_annual=2500, | ||
contacted=True, | ||
promotional_materials_requested=True, | ||
is_active=True, | ||
next_renewal_date="2024-02-15", | ||
), | ||
GlobalPartner( | ||
company_name="Mirumee", | ||
contact_person="Test Contact", | ||
contact_email="[email protected]", | ||
prospective_sponsor=False, | ||
sponsor_level_annual=2500, | ||
contacted=True, | ||
promotional_materials_requested=False, | ||
is_active=False, | ||
next_renewal_date="2024-02-15", | ||
), | ||
] | ||
) |
Oops, something went wrong.