From b5f73b88f546b9ad50effd22e4346927c0bb1cb2 Mon Sep 17 00:00:00 2001 From: Aditya Anand M C Date: Sun, 4 Oct 2020 20:30:55 +0530 Subject: [PATCH] stable -> master (#7605) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * switched source for num contributors and amount contributed (#7599) * add new fields to profile (#7601) * fix invoice Co-authored-by: fronk <7516920+frankchen07@users.noreply.github.com> Co-authored-by: Octavio Amuchástegui --- app/dashboard/templates/bounty/invoice.html | 61 ++++++++++++------- .../templates/profiles/header_details.html | 23 ++++++- app/dashboard/views.py | 28 ++++++--- .../management/commands/analytics_clr.py | 3 +- .../commands/pending_contributions.py | 1 - app/marketing/mails.py | 13 ++-- 6 files changed, 88 insertions(+), 41 deletions(-) diff --git a/app/dashboard/templates/bounty/invoice.html b/app/dashboard/templates/bounty/invoice.html index a4c7d28d829..f0b3b07af70 100644 --- a/app/dashboard/templates/bounty/invoice.html +++ b/app/dashboard/templates/bounty/invoice.html @@ -181,29 +181,46 @@ - {% for fullfillment in accepted_fulfillments %} - - - {% trans "Direct Payment to " %}{{fullfillment.fulfiller_github_username}} {{fullfillment.fulfiller_address}} - - - - {{bounty.value_true}} {{bounty.token_name}} (${{bounty.get_value_in_usdt|floatformat:2}}) - - - {% endfor %} - {% for tip in tips %} - - - Direct Payment to {{tip.username}} {{tip.receive_address}} - - - - {{tip.amount_in_whole_units}} {{tip.tokenName}} (${{tip.value_in_usdt|floatformat:2}}) - - - {% endfor %} + {% if web3_type == 'bounties_network' %} + + {% for fullfillment in accepted_fulfillments %} + + + {% trans "Direct Payment to " %}{{fullfillment.fulfiller_github_username}} {{fullfillment.fulfiller_address}} + + + + {{bounty.value_true}} {{bounty.token_name}} (${{bounty.get_value_in_usdt|floatformat:2}}) + + + {% endfor %} + + {% for tip in tips %} + + + Direct Payment to {{tip.username}} {{tip.receive_address}} + + + + {{tip.amount_in_whole_units}} {{tip.tokenName}} (${{tip.value_in_usdt|floatformat:2}}) + + + {% endfor %} + + {% else %} + {% for fullfillment in accepted_fulfillments %} + + + {% trans "Direct Payment to " %}{{fullfillment.fulfiller_github_username}} {{fullfillment.fulfiller_address}} + + + + {{fullfillment.payout_amount}} {{fullfillment.token_name}} (${{fullfillment.payout_amount_usd|floatformat:2}}) + + + {% endfor %} + {% endif %} {% if fee_value_in_usdt %} diff --git a/app/dashboard/templates/profiles/header_details.html b/app/dashboard/templates/profiles/header_details.html index 71f310b1423..db1b7884e16 100644 --- a/app/dashboard/templates/profiles/header_details.html +++ b/app/dashboard/templates/profiles/header_details.html @@ -24,10 +24,27 @@

{% endif %}

-{% if profile.data.bio %} +{% if profile.bio %} +
+ {{ profile.bio }} +
+{% elif profile.data.bio %}
{{ profile.data.bio }}
+{% endif %} +{% if profile.interests %} + Interests: +
+ {% for interest in profile.interests %} + {% if forloop.counter < 5 %} + {{interest}} + {% endif %} + {% endfor %} + {% if profile.interests|length > 4 %} + +{{profile.interests|length|add:"-4"}} + {% endif %} +
{% endif %} {% if profile.custom_tagline %}
@@ -58,11 +75,11 @@

- - + diff --git a/app/dashboard/views.py b/app/dashboard/views.py index ad124c02a96..ee16a8f0b1d 100644 --- a/app/dashboard/views.py +++ b/app/dashboard/views.py @@ -1427,18 +1427,32 @@ def invoice(request): active='invoice_view', title=_('Invoice'), ) + params['accepted_fulfillments'] = bounty.fulfillments.filter(accepted=True) - params['tips'] = [ - tip for tip in bounty.tips.send_happy_path() if ((tip.username == request.user.username and tip.username) or (tip.from_username == request.user.username and tip.from_username) or request.user.is_staff) - ] - params['total'] = bounty._val_usd_db if params['accepted_fulfillments'] else 0 - for tip in params['tips']: - if tip.value_in_usdt: - params['total'] += Decimal(tip.value_in_usdt) + params['web3_type'] = bounty.web3_type + + if bounty.web3_type == 'bounties_network': + # Legacy Flow + params['total'] = bounty._val_usd_db if params['accepted_fulfillments'] else 0 + params['tips'] = [ + tip for tip in bounty.tips.send_happy_path() if ((tip.username == request.user.username and tip.username) or (tip.from_username == request.user.username and tip.from_username) or request.user.is_staff) + ] + + for tip in params['tips']: + if tip.value_in_usdt: + params['total'] += Decimal(tip.value_in_usdt) + else: + params['total'] = 0 + if params['accepted_fulfillments']: + for fulfillment in params['accepted_fulfillments']: + if fulfillment.payout_amount: + fulfillment.payout_amount_usd = convert_amount(fulfillment.payout_amount, fulfillment.token_name, 'USDT') + params['total'] += fulfillment.payout_amount_usd if bounty.fee_amount > 0: params['fee_value_in_usdt'] = bounty.fee_amount * Decimal(bounty.get_value_in_usdt) / bounty.value_true params['total'] = params['total'] + params['fee_value_in_usdt'] + return TemplateResponse(request, 'bounty/invoice.html', params) diff --git a/app/grants/management/commands/analytics_clr.py b/app/grants/management/commands/analytics_clr.py index d72f2a442ad..e8e8f583dd5 100644 --- a/app/grants/management/commands/analytics_clr.py +++ b/app/grants/management/commands/analytics_clr.py @@ -54,7 +54,8 @@ def analytics_clr(from_date=None, clr_round=None, network='mainnet'): v_threshold, uv_threshold ) - debug_output.append([grant.id, grant.title, num_contribs, contrib_amount, clr_amount]) + # debug_output.append([grant.id, grant.title, num_contribs, contrib_amount, clr_amount]) + debug_output.append([grant.id, grant.title, grant.positive_round_contributor_count, float(grant.amount_received_in_round), clr_amount]) return debug_output diff --git a/app/grants/management/commands/pending_contributions.py b/app/grants/management/commands/pending_contributions.py index a7ac3e86c07..82cabff5b47 100644 --- a/app/grants/management/commands/pending_contributions.py +++ b/app/grants/management/commands/pending_contributions.py @@ -31,4 +31,3 @@ def handle(self, *args, **options): validator_comment__contains="User may not be aware so send them email reminders") for contribution in contributions: pending_contribution(contribution) - diff --git a/app/marketing/mails.py b/app/marketing/mails.py index 22c463647e9..476ab48a67a 100644 --- a/app/marketing/mails.py +++ b/app/marketing/mails.py @@ -40,14 +40,13 @@ render_grant_txn_failed, render_grant_update, render_kudos_email, render_match_distribution, render_match_email, render_mention, render_new_bounty, render_new_bounty_acceptance, render_new_bounty_rejection, render_new_bounty_roundup, render_new_grant_email, render_new_supporter_email, render_new_work_submission, - render_no_applicant_reminder, render_nth_day_email_campaign, render_quarterly_stats, render_remember_your_cart, - render_request_amount_email, render_reserved_issue, render_share_bounty, - render_start_work_applicant_about_to_expire, render_start_work_applicant_expired, render_start_work_approved, - render_start_work_new_applicant, render_start_work_rejected, render_subscription_terminated_email, - render_successful_contribution_email, render_support_cancellation_email, render_tax_report, - render_thank_you_for_supporting_email, render_tip_email, render_tribe_hackathon_prizes, + render_no_applicant_reminder, render_nth_day_email_campaign, render_pending_contribution_email, + render_quarterly_stats, render_remember_your_cart, render_request_amount_email, render_reserved_issue, + render_share_bounty, render_start_work_applicant_about_to_expire, render_start_work_applicant_expired, + render_start_work_approved, render_start_work_new_applicant, render_start_work_rejected, + render_subscription_terminated_email, render_successful_contribution_email, render_support_cancellation_email, + render_tax_report, render_thank_you_for_supporting_email, render_tip_email, render_tribe_hackathon_prizes, render_unread_notification_email_weekly_roundup, render_wallpost, render_weekly_recap, - render_pending_contribution_email, ) from sendgrid.helpers.mail import Attachment, Content, Email, Mail, Personalization from sendgrid.helpers.stats import Category