forked from gitcoinco/web
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Send an email if a bounty is funded below a threshold
Fixes: gitcoinco#2808
- Loading branch information
1 parent
653d229
commit 5801ca2
Showing
4 changed files
with
60 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ | |
from django.templatetags.static import static | ||
from django.utils import timezone, translation | ||
from django.utils.translation import gettext | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
import requests | ||
import twitter | ||
|
@@ -42,6 +43,31 @@ | |
logger = logging.getLogger(__name__) | ||
|
||
|
||
def notify_of_lowball_bounty(bounty): | ||
"""Send an email to [email protected] with the lowball bounty info | ||
Args: | ||
bounty (dashboard.models.Bounty): The lowball bounty object | ||
""" | ||
to_email = '[email protected]' | ||
from_email = settings.CONTACT_EMAIL | ||
cur_language = translation.get_language() | ||
try: | ||
setup_lang(to_email) | ||
subject = _("Low Bounty Notification") | ||
body = \ | ||
f"Bounty: {bounty}\n\n" \ | ||
f"url: {bounty.url}\n\n" \ | ||
f"Owner Name: {bounty.bounty_owner_name}\n\n" \ | ||
f"Owner Email: {bounty.bounty_owner_email}\n\n" \ | ||
f"Owner Address: {bounty.bounty_owner_address}\n\n" \ | ||
f"Owner Profile: {bounty.bounty_owner_profile}" | ||
send_mail(from_email, to_email, subject, body, from_name=_("No Reply from Gitcoin.co"), categories=['admin'], ) | ||
finally: | ||
translation.activate(cur_language) | ||
|
||
|
||
def github_org_to_twitter_tags(github_org): | ||
"""Build a string of github organization twitter tags. | ||
|
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 |
---|---|---|
|
@@ -18,9 +18,12 @@ | |
""" | ||
from datetime import datetime | ||
from unittest.mock import patch | ||
|
||
from dashboard.models import Bounty | ||
from dashboard.notifications import amount_usdt_open_work, append_snooze_copy, build_github_notification | ||
from dashboard.notifications import ( | ||
amount_usdt_open_work, append_snooze_copy, build_github_notification, notify_of_lowball_bounty, | ||
) | ||
from pytz import UTC | ||
from test_plus.test import TestCase | ||
|
||
|
@@ -38,7 +41,9 @@ def setUp(self): | |
github_url='https://github.com/gitcoinco/web/issues/11', | ||
token_address='0x0', | ||
issue_description='hello world', | ||
bounty_owner_name="Fred", | ||
bounty_owner_github_username='flintstone', | ||
bounty_owner_email="[email protected]" | ||
is_open=False, | ||
accepted=True, | ||
expires_date=datetime(2008, 11, 30, tzinfo=UTC), | ||
|
@@ -87,6 +92,11 @@ def test_append_snooze_copy(self): | |
copy = f'\nFunders only: Snooze warnings for {copy}' | ||
assert segments[i] == copy | ||
|
||
@patch('marketing.mails.send_mail') | ||
def test_notify_of_lowball_bounty(self): | ||
notify_of_lowball_bounty(self.bounty) | ||
assert mock_send_mail.call_count == 1 | ||
|
||
def tearDown(self): | ||
"""Perform cleanup for the testcase.""" | ||
self.bounty.delete() |