From 8f8343b214db5e6761181e7075cd1e2dcff7c36c Mon Sep 17 00:00:00 2001 From: walidmujahid Date: Wed, 18 Mar 2020 19:12:27 -0400 Subject: [PATCH 1/9] add .gitattributes and normalise line endings for .sh files fixes https://github.com/gitcoinco/web/issues/6136 Add base template for request money Fill tip based on request fund Fix update of requests --- .gitattributes | 1 + app/app/urls.py | 2 +- app/assets/onepager/js/request.js | 83 ++++++++++++ .../migrations/0093_auto_20200324_1653.py | 37 ++++++ app/dashboard/models.py | 22 +++- app/dashboard/templates/onepager/send2.html | 4 +- app/dashboard/templates/request_payment.html | 119 ++++++++++++++++++ app/dashboard/tip_views.py | 65 ++++++++-- app/marketing/mails.py | 19 ++- app/retail/emails.py | 21 ++++ .../templates/emails/request_funds.html | 68 ++++++++++ app/retail/templates/emails/request_funds.txt | 13 ++ 12 files changed, 439 insertions(+), 15 deletions(-) create mode 100644 .gitattributes create mode 100644 app/assets/onepager/js/request.js create mode 100644 app/dashboard/migrations/0093_auto_20200324_1653.py create mode 100644 app/dashboard/templates/request_payment.html create mode 100644 app/retail/templates/emails/request_funds.html create mode 100644 app/retail/templates/emails/request_funds.txt diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000000..d6c0fd08894 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.sh text eol=lf diff --git a/app/app/urls.py b/app/app/urls.py index b765f660493..fba8dc1e33e 100644 --- a/app/app/urls.py +++ b/app/app/urls.py @@ -331,7 +331,7 @@ url(r'^tip/send/?', dashboard.tip_views.send_tip, name='send_tip'), url(r'^send/?', dashboard.tip_views.send_tip, name='tip'), url(r'^tip/?', dashboard.tip_views.send_tip_2, name='tip'), - + url(r'^requestmoney/?', dashboard.tip_views.request_money, name='request_money'), # Legal re_path(r'^terms/?', dashboard.views.terms, name='_terms'), re_path(r'^legal/terms/?', dashboard.views.terms, name='terms'), diff --git a/app/assets/onepager/js/request.js b/app/assets/onepager/js/request.js new file mode 100644 index 00000000000..e932db248d0 --- /dev/null +++ b/app/assets/onepager/js/request.js @@ -0,0 +1,83 @@ +$(document).ready(function() { + $('#request').on('click', function(e) { + e.preventDefault(); + if ($(this).hasClass('disabled')) + return; + loading_button($(this)); + // get form data + var username = $('.username-search').select2('data')[0] ? $('.username-search').select2('data')[0].text : ''; + var amount = parseFloat($('#amount').val()); + var comments = $('#comments').val(); + var tokenAddress = ( + ($('#token').val() == '0x0') ? + '0x0000000000000000000000000000000000000000' + : $('#token').val()); + + + // derived info + var isSendingETH = (tokenAddress == '0x0' || tokenAddress == '0x0000000000000000000000000000000000000000'); + var tokenDetails = tokenAddressToDetails(tokenAddress); + var tokenName = 'ETH'; + + if (!isSendingETH) { + tokenName = tokenDetails.name; + } + + if (!username) { + _alert('Please enter a recipient', 'error'); + return; + } + + var success_callback = function() { + unloading_button($('#request')); + }; + var failure_callback = function() { + unloading_button($('#request')); + }; + + return requestFunds(username, amount, comments, tokenAddress, tokenName, success_callback, failure_callback); + + }); + +}); + +function requestFunds(username, amount, comments, tokenAddress, tokenName, success_callback, failure_callback) { + if (username.indexOf('@') == -1) { + username = '@' + username; + } + + var tokenDetails = tokenAddressToDetails(tokenAddress); + + if (!isNumeric(amount) || amount == 0) { + _alert({ message: gettext('You must enter an number for the amount!') }, 'warning'); + failure_callback(); + return; + } + if (username == '') { + _alert({ message: gettext('You must enter a username.') }, 'warning'); + failure_callback(); + return; + } + + const csrfmiddlewaretoken = $('[name=csrfmiddlewaretoken]').val(); + const url = '/requestmoney'; + const formData = new FormData(); + + formData.append('username', username); + formData.append('amount', amount); + formData.append('tokenName', tokenName); + formData.append('comments', comments); + formData.append('tokenAddress', tokenAddress); + formData.append('csrfmiddlewaretoken', csrfmiddlewaretoken); + + fetch(url, { + method: 'POST', + body: formData + }).then(function(json) { + _alert('The funder has been notified', 'success'); + success_callback() + }).catch(function (error) { + _alert('Something goes wrong, try later.', 'error'); + failure_callback() + }); +} diff --git a/app/dashboard/migrations/0093_auto_20200324_1653.py b/app/dashboard/migrations/0093_auto_20200324_1653.py new file mode 100644 index 00000000000..abd136654a5 --- /dev/null +++ b/app/dashboard/migrations/0093_auto_20200324_1653.py @@ -0,0 +1,37 @@ +# Generated by Django 2.2.4 on 2020-03-24 16:53 + +from django.db import migrations, models +import django.db.models.deletion +import economy.models + + +class Migration(migrations.Migration): + + dependencies = [ + ('dashboard', '0092_auto_20200316_2228'), + ] + + operations = [ + migrations.AlterField( + model_name='activity', + name='activity_type', + field=models.CharField(blank=True, choices=[('wall_post', 'Wall Post'), ('status_update', 'Update status'), ('new_bounty', 'New Bounty'), ('start_work', 'Work Started'), ('stop_work', 'Work Stopped'), ('work_submitted', 'Work Submitted'), ('work_done', 'Work Done'), ('worker_approved', 'Worker Approved'), ('worker_rejected', 'Worker Rejected'), ('worker_applied', 'Worker Applied'), ('increased_bounty', 'Increased Funding'), ('killed_bounty', 'Canceled Bounty'), ('new_tip', 'New Tip'), ('receive_tip', 'Tip Received'), ('bounty_abandonment_escalation_to_mods', 'Escalated checkin from @gitcoinbot about bounty status'), ('bounty_abandonment_warning', 'Checkin from @gitcoinbot about bounty status'), ('bounty_removed_slashed_by_staff', 'Dinged and Removed from Bounty by Staff'), ('bounty_removed_by_staff', 'Removed from Bounty by Staff'), ('bounty_removed_by_funder', 'Removed from Bounty by Funder'), ('new_crowdfund', 'New Crowdfund Contribution'), ('new_grant', 'New Grant'), ('update_grant', 'Updated Grant'), ('killed_grant', 'Cancelled Grant'), ('new_grant_contribution', 'Contributed to Grant'), ('new_grant_subscription', 'Subscribed to Grant'), ('killed_grant_contribution', 'Cancelled Grant Contribution'), ('new_milestone', 'New Milestone'), ('update_milestone', 'Updated Milestone'), ('new_kudos', 'New Kudos'), ('created_kudos', 'Created Kudos'), ('receive_kudos', 'Receive Kudos'), ('joined', 'Joined Gitcoin'), ('played_quest', 'Played Quest'), ('beat_quest', 'Beat Quest'), ('created_quest', 'Created Quest'), ('updated_avatar', 'Updated Avatar'), ('mini_clr_payout', 'Mini CLR Payout'), ('leaderboard_rank', 'Leaderboard Rank'), ('consolidated_leaderboard_rank', 'Consolidated Leaderboard Rank'), ('consolidated_mini_clr_payout', 'Consolidated CLR Payout'), ('hackathon_registration', 'Hackathon Registration')], db_index=True, max_length=50), + ), + migrations.CreateModel( + name='FundRequest', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('modified_on', models.DateTimeField(default=economy.models.get_time)), + ('token_name', models.CharField(default='ETH', max_length=255)), + ('amount', models.DecimalField(decimal_places=4, default=1, max_digits=50)), + ('comments', models.TextField(blank=True, default='')), + ('created_on', models.DateTimeField(auto_now_add=True)), + ('profile', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='requests_receiver', to='dashboard.Profile')), + ('requester', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='requests_sender', to='dashboard.Profile')), + ('tip', models.OneToOneField(null=True, on_delete=django.db.models.deletion.CASCADE, to='dashboard.Tip')), + ], + options={ + 'abstract': False, + }, + ), + ] diff --git a/app/dashboard/models.py b/app/dashboard/models.py index 96588e6de54..f1e5b433031 100644 --- a/app/dashboard/models.py +++ b/app/dashboard/models.py @@ -62,7 +62,7 @@ _AUTH, HEADERS, TOKEN_URL, build_auth_dict, get_gh_issue_details, get_issue_comments, issue_number, org_name, repo_name, ) -from marketing.mails import featured_funded_bounty, start_work_approved +from marketing.mails import featured_funded_bounty, start_work_approved, fund_request_email from marketing.models import LeaderboardRank from rest_framework import serializers from web3 import Web3 @@ -1771,6 +1771,26 @@ def __str__(self): return f"tip: {self.tip.pk} profile: {self.profile.handle}" +class FundRequest(SuperModel): + profile = models.ForeignKey( + 'dashboard.Profile', related_name='requests_receiver', on_delete=models.CASCADE + ) + requester = models.ForeignKey( + 'dashboard.Profile', related_name='requests_sender', on_delete=models.CASCADE + ) + token_name = models.CharField(max_length=255, default='ETH') + amount = models.DecimalField(default=1, decimal_places=4, max_digits=50) + comments = models.TextField(default='', blank=True) + tip = models.OneToOneField(Tip, on_delete=models.CASCADE, null=True) + created_on = models.DateTimeField(auto_now_add=True) + + +@receiver(post_save, sender=FundRequest, dispatch_uid="post_save_fund_request") +def psave_fund_request(sender, instance, created, **kwargs): + if created: + fund_request_email(instance, [instance.profile.email]) + + @receiver(pre_save, sender=Tip, dispatch_uid="psave_tip") def psave_tip(sender, instance, **kwargs): # when a new tip is saved, make sure it doesnt have whitespace in it diff --git a/app/dashboard/templates/onepager/send2.html b/app/dashboard/templates/onepager/send2.html index 6abc8722c5c..0e145ed70ab 100644 --- a/app/dashboard/templates/onepager/send2.html +++ b/app/dashboard/templates/onepager/send2.html @@ -80,10 +80,10 @@

