Skip to content

Commit

Permalink
Update to fix SES issue, emails for colorado token, and a leaderboard…
Browse files Browse the repository at this point in the history
… fix.
  • Loading branch information
villanuevawill committed May 12, 2018
1 parent b9c92a2 commit fa40025
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
6 changes: 3 additions & 3 deletions bounties_api/bounties/ses_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
SENDER = 'Bounties Team <[email protected]>'
AWS_REGION = 'us-east-1'
CHARSET = "UTF-8"
client = boto3.client('ses', region_name=AWS_REGION,
aws_secret_access_key=settings.AWS_SECRET_ACCESS_KEY,
aws_access_key_id=settings.AWS_ACCESS_KEY_ID)
client = boto3.client('ses', region_name=AWS_REGION)

def send_email(receiver, subject, text):
if settings.LOCAL:
return
if settings.ENVIRONMENT not in ['rinkeby', 'production', 'consensys']:
return
try:
response = client.send_email(
Destination={
Expand Down
4 changes: 2 additions & 2 deletions bounties_api/std_bounties/client_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ def format_deadline(fields):
return merge(fields, {'deadline': deadline.strftime('%m/%d/%Y')})


def bounty_url_for(bounty_id):
url = '{}/bounty/v1/{}/'.format(settings.DEPLOY_URL, bounty_id)
def bounty_url_for(bounty_id, base_url_override=None):
url = '{}/bounty/v1/{}/'.format(base_url_override or settings.DEPLOY_URL, bounty_id)
return url


Expand Down
8 changes: 7 additions & 1 deletion bounties_api/std_bounties/master_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,14 @@ def bounty_fulfilled(bounty_id, **kwargs):
slack_client=sc,
before_formatter=[add_link]
)

if bounty.platform == 'colorado':
email_url = bounty_url_for(bounty_id, base_url_override='https://colorado.bounties.network')
else:
email_url = bounty_url_for(bounty_id)

send_email(bounty.issuer_email, 'Bounty Contribution Received',
'Hey there! You received a contribution for your bounty: {}. {}'.format(bounty.title, bounty_url_for(bounty_id)))
'Hey there! You received a contribution for your bounty: {}. {}'.format(bounty.title, email_url))


def fullfillment_updated(bounty_id, **kwargs):
Expand Down
12 changes: 8 additions & 4 deletions bounties_api/std_bounties/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ class UserProfile(APIView):
def get(self, request, address=''):
platform_in = extractInParams(request, 'platform', 'platform__in')
extra_filters = {}
if schema_name_in:
extra_filters['platform__in'] = schema_name_in
if platform_in:
extra_filters['platform__in'] = platform_in
ordered_fulfillments = Fulfillment.objects.filter(
fulfiller=address.lower(), **extra_filters).order_by('-created')
if not ordered_fulfillments.exists():
Expand All @@ -71,8 +71,12 @@ def get(self, request):
sql_param = ''
platform_in = extractInParams(request, 'platform', 'platform__in')
if platform_in:
sql_param = 'AND '
sql_param = 'AND ( '
sql_param += sqlGenerateOrList('fulfillment.\"platform\"', len(platform_in), '=')
sql_param += ' OR '
sql_param += sqlGenerateOrList('bounty.\"platform\"', len(platform_in), '=')
sql_param += ' )'
platform_in = platform_in + platform_in

formatted_query = LEADERBOARD_QUERY.format(sql_param)
cursor = connection.cursor()
Expand All @@ -88,7 +92,7 @@ def get(self, request, address=''):
extra_filters_bounty = {}
extra_filters_fulfillment = {}
platform_in = extractInParams(request, 'platform', 'platform__in')
if schema_name_in:
if platform_in:
extra_filters_bounty['platform__in'] = platform_in
extra_filters_fulfillment['platform__in'] = platform_in
user_bounties = Bounty.objects.filter(issuer=address.lower(), **extra_filters_bounty)
Expand Down

0 comments on commit fa40025

Please sign in to comment.