Skip to content

Commit

Permalink
Adds unrating bounty to the emails
Browse files Browse the repository at this point in the history
  • Loading branch information
SaptakS committed Apr 3, 2019
1 parent 9f3c32d commit 22d89a9
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 19 deletions.
20 changes: 20 additions & 0 deletions app/dashboard/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,26 @@ def get_bounty_from_invite_url(invite_url):
return {'inviter': inviter, 'bounty': bounty}


def get_unrated_bounties_count(user):
unrated_contributed = Bounty.objects.current().prefetch_related('feedbacks').filter(interested__profile=user) \
.filter(interested__status='okay') \
.filter(interested__pending=False).filter(idx_status='done') \
.exclude(
feedbacks__feedbackType='worker',
feedbacks__sender_profile=user
)
unrated_funded = Bounty.objects.prefetch_related('fulfillments', 'interested', 'interested__profile', 'feedbacks') \
.filter(
bounty_owner_github_username__iexact=user.handle,
idx_status='done'
).exclude(
feedbacks__feedbackType='approver',
feedbacks__sender_profile=user,
)
unrated_count = unrated_funded.count() + unrated_contributed.count()
return unrated_count


def getStandardBountiesContractAddresss(network):
if network == 'mainnet':
return to_checksum_address('0x2af47a65da8cd66729b4209c22017d6a5c2d2400')
Expand Down
20 changes: 3 additions & 17 deletions app/dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@
maybe_market_to_user_slack,
)
from .utils import (
get_bounty, get_bounty_id, get_context, get_web3, has_tx_mined, record_user_action_on_interest, web3_process_bounty,
get_bounty, get_bounty_id, get_context, get_unrated_bounties_count,get_web3, has_tx_mined,
record_user_action_on_interest, web3_process_bounty,
)

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -435,22 +436,7 @@ def unrated_bounties(request):
status=401)

if user:
unrated_contributed = Bounty.objects.current().prefetch_related('feedbacks').filter(interested__profile=user) \
.filter(interested__status='okay') \
.filter(interested__pending=False).filter(idx_status='done') \
.exclude(
feedbacks__feedbackType='worker',
feedbacks__sender_profile=user
)
unrated_funded = Bounty.objects.prefetch_related('fulfillments', 'interested', 'interested__profile', 'feedbacks') \
.filter(
bounty_owner_github_username__iexact=user.handle,
idx_status='done'
).exclude(
feedbacks__feedbackType='approver',
feedbacks__sender_profile=user,
)
unrated_count = unrated_funded.count() + unrated_contributed.count()
unrated_count = get_unrated_bounties_count(user)

# data = json.dumps(unrated)
return JsonResponse({
Expand Down
6 changes: 5 additions & 1 deletion app/marketing/mails.py
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,8 @@ def new_bounty_rejection(bounty, to_emails=None):


def new_bounty_acceptance(bounty, to_emails=None):
from dashboard.models import Profile
from dashboard.utils import get_unrated_bounties_count
if not bounty or not bounty.value_in_usdt_now:
return

Expand All @@ -792,10 +794,12 @@ def new_bounty_acceptance(bounty, to_emails=None):

for to_email in to_emails:
cur_language = translation.get_language()
profile = Profile.objects.filter(email=to_email).first()
unrated_count = get_unrated_bounties_count(profile)
try:
setup_lang(to_email)
from_email = settings.CONTACT_EMAIL
html, text = render_new_bounty_acceptance(to_email, bounty)
html, text = render_new_bounty_acceptance(to_email, bounty, unrated_count)

if not should_suppress_notification_email(to_email, 'bounty'):
send_mail(from_email, to_email, subject, text, html, categories=['transactional', func_name()])
Expand Down
3 changes: 2 additions & 1 deletion app/retail/emails.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,9 +696,10 @@ def render_new_work_submission(to_email, bounty):
return response_html, response_txt


def render_new_bounty_acceptance(to_email, bounty):
def render_new_bounty_acceptance(to_email, bounty, unrated_count):
params = {
'bounty': bounty,
'unrated_count': unrated_count,
'subscriber': get_or_save_email_subscriber(to_email, 'internal'),
}

Expand Down
3 changes: 3 additions & 0 deletions app/retail/templates/emails/new_bounty_acceptance.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

<h1>🌈 {% trans "Funds Paid!" %} 🌈</h1>

{% if unrated_count > 0 %}
Rate!!!!
{% endif %}

<p>
{% trans "Your claim has been accepted, and the fulfillment transaction is now on the Ethereum network!" %}
Expand Down
3 changes: 3 additions & 0 deletions app/retail/templates/emails/new_bounty_acceptance.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
🌈 Funds Paid! 🌈

Your funded issue has been accepted, and the fulfillment transaction is now on the Etherum network!
{% if unrated_count > 0 %}
Rate!!!!
{% endif %}

{% include 'emails/bounty.txt' with bounty=bounty %}

Expand Down

0 comments on commit 22d89a9

Please sign in to comment.