{% trans "Send Tip." %}


{% trans "Amount of" %} - - +
 
{% trans "Where is my Eth going? " %}

diff --git a/app/dashboard/templates/request_payment.html b/app/dashboard/templates/request_payment.html new file mode 100644 index 00000000000..55be739bba5 --- /dev/null +++ b/app/dashboard/templates/request_payment.html @@ -0,0 +1,119 @@ +{% extends 'onepager/base.html' %} +{% comment %} + Copyright (C) 2020 Gitcoin Core + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +{% endcomment %} +{% load i18n static %} +{% block 'scripts' %} + {% include 'shared/current_profile.html' %} + + + + + + + + + + + + + +{% endblock %} + +{% block 'main' %} + + +
+ +
+
+
+ + + Helmet + + +
+
+

{% trans "Request money." %}

+ {% csrf_token %} +
+
+
+
+ +
+ {% trans "Amount of" %} + + +
+
 
+
+ {% trans "Comments" %}: + +
+
+ + +
+ {% trans "Send" %} ⚡️ +
+
+
+ + {% if not user_json and username %} + + {% endif %} +{% endblock %} diff --git a/app/dashboard/tip_views.py b/app/dashboard/tip_views.py index fe680e49514..7e56577f8ab 100644 --- a/app/dashboard/tip_views.py +++ b/app/dashboard/tip_views.py @@ -24,6 +24,7 @@ from django.conf import settings from django.contrib import messages +from django.contrib.auth.decorators import login_required from django.http import JsonResponse from django.shortcuts import redirect from django.template.response import TemplateResponse @@ -39,7 +40,7 @@ from retail.helpers import get_ip from web3 import Web3 -from .models import Activity, Profile, Tip, TipPayout +from .models import Activity, Profile, Tip, TipPayout, FundRequest from .notifications import maybe_market_tip_to_email, maybe_market_tip_to_github, maybe_market_tip_to_slack logging.basicConfig(level=logging.DEBUG) @@ -60,6 +61,38 @@ def send_tip(request): return TemplateResponse(request, 'onepager/send1.html', params) +def request_money(request): + """""" + if request.method == 'POST': + username = request.POST.get('username', '').strip('@') + token_name = request.POST.get('tokenName') + amount = request.POST.get('amount') + comments = request.POST.get('comments') + token_address = request.POST.get('tokenAddress') + profiles = Profile.objects.filter(handle=username.lower()) + + if profiles.exists(): + profile = profiles.first() + kwargs = { + 'profile': profile, + 'token_name': token_name, + 'amount': amount, + 'comments': comments, + 'requester': request.user.profile, + } + fund_request = FundRequest.objects.create(**kwargs) + messages.success(request, f'Stay tuned, {profile.handle} has been notified by email.') + else: + messages.error(request, f'The user {username} doesn\'t exists.') + + params = { + 'class': 'send2', + 'title': 'Request Money | Gitcoin', + 'card_desc': 'Request money from any user at the click of a button.', + } + + return TemplateResponse(request, 'request_payment.html', params) + def record_tip_activity(tip, github_handle, event_name, override_created=None, other_handle=None): kwargs = { 'created_on': timezone.now() if not override_created else override_created, @@ -413,8 +446,10 @@ def send_tip_2(request): TemplateResponse: Render the submission form. """ - + profile = None + fund_request = None username = request.GET.get('username', None) + pk_fund_request = request.GET.get('request', None) is_user_authenticated = request.user.is_authenticated from_username = request.user.username if is_user_authenticated else '' primary_from_email = request.user.email if is_user_authenticated else '' @@ -422,17 +457,26 @@ def send_tip_2(request): user = {} if username: profiles = Profile.objects.filter(handle=username.lower()) - if profiles.exists(): profile = profiles.first() - user['id'] = profile.id - user['text'] = profile.handle - user['avatar_url'] = profile.avatar_url - if profile.avatar_baseavatar_related.exists(): - user['avatar_id'] = profile.avatar_baseavatar_related.filter(active=True).first().pk - user['avatar_url'] = profile.avatar_baseavatar_related.filter(active=True).first().avatar_url - user['preferred_payout_address'] = profile.preferred_payout_address + if pk_fund_request: + requests = FundRequest.objects.filter(pk=int(pk_fund_request)) + if requests.exists(): + fund_request = requests.first() + profile = fund_request.requester + else: + messages.error(f'Failed to retrieve the fund request {fund_request}') + + if profile: + user['id'] = profile.id + user['text'] = profile.handle + user['avatar_url'] = profile.avatar_url + + if profile.avatar_baseavatar_related.exists(): + user['avatar_id'] = profile.avatar_baseavatar_related.filter(active=True).first().pk + user['avatar_url'] = profile.avatar_baseavatar_related.filter(active=True).first().avatar_url + user['preferred_payout_address'] = profile.preferred_payout_address params = { 'issueURL': request.GET.get('source'), @@ -442,6 +486,7 @@ def send_tip_2(request): 'from_handle': from_username, 'title': 'Send Tip | Gitcoin', 'card_desc': 'Send a tip to any github user at the click of a button.', + 'fund_request': fund_request } if user: diff --git a/app/marketing/mails.py b/app/marketing/mails.py index 42654813e9c..3da470e5d36 100644 --- a/app/marketing/mails.py +++ b/app/marketing/mails.py @@ -42,7 +42,7 @@ render_start_work_new_applicant, render_start_work_rejected, render_subscription_terminated_email, render_successful_contribution_email, render_support_cancellation_email, render_thank_you_for_supporting_email, render_tip_email, render_unread_notification_email_weekly_roundup, render_wallpost, render_weekly_recap, -) + render_request_amount_email) from sendgrid.helpers.mail import Content, Email, Mail, Personalization from sendgrid.helpers.stats import Category from townsquare.utils import is_email_townsquare_enabled, is_there_an_action_available @@ -1500,3 +1500,20 @@ def bounty_request_feedback(profile): ) finally: translation.activate(cur_language) + + +def fund_request_email(request, to_emails, is_new=False): + subject = gettext("🕐 New Request funds from {} ({} {})").format(request.requester.handle, + request.amount, + request.token_name) + for to_email in to_emails: + cur_language = translation.get_language() + try: + setup_lang(to_email) + from_email = settings.CONTACT_EMAIL + html, text = render_request_amount_email(to_email, request, is_new) + + if not should_suppress_notification_email(to_email, 'tip'): + send_mail(from_email, to_email, subject, text, html, categories=['transactional', func_name()]) + finally: + translation.activate(cur_language) diff --git a/app/retail/emails.py b/app/retail/emails.py index 36ad623d669..067714aa1aa 100644 --- a/app/retail/emails.py +++ b/app/retail/emails.py @@ -27,6 +27,7 @@ from django.shortcuts import redirect from django.template.loader import render_to_string from django.template.response import TemplateResponse +from django.urls import reverse from django.utils import timezone from django.utils.translation import gettext as _ @@ -260,6 +261,26 @@ def render_tip_email(to_email, tip, is_new): return response_html, response_txt +def render_request_amount_email(to_email, request, is_new): + + link = f'{reverse("tip")}?request={request.id}' + params = { + 'link': link, + 'amount': request.amount, + 'tokenName': request.token_name, + 'comments': request.comments, + 'subscriber': get_or_save_email_subscriber(to_email, 'internal'), + 'email_type': 'request', + 'request': request, + 'already_received': request.tip + } + + response_html = premailer_transform(render_to_string("emails/request_funds.html", params)) + response_txt = render_to_string("emails/new_tip.txt", params) + + return response_html, response_txt + + def render_kudos_email(to_email, kudos_transfer, is_new, html_template, text_template=None): """Summary diff --git a/app/retail/templates/emails/request_funds.html b/app/retail/templates/emails/request_funds.html new file mode 100644 index 00000000000..6549f0845b3 --- /dev/null +++ b/app/retail/templates/emails/request_funds.html @@ -0,0 +1,68 @@ +{% extends 'emails/template.html' %} +{% comment %} + Copyright (C) 2019 Gitcoin Core + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +{% endcomment %} +{% load i18n humanize %} + +{% block content %} + + + +
+

🕑️ {% trans "Request funds" %} 🕑️

+

+ {{request.requester.handle}} {% blocktrans %} request funds worth {{amount}} {{tokenName}}{% endblocktrans %} + {{tip.created_on | naturaltime}}. +

+
+ +
+
+
+

+ {% trans "They had the following comments:" %} +

+              {{comments}}
+            
+

+
+
+ {% if not already_redeemed %} +
+ {% trans "Fund this requests" %} +
+ {% endif %} +
+ +{% endblock %} diff --git a/app/retail/templates/emails/request_funds.txt b/app/retail/templates/emails/request_funds.txt new file mode 100644 index 00000000000..31d4df4df1e --- /dev/null +++ b/app/retail/templates/emails/request_funds.txt @@ -0,0 +1,13 @@ +{% load humanize i18n %} +🕑️ {% trans "Request funds" %} 🕑️ + +{{request.requester.handle}} {% blocktrans %} request funds worth {{amount}} {{tokenName}}{% endblocktrans %} + +{% if comments %} +The request had the following comments: +{{comments}} +{% endif %} + +{% if not already_redeemed %} +Click here to redeem it: {{link}} +{% endif %} \ No newline at end of file From fe0d4834785d5c9dbcebd488b3b839a632f3cbfd Mon Sep 17 00:00:00 2001 From: Miguel Angel G Date: Thu, 9 Apr 2020 01:41:11 -0500 Subject: [PATCH 2/9] Add network and address attributes to request funds --- app/assets/onepager/js/request.js | 25 ++++++-- app/dashboard/admin.py | 10 +++- .../migrations/0093_auto_20200324_1653.py | 37 ------------ app/dashboard/models.py | 2 + app/dashboard/templates/onepager/send2.html | 15 +++-- app/dashboard/templates/request_payment.html | 60 ++++++++++++------- app/dashboard/tip_views.py | 7 +++ app/marketing/mails.py | 3 +- app/retail/emails.py | 3 +- .../templates/emails/request_funds.html | 3 + app/retail/templates/emails/request_funds.txt | 3 + 11 files changed, 98 insertions(+), 70 deletions(-) delete mode 100644 app/dashboard/migrations/0093_auto_20200324_1653.py diff --git a/app/assets/onepager/js/request.js b/app/assets/onepager/js/request.js index e932db248d0..bd892b0b140 100644 --- a/app/assets/onepager/js/request.js +++ b/app/assets/onepager/js/request.js @@ -1,12 +1,26 @@ $(document).ready(function() { + $('#network').change(function(e) { + if ($(this).val() !== 'ETH') { + $('#token').prop('disabled', 'disabled'); + $('#token').val(''); + } else { + $('#token').prop('disabled', false); + } + }); $('#request').on('click', function(e) { e.preventDefault(); if ($(this).hasClass('disabled')) return; + + if (!$('#tos').is(":checked")) { + _alert('Please accept the terms and conditions before submit.', 'warning'); + } loading_button($(this)); // get form data var username = $('.username-search').select2('data')[0] ? $('.username-search').select2('data')[0].text : ''; var amount = parseFloat($('#amount').val()); + var network = $('#network').val(); + var address = $('#address').val(); var comments = $('#comments').val(); var tokenAddress = ( ($('#token').val() == '0x0') ? @@ -19,7 +33,7 @@ $(document).ready(function() { var tokenDetails = tokenAddressToDetails(tokenAddress); var tokenName = 'ETH'; - if (!isSendingETH) { + if (network == 'ETH' == !isSendingETH) { tokenName = tokenDetails.name; } @@ -35,13 +49,13 @@ $(document).ready(function() { unloading_button($('#request')); }; - return requestFunds(username, amount, comments, tokenAddress, tokenName, success_callback, failure_callback); + return requestFunds(username, amount, comments, tokenAddress, tokenName, network, address, success_callback, failure_callback); }); }); -function requestFunds(username, amount, comments, tokenAddress, tokenName, success_callback, failure_callback) { +function requestFunds(username, amount, comments, tokenAddress, tokenName, network, address, success_callback, failure_callback) { if (username.indexOf('@') == -1) { username = '@' + username; } @@ -49,7 +63,7 @@ function requestFunds(username, amount, comments, tokenAddress, tokenName, succe var tokenDetails = tokenAddressToDetails(tokenAddress); if (!isNumeric(amount) || amount == 0) { - _alert({ message: gettext('You must enter an number for the amount!') }, 'warning'); + _alert({ message: gettext('You must enter the amount!') }, 'warning'); failure_callback(); return; } @@ -69,7 +83,8 @@ function requestFunds(username, amount, comments, tokenAddress, tokenName, succe formData.append('comments', comments); formData.append('tokenAddress', tokenAddress); formData.append('csrfmiddlewaretoken', csrfmiddlewaretoken); - + formData.append('network', network); + formData.append('address', address); fetch(url, { method: 'POST', body: formData diff --git a/app/dashboard/admin.py b/app/dashboard/admin.py index e8a548c0111..05e8ce81d48 100644 --- a/app/dashboard/admin.py +++ b/app/dashboard/admin.py @@ -29,7 +29,7 @@ HackathonRegistration, HackathonSponsor, Interest, LabsResearch, PortfolioItem, Profile, ProfileView, RefundFeeRequest, SearchHistory, Sponsor, Tip, TipPayout, TokenApproval, Tool, ToolVote, TribeMember, UserAction, UserVerificationModel, -) + FundRequest) class BountyEventAdmin(admin.ModelAdmin): @@ -453,6 +453,13 @@ class TribeMemberAdmin(admin.ModelAdmin): list_display = ['pk', 'profile', 'org', 'leader', 'status'] +class FundRequestAdmin(admin.ModelAdmin): + list_display = ['profile', 'requester', 'token_name', 'amount', + 'comments', 'tip', 'created_on'] + ordering = ['-id'] + raw_id_fields = ['profile', 'requester', 'tip'] + + admin.site.register(BountyEvent, BountyEventAdmin) admin.site.register(SearchHistory, SearchHistoryAdmin) admin.site.register(Activity, ActivityAdmin) @@ -486,3 +493,4 @@ class TribeMemberAdmin(admin.ModelAdmin): admin.site.register(RefundFeeRequest, RefundFeeRequestAdmin) admin.site.register(Coupon, CouponAdmin) admin.site.register(TribeMember, TribeMemberAdmin) +admin.site.register(FundRequest, FundRequestAdmin) \ No newline at end of file diff --git a/app/dashboard/migrations/0093_auto_20200324_1653.py b/app/dashboard/migrations/0093_auto_20200324_1653.py deleted file mode 100644 index abd136654a5..00000000000 --- a/app/dashboard/migrations/0093_auto_20200324_1653.py +++ /dev/null @@ -1,37 +0,0 @@ -# Generated by Django 2.2.4 on 2020-03-24 16:53 - -from django.db import migrations, models -import django.db.models.deletion -import economy.models - - -class Migration(migrations.Migration): - - dependencies = [ - ('dashboard', '0092_auto_20200316_2228'), - ] - - operations = [ - migrations.AlterField( - model_name='activity', - name='activity_type', - field=models.CharField(blank=True, choices=[('wall_post', 'Wall Post'), ('status_update', 'Update status'), ('new_bounty', 'New Bounty'), ('start_work', 'Work Started'), ('stop_work', 'Work Stopped'), ('work_submitted', 'Work Submitted'), ('work_done', 'Work Done'), ('worker_approved', 'Worker Approved'), ('worker_rejected', 'Worker Rejected'), ('worker_applied', 'Worker Applied'), ('increased_bounty', 'Increased Funding'), ('killed_bounty', 'Canceled Bounty'), ('new_tip', 'New Tip'), ('receive_tip', 'Tip Received'), ('bounty_abandonment_escalation_to_mods', 'Escalated checkin from @gitcoinbot about bounty status'), ('bounty_abandonment_warning', 'Checkin from @gitcoinbot about bounty status'), ('bounty_removed_slashed_by_staff', 'Dinged and Removed from Bounty by Staff'), ('bounty_removed_by_staff', 'Removed from Bounty by Staff'), ('bounty_removed_by_funder', 'Removed from Bounty by Funder'), ('new_crowdfund', 'New Crowdfund Contribution'), ('new_grant', 'New Grant'), ('update_grant', 'Updated Grant'), ('killed_grant', 'Cancelled Grant'), ('new_grant_contribution', 'Contributed to Grant'), ('new_grant_subscription', 'Subscribed to Grant'), ('killed_grant_contribution', 'Cancelled Grant Contribution'), ('new_milestone', 'New Milestone'), ('update_milestone', 'Updated Milestone'), ('new_kudos', 'New Kudos'), ('created_kudos', 'Created Kudos'), ('receive_kudos', 'Receive Kudos'), ('joined', 'Joined Gitcoin'), ('played_quest', 'Played Quest'), ('beat_quest', 'Beat Quest'), ('created_quest', 'Created Quest'), ('updated_avatar', 'Updated Avatar'), ('mini_clr_payout', 'Mini CLR Payout'), ('leaderboard_rank', 'Leaderboard Rank'), ('consolidated_leaderboard_rank', 'Consolidated Leaderboard Rank'), ('consolidated_mini_clr_payout', 'Consolidated CLR Payout'), ('hackathon_registration', 'Hackathon Registration')], db_index=True, max_length=50), - ), - migrations.CreateModel( - name='FundRequest', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('modified_on', models.DateTimeField(default=economy.models.get_time)), - ('token_name', models.CharField(default='ETH', max_length=255)), - ('amount', models.DecimalField(decimal_places=4, default=1, max_digits=50)), - ('comments', models.TextField(blank=True, default='')), - ('created_on', models.DateTimeField(auto_now_add=True)), - ('profile', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='requests_receiver', to='dashboard.Profile')), - ('requester', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='requests_sender', to='dashboard.Profile')), - ('tip', models.OneToOneField(null=True, on_delete=django.db.models.deletion.CASCADE, to='dashboard.Tip')), - ], - options={ - 'abstract': False, - }, - ), - ] diff --git a/app/dashboard/models.py b/app/dashboard/models.py index f1e5b433031..8d9d675a07b 100644 --- a/app/dashboard/models.py +++ b/app/dashboard/models.py @@ -1782,6 +1782,8 @@ class FundRequest(SuperModel): amount = models.DecimalField(default=1, decimal_places=4, max_digits=50) comments = models.TextField(default='', blank=True) tip = models.OneToOneField(Tip, on_delete=models.CASCADE, null=True) + network = models.CharField(max_length=255, default='') + address = models.CharField(max_length=255, default='') created_on = models.DateTimeField(auto_now_add=True) diff --git a/app/dashboard/templates/onepager/send2.html b/app/dashboard/templates/onepager/send2.html index 0e145ed70ab..9b168724c7d 100644 --- a/app/dashboard/templates/onepager/send2.html +++ b/app/dashboard/templates/onepager/send2.html @@ -80,9 +80,16 @@

{% trans "Send Tip." %}


{% trans "Amount of" %} - + {% if fund_request.network == 'ETH' %} + + {% else %} + + + {% endif %}
 
@@ -91,7 +98,7 @@

{% trans "Send Tip." %}


diff --git a/app/dashboard/templates/request_payment.html b/app/dashboard/templates/request_payment.html index 55be739bba5..eda87706883 100644 --- a/app/dashboard/templates/request_payment.html +++ b/app/dashboard/templates/request_payment.html @@ -64,14 +64,19 @@ .terms { margin-top: 0.75rem; } + + .amount > span { + margin: 0; + width: 100% !important; + }
-
+
- + Helmet @@ -80,32 +85,45 @@

{% trans "Request money." %}

{% csrf_token %}
-
-
-
+
+
- {% trans "Amount of" %} - - -
-
 
-
- {% trans "Comments" %}: - -
-
- - +
+ + +
+
+ + + +
+
+
+ +
+
+ {% trans "Comments" %}: + +
+
+ + +
+ {% trans "Send" %} ⚡️
- {% trans "Send" %} ⚡️ -
diff --git a/app/dashboard/tip_views.py b/app/dashboard/tip_views.py index 7e56577f8ab..3e4d829712a 100644 --- a/app/dashboard/tip_views.py +++ b/app/dashboard/tip_views.py @@ -68,14 +68,21 @@ def request_money(request): token_name = request.POST.get('tokenName') amount = request.POST.get('amount') comments = request.POST.get('comments') + network = request.POST.get('network') + address = request.POST.get('address') token_address = request.POST.get('tokenAddress') profiles = Profile.objects.filter(handle=username.lower()) + if network != 'ETH': + token_name = '' + if profiles.exists(): profile = profiles.first() kwargs = { 'profile': profile, 'token_name': token_name, + 'network': network, + 'address': address, 'amount': amount, 'comments': comments, 'requester': request.user.profile, diff --git a/app/marketing/mails.py b/app/marketing/mails.py index 3da470e5d36..abd13c9df59 100644 --- a/app/marketing/mails.py +++ b/app/marketing/mails.py @@ -1503,9 +1503,10 @@ def bounty_request_feedback(profile): def fund_request_email(request, to_emails, is_new=False): + token_name = request.token_name if request.network == 'ETH' else request.network subject = gettext("🕐 New Request funds from {} ({} {})").format(request.requester.handle, request.amount, - request.token_name) + token_name) for to_email in to_emails: cur_language = translation.get_language() try: diff --git a/app/retail/emails.py b/app/retail/emails.py index 067714aa1aa..3cd19de944c 100644 --- a/app/retail/emails.py +++ b/app/retail/emails.py @@ -267,7 +267,8 @@ def render_request_amount_email(to_email, request, is_new): params = { 'link': link, 'amount': request.amount, - 'tokenName': request.token_name, + 'tokenName': request.token_name if request.network == 'ETH' else request.network, + 'address': request.address, 'comments': request.comments, 'subscriber': get_or_save_email_subscriber(to_email, 'internal'), 'email_type': 'request', diff --git a/app/retail/templates/emails/request_funds.html b/app/retail/templates/emails/request_funds.html index 6549f0845b3..6c5318dffd5 100644 --- a/app/retail/templates/emails/request_funds.html +++ b/app/retail/templates/emails/request_funds.html @@ -43,6 +43,9 @@

🕑️ {% trans "Request funds" %} 🕑️

{{request.requester.handle}} {% blocktrans %} request funds worth {{amount}} {{tokenName}}{% endblocktrans %} + {% if address %} + Recipient Address: {{ address }} + {% endif %} {{tip.created_on | naturaltime}}.

diff --git a/app/retail/templates/emails/request_funds.txt b/app/retail/templates/emails/request_funds.txt index 31d4df4df1e..c2c648e3a5a 100644 --- a/app/retail/templates/emails/request_funds.txt +++ b/app/retail/templates/emails/request_funds.txt @@ -2,6 +2,9 @@ 🕑️ {% trans "Request funds" %} 🕑️ {{request.requester.handle}} {% blocktrans %} request funds worth {{amount}} {{tokenName}}{% endblocktrans %} +{% if address %} +Recipient Address: {{ address }} +{% endif %} {% if comments %} The request had the following comments: From 2577249d4bdae1efc3f051baf573169acffed5c2 Mon Sep 17 00:00:00 2001 From: Miguel Angel G Date: Thu, 9 Apr 2020 01:45:22 -0500 Subject: [PATCH 3/9] remove extra address from tip view --- app/dashboard/admin.py | 5 +++-- app/dashboard/templates/onepager/send2.html | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/dashboard/admin.py b/app/dashboard/admin.py index 05e8ce81d48..7456ff58c35 100644 --- a/app/dashboard/admin.py +++ b/app/dashboard/admin.py @@ -454,8 +454,9 @@ class TribeMemberAdmin(admin.ModelAdmin): class FundRequestAdmin(admin.ModelAdmin): - list_display = ['profile', 'requester', 'token_name', 'amount', - 'comments', 'tip', 'created_on'] + list_display = ['id', 'profile', 'requester', 'network', 'token_name', 'amount', + 'comments', 'address', 'tip', 'created_on'] + readonly_fields = ['id'] ordering = ['-id'] raw_id_fields = ['profile', 'requester', 'tip'] diff --git a/app/dashboard/templates/onepager/send2.html b/app/dashboard/templates/onepager/send2.html index 9b168724c7d..df99bce482d 100644 --- a/app/dashboard/templates/onepager/send2.html +++ b/app/dashboard/templates/onepager/send2.html @@ -88,7 +88,6 @@

{% trans "Send Tip." %}

- {% endif %} From 663b40f8d774faeceb5828cbe441418274dc8117 Mon Sep 17 00:00:00 2001 From: Miguel Angel G Date: Thu, 9 Apr 2020 01:54:25 -0500 Subject: [PATCH 4/9] Fix conflict migration --- .../migrations/0098_auto_20200409_0651.py | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 app/dashboard/migrations/0098_auto_20200409_0651.py diff --git a/app/dashboard/migrations/0098_auto_20200409_0651.py b/app/dashboard/migrations/0098_auto_20200409_0651.py new file mode 100644 index 00000000000..373ace003a7 --- /dev/null +++ b/app/dashboard/migrations/0098_auto_20200409_0651.py @@ -0,0 +1,34 @@ +# Generated by Django 2.2.4 on 2020-04-09 06:51 + +from django.db import migrations, models +import django.db.models.deletion +import economy.models + + +class Migration(migrations.Migration): + + dependencies = [ + ('dashboard', '0097_merge_20200408_1219'), + ] + + operations = [ + migrations.CreateModel( + name='FundRequest', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('modified_on', models.DateTimeField(default=economy.models.get_time)), + ('token_name', models.CharField(default='ETH', max_length=255)), + ('amount', models.DecimalField(decimal_places=4, default=1, max_digits=50)), + ('comments', models.TextField(blank=True, default='')), + ('network', models.CharField(default='', max_length=255)), + ('address', models.CharField(default='', max_length=255)), + ('created_on', models.DateTimeField(auto_now_add=True)), + ('profile', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='requests_receiver', to='dashboard.Profile')), + ('requester', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='requests_sender', to='dashboard.Profile')), + ('tip', models.OneToOneField(null=True, on_delete=django.db.models.deletion.CASCADE, to='dashboard.Tip')), + ], + options={ + 'abstract': False, + }, + ), + ] From 388b3da0770b56efa7f30a1bf767727dc62c3902 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Angel=20Gordi=C3=A1n?= Date: Thu, 16 Apr 2020 21:26:09 -0500 Subject: [PATCH 5/9] Update tip_views.py --- app/dashboard/tip_views.py | 1 - 1 file changed, 1 deletion(-) diff --git a/app/dashboard/tip_views.py b/app/dashboard/tip_views.py index 3e4d829712a..07375c6ed3f 100644 --- a/app/dashboard/tip_views.py +++ b/app/dashboard/tip_views.py @@ -70,7 +70,6 @@ def request_money(request): comments = request.POST.get('comments') network = request.POST.get('network') address = request.POST.get('address') - token_address = request.POST.get('tokenAddress') profiles = Profile.objects.filter(handle=username.lower()) if network != 'ETH': From 7ecd3b50a5065667abd291aed90f5e0a03263740 Mon Sep 17 00:00:00 2001 From: Miguel Angel G Date: Tue, 28 Apr 2020 05:38:30 -0500 Subject: [PATCH 6/9] Update display error on token name --- app/assets/onepager/js/send.js | 3 ++- app/dashboard/admin.py | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/assets/onepager/js/send.js b/app/assets/onepager/js/send.js index 25550d349cf..9e0f1f514e3 100644 --- a/app/assets/onepager/js/send.js +++ b/app/assets/onepager/js/send.js @@ -144,7 +144,8 @@ $(document).ready(function() { waitforWeb3(function() { tokens(document.web3network).forEach(function(ele) { if (ele && ele.addr) { - var html = ''; + const is_token_selected = $('#token').data('token') === ele.name ? ' selected' : ' '; + const html = ''; $('#token').append(html); } diff --git a/app/dashboard/admin.py b/app/dashboard/admin.py index 52ec553d976..522d71c3a07 100644 --- a/app/dashboard/admin.py +++ b/app/dashboard/admin.py @@ -27,8 +27,8 @@ Activity, BlockedURLFilter, BlockedUser, Bounty, BountyEvent, BountyFulfillment, BountyInvites, BountySyncRequest, CoinRedemption, CoinRedemptionRequest, Coupon, Earning, FeedbackEntry, FundRequest, HackathonEvent, HackathonProject, HackathonRegistration, HackathonSponsor, Interest, LabsResearch, PortfolioItem, Profile, ProfileView, - RefundFeeRequest, SearchHistory, Sponsor, Tip, TipPayout, TokenApproval, Tool, ToolVote, TribeMember, UserAction, - UserVerificationModel, + SearchHistory, Sponsor, Tip, TipPayout, TokenApproval, Tool, ToolVote, TribeMember, UserAction, + UserVerificationModel, ) @@ -451,4 +451,4 @@ class FundRequestAdmin(admin.ModelAdmin): admin.site.register(UserVerificationModel, VerificationAdmin) admin.site.register(Coupon, CouponAdmin) admin.site.register(TribeMember, TribeMemberAdmin) -admin.site.register(FundRequest, FundRequestAdmin) \ No newline at end of file +admin.site.register(FundRequest, FundRequestAdmin) From d70ee2e110d9e388842b4af7b6d2fdd3d8e26b54 Mon Sep 17 00:00:00 2001 From: Miguel Angel G Date: Tue, 28 Apr 2020 06:01:46 -0500 Subject: [PATCH 7/9] Fix migration error --- app/assets/onepager/js/request.js | 8 ++++---- app/dashboard/admin.py | 6 +++--- ...98_auto_20200409_0651.py => 0103_fundrequest.py} | 4 ++-- app/dashboard/models.py | 2 +- app/dashboard/tip_views.py | 2 +- app/marketing/mails.py | 13 +++++++------ 6 files changed, 18 insertions(+), 17 deletions(-) rename app/dashboard/migrations/{0098_auto_20200409_0651.py => 0103_fundrequest.py} (93%) diff --git a/app/assets/onepager/js/request.js b/app/assets/onepager/js/request.js index bd892b0b140..a3be99110b0 100644 --- a/app/assets/onepager/js/request.js +++ b/app/assets/onepager/js/request.js @@ -12,7 +12,7 @@ $(document).ready(function() { if ($(this).hasClass('disabled')) return; - if (!$('#tos').is(":checked")) { + if (!$('#tos').is(':checked')) { _alert('Please accept the terms and conditions before submit.', 'warning'); } loading_button($(this)); @@ -90,9 +90,9 @@ function requestFunds(username, amount, comments, tokenAddress, tokenName, netwo body: formData }).then(function(json) { _alert('The funder has been notified', 'success'); - success_callback() - }).catch(function (error) { + success_callback(); + }).catch(function(error) { _alert('Something goes wrong, try later.', 'error'); - failure_callback() + failure_callback(); }); } diff --git a/app/dashboard/admin.py b/app/dashboard/admin.py index 522d71c3a07..88014cb6856 100644 --- a/app/dashboard/admin.py +++ b/app/dashboard/admin.py @@ -25,9 +25,9 @@ from .models import ( Activity, BlockedURLFilter, BlockedUser, Bounty, BountyEvent, BountyFulfillment, BountyInvites, BountySyncRequest, - CoinRedemption, CoinRedemptionRequest, Coupon, Earning, FeedbackEntry, FundRequest, HackathonEvent, HackathonProject, - HackathonRegistration, HackathonSponsor, Interest, LabsResearch, PortfolioItem, Profile, ProfileView, - SearchHistory, Sponsor, Tip, TipPayout, TokenApproval, Tool, ToolVote, TribeMember, UserAction, + CoinRedemption, CoinRedemptionRequest, Coupon, Earning, FeedbackEntry, FundRequest, HackathonEvent, + HackathonProject, HackathonRegistration, HackathonSponsor, Interest, LabsResearch, PortfolioItem, Profile, + ProfileView, SearchHistory, Sponsor, Tip, TipPayout, TokenApproval, Tool, ToolVote, TribeMember, UserAction, UserVerificationModel, ) diff --git a/app/dashboard/migrations/0098_auto_20200409_0651.py b/app/dashboard/migrations/0103_fundrequest.py similarity index 93% rename from app/dashboard/migrations/0098_auto_20200409_0651.py rename to app/dashboard/migrations/0103_fundrequest.py index 373ace003a7..162f3e2ad04 100644 --- a/app/dashboard/migrations/0098_auto_20200409_0651.py +++ b/app/dashboard/migrations/0103_fundrequest.py @@ -1,4 +1,4 @@ -# Generated by Django 2.2.4 on 2020-04-09 06:51 +# Generated by Django 2.2.4 on 2020-04-28 10:59 from django.db import migrations, models import django.db.models.deletion @@ -8,7 +8,7 @@ class Migration(migrations.Migration): dependencies = [ - ('dashboard', '0097_merge_20200408_1219'), + ('dashboard', '0102_auto_20200422_1452'), ] operations = [ diff --git a/app/dashboard/models.py b/app/dashboard/models.py index 6f5275ab6d4..d395b961922 100644 --- a/app/dashboard/models.py +++ b/app/dashboard/models.py @@ -62,7 +62,7 @@ _AUTH, HEADERS, TOKEN_URL, build_auth_dict, get_gh_issue_details, get_issue_comments, issue_number, org_name, repo_name, ) -from marketing.mails import featured_funded_bounty, start_work_approved, fund_request_email +from marketing.mails import featured_funded_bounty, fund_request_email, start_work_approved from marketing.models import LeaderboardRank from rest_framework import serializers from web3 import Web3 diff --git a/app/dashboard/tip_views.py b/app/dashboard/tip_views.py index e27a3a7ac0c..22f34e3d3e6 100644 --- a/app/dashboard/tip_views.py +++ b/app/dashboard/tip_views.py @@ -40,7 +40,7 @@ from retail.helpers import get_ip from web3 import Web3 -from .models import Activity, Profile, Tip, TipPayout, FundRequest +from .models import Activity, FundRequest, Profile, Tip, TipPayout from .notifications import maybe_market_tip_to_email, maybe_market_tip_to_github, maybe_market_tip_to_slack logging.basicConfig(level=logging.DEBUG) diff --git a/app/marketing/mails.py b/app/marketing/mails.py index d93f5828e46..68dc5051c87 100644 --- a/app/marketing/mails.py +++ b/app/marketing/mails.py @@ -37,12 +37,13 @@ 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_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_thank_you_for_supporting_email, - render_tip_email, render_unread_notification_email_weekly_roundup, render_wallpost, render_weekly_recap, - render_request_amount_email) + render_nth_day_email_campaign, render_quarterly_stats, 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_thank_you_for_supporting_email, render_tip_email, render_unread_notification_email_weekly_roundup, + render_wallpost, render_weekly_recap, +) from sendgrid.helpers.mail import Content, Email, Mail, Personalization from sendgrid.helpers.stats import Category from townsquare.utils import is_email_townsquare_enabled, is_there_an_action_available From 198c940b771ecfd88534b8e7cc65cd4eb3fde809 Mon Sep 17 00:00:00 2001 From: Miguel Angel G Date: Wed, 29 Apr 2020 09:29:17 -0500 Subject: [PATCH 8/9] Fix style on vars --- app/assets/onepager/js/request.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/app/assets/onepager/js/request.js b/app/assets/onepager/js/request.js index a3be99110b0..fc02cd7b423 100644 --- a/app/assets/onepager/js/request.js +++ b/app/assets/onepager/js/request.js @@ -17,24 +17,26 @@ $(document).ready(function() { } loading_button($(this)); // get form data - var username = $('.username-search').select2('data')[0] ? $('.username-search').select2('data')[0].text : ''; - var amount = parseFloat($('#amount').val()); - var network = $('#network').val(); - var address = $('#address').val(); - var comments = $('#comments').val(); - var tokenAddress = ( + const username = $('.username-search').select2('data')[0] ? $('.username-search').select2('data')[0].text : ''; + const amount = parseFloat($('#amount').val()); + const network = $('#network').val(); + const address = $('#address').val(); + const comments = $('#comments').val(); + const tokenAddress = ( ($('#token').val() == '0x0') ? '0x0000000000000000000000000000000000000000' : $('#token').val()); // derived info - var isSendingETH = (tokenAddress == '0x0' || tokenAddress == '0x0000000000000000000000000000000000000000'); - var tokenDetails = tokenAddressToDetails(tokenAddress); - var tokenName = 'ETH'; + const isSendingETH = (tokenAddress == '0x0' || tokenAddress == '0x0000000000000000000000000000000000000000'); + const tokenDetails = tokenAddressToDetails(tokenAddress); + let tokenName; if (network == 'ETH' == !isSendingETH) { tokenName = tokenDetails.name; + } else { + tokenName = 'ETH'; } if (!username) { @@ -42,10 +44,10 @@ $(document).ready(function() { return; } - var success_callback = function() { + const success_callback = function() { unloading_button($('#request')); }; - var failure_callback = function() { + const failure_callback = function() { unloading_button($('#request')); }; @@ -60,8 +62,6 @@ function requestFunds(username, amount, comments, tokenAddress, tokenName, netwo username = '@' + username; } - var tokenDetails = tokenAddressToDetails(tokenAddress); - if (!isNumeric(amount) || amount == 0) { _alert({ message: gettext('You must enter the amount!') }, 'warning'); failure_callback(); From 91c7952be0e85f4b6e4d98a6a41defc773567cb6 Mon Sep 17 00:00:00 2001 From: Miguel Angel G Date: Wed, 29 Apr 2020 09:39:04 -0500 Subject: [PATCH 9/9] fix migration error --- .../migrations/{0103_fundrequest.py => 0104_fundrequest.py} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename app/dashboard/migrations/{0103_fundrequest.py => 0104_fundrequest.py} (93%) diff --git a/app/dashboard/migrations/0103_fundrequest.py b/app/dashboard/migrations/0104_fundrequest.py similarity index 93% rename from app/dashboard/migrations/0103_fundrequest.py rename to app/dashboard/migrations/0104_fundrequest.py index 162f3e2ad04..59c1c2e53b7 100644 --- a/app/dashboard/migrations/0103_fundrequest.py +++ b/app/dashboard/migrations/0104_fundrequest.py @@ -1,4 +1,4 @@ -# Generated by Django 2.2.4 on 2020-04-28 10:59 +# Generated by Django 2.2.4 on 2020-04-29 14:38 from django.db import migrations, models import django.db.models.deletion @@ -8,7 +8,7 @@ class Migration(migrations.Migration): dependencies = [ - ('dashboard', '0102_auto_20200422_1452'), + ('dashboard', '0103_auto_20200428_1057'), ] operations = [