From fbe529b2e9060e18f0c7b14d99178a2b69e20b93 Mon Sep 17 00:00:00 2001 From: octavioamu Date: Tue, 25 Jun 2019 21:56:59 -0300 Subject: [PATCH 01/24] add personas modal --- app/app/context.py | 3 ++ app/assets/v2/js/base.js | 33 ++++++++++++++++++- app/retail/templates/home/index.html | 16 ++++++--- .../templates/shared/footer_scripts.html | 4 +-- .../templates/shared/footer_scripts_lite.html | 4 +-- 5 files changed, 48 insertions(+), 12 deletions(-) diff --git a/app/app/context.py b/app/app/context.py index 27afc921c01..820ca588798 100644 --- a/app/app/context.py +++ b/app/app/context.py @@ -91,6 +91,9 @@ def preprocess(request): 'access_token': profile.access_token if profile else '', 'is_staff': request.user.is_staff if user_is_authenticated else False, 'is_moderator': profile.is_moderator if profile else False, + 'persona_is_funder': profile.persona_is_funder if profile else False, + 'persona_is_hunter': profile.persona_is_hunter if profile else False, + } context['json_context'] = json.dumps(context) diff --git a/app/assets/v2/js/base.js b/app/assets/v2/js/base.js index f7cbf91f15a..72c0afd9dc7 100644 --- a/app/assets/v2/js/base.js +++ b/app/assets/v2/js/base.js @@ -171,7 +171,7 @@ if ($('#is-authenticated').val() === 'True' && !localStorage['notify_policy_upda ${gettext('Read Our Updated Terms')}
- Ok +
@@ -180,3 +180,34 @@ if ($('#is-authenticated').val() === 'True' && !localStorage['notify_policy_upda $(content).appendTo('body'); $('#notify_policy_update').bootstrapModal('show'); } + +if (!document.contxt.persona_is_funder && !document.contxt.persona_is_hunter) { + + const content = $.parseHTML( + ``); + + $(content).appendTo('body'); + $('#persona_modal').bootstrapModal('show'); +} diff --git a/app/retail/templates/home/index.html b/app/retail/templates/home/index.html index 1cbee50de5d..1761521031d 100644 --- a/app/retail/templates/home/index.html +++ b/app/retail/templates/home/index.html @@ -51,7 +51,7 @@

{% trans "Crowdfunding and freelance developers for your software projects"

{% blocktrans %} Coders/Software Developers:
- Get paid in crypto for freelance jobs, building features, and solving bug bounties! Work with top open source projects and get paid out fast. + Get paid in crypto for freelance jobs, building features, and solving bug bounties! Work with top open source projects and get paid out fast. {% endblocktrans %}
{% trans "Bug Bounties" %} @@ -304,17 +304,23 @@

{{ article.title }}

{% include 'shared/bottom_notification.html' %} {% include 'shared/analytics.html' %} - {% include 'shared/footer_scripts.html' with slim=1 %} + {% include 'shared/footer_scripts_lite.html' with slim=1 %} {% include 'shared/footer.html' %} {% include 'shared/messages.html' %} - + + + @@ -79,7 +80,4 @@ {% endif %} - {% include 'shared/messages.html' %} diff --git a/app/retail/templates/shared/footer_scripts_lite.html b/app/retail/templates/shared/footer_scripts_lite.html index 8b46fee8f25..70dc730458a 100644 --- a/app/retail/templates/shared/footer_scripts_lite.html +++ b/app/retail/templates/shared/footer_scripts_lite.html @@ -20,6 +20,7 @@ @@ -77,7 +78,4 @@ {% endif %} - {% include 'shared/messages.html' %} From a22b444dc4516d70daa983f017b0c3c81d8e3ca9 Mon Sep 17 00:00:00 2001 From: octavioamu Date: Mon, 1 Jul 2019 19:43:45 -0300 Subject: [PATCH 02/24] apply styles --- .../v2/images/modals/persona-choose.svg | 100 ++++++++++++++++++ app/assets/v2/js/base.js | 17 ++- 2 files changed, 108 insertions(+), 9 deletions(-) create mode 100644 app/assets/v2/images/modals/persona-choose.svg diff --git a/app/assets/v2/images/modals/persona-choose.svg b/app/assets/v2/images/modals/persona-choose.svg new file mode 100644 index 00000000000..a5320022de0 --- /dev/null +++ b/app/assets/v2/images/modals/persona-choose.svg @@ -0,0 +1,100 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/assets/v2/js/base.js b/app/assets/v2/js/base.js index 72c0afd9dc7..31b59e4acf9 100644 --- a/app/assets/v2/js/base.js +++ b/app/assets/v2/js/base.js @@ -181,7 +181,7 @@ if ($('#is-authenticated').val() === 'True' && !localStorage['notify_policy_upda $('#notify_policy_update').bootstrapModal('show'); } -if (!document.contxt.persona_is_funder && !document.contxt.persona_is_hunter) { +if (document.contxt.github_handle && !document.contxt.persona_is_funder && !document.contxt.persona_is_hunter) { const content = $.parseHTML( `
-

${gettext('Are you a Funder or a Contributor?')}

+ +

${gettext('Are you a Funder or a Contributor?')}

-
-

${gettext('Let us know so we could optimize the best experience for you!')}

+
+

${gettext('Let us know so we could optimize the
best experience for you!')}

-
- - - - +
+ +
From f54ff85a011f78cfad096c5829846185bdf64df9 Mon Sep 17 00:00:00 2001 From: octavioamu Date: Mon, 1 Jul 2019 19:47:39 -0300 Subject: [PATCH 03/24] optimize svg --- .../v2/images/modals/persona-choose.svg | 154 +++++++----------- 1 file changed, 57 insertions(+), 97 deletions(-) diff --git a/app/assets/v2/images/modals/persona-choose.svg b/app/assets/v2/images/modals/persona-choose.svg index a5320022de0..c801b297e7d 100644 --- a/app/assets/v2/images/modals/persona-choose.svg +++ b/app/assets/v2/images/modals/persona-choose.svg @@ -1,100 +1,60 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 0bfa4bb85fe9958c2b7cb8dcdbbcafd6745711f9 Mon Sep 17 00:00:00 2001 From: octavioamu Date: Tue, 2 Jul 2019 14:08:04 -0300 Subject: [PATCH 04/24] fix bootstrap compatibility in all site --- app/assets/v2/js/rating.js | 2 +- app/dashboard/templates/bounty/details.html | 10 +--------- app/dashboard/templates/bounty/fulfill.html | 11 +---------- app/dashboard/templates/bulk_payout_bounty.html | 14 +++----------- app/dashboard/templates/dashboard/index.html | 11 +++++------ app/dashboard/templates/dashboard/users.html | 12 ++++-------- app/dashboard/templates/process_bounty.html | 8 +------- app/dashboard/templates/profiles/profile.html | 8 +------- app/grants/templates/grants/detail/index.html | 7 +------ app/grants/templates/grants/fund.html | 6 ------ app/kudos/templates/kudos_details.html | 5 +---- app/retail/templates/bounties/contributor.html | 9 +-------- app/retail/templates/shared/footer_scripts.html | 10 ++++++++++ .../templates/shared/footer_scripts_lite.html | 5 +++-- 14 files changed, 33 insertions(+), 85 deletions(-) diff --git a/app/assets/v2/js/rating.js b/app/assets/v2/js/rating.js index f7c53687e81..c05098d3305 100644 --- a/app/assets/v2/js/rating.js +++ b/app/assets/v2/js/rating.js @@ -12,7 +12,7 @@ const ratingModal = (bountyId, receiver, elem) => { }).done(function(result) { $('body').append(result); $('#modalRating').bootstrapModal('show'); - $('[data-toggle="tooltip"]').runTooltip(); + $('[data-toggle="tooltip"]').bootstrapTooltip(); $('input[name="review[rating]"]').filter('[value="' + elem.val() + '"]').prop('checked', true); $('#ratingForm').on('submit', function(e) { diff --git a/app/dashboard/templates/bounty/details.html b/app/dashboard/templates/bounty/details.html index 1a64bdc2e1a..05f6e87d674 100644 --- a/app/dashboard/templates/bounty/details.html +++ b/app/dashboard/templates/bounty/details.html @@ -441,16 +441,8 @@
{% trans "Funder" %}
- - - + > - - diff --git a/app/dashboard/templates/bulk_payout_bounty.html b/app/dashboard/templates/bulk_payout_bounty.html index 0040a3b1e86..1ca1a89a108 100644 --- a/app/dashboard/templates/bulk_payout_bounty.html +++ b/app/dashboard/templates/bulk_payout_bounty.html @@ -71,7 +71,7 @@

{% trans "Advanced Payout" %}

- + @@ -83,7 +83,7 @@

{% trans "Advanced Payout" %}

{% for key, token in bounty.additional_funding_summary.items %} {{ key }} {% endfor %} - +
{% endif %} @@ -201,17 +201,9 @@
{% trans 'Payout Preview' %}
{% include 'shared/footer.html' %} {% include 'shared/messages.html' %} - - - - diff --git a/app/dashboard/templates/dashboard/index.html b/app/dashboard/templates/dashboard/index.html index 25ebc87de3c..cf444bf21f9 100644 --- a/app/dashboard/templates/dashboard/index.html +++ b/app/dashboard/templates/dashboard/index.html @@ -106,11 +106,10 @@

{% trans "No results found." %}

{% include 'shared/footer_scripts.html' %} {% include 'shared/footer.html' %} {% include 'shared/messages.html' %} - - + - - diff --git a/app/dashboard/templates/process_bounty.html b/app/dashboard/templates/process_bounty.html index f87cb761043..ab9dba5e051 100644 --- a/app/dashboard/templates/process_bounty.html +++ b/app/dashboard/templates/process_bounty.html @@ -160,15 +160,9 @@

Suggested Kudos

- - diff --git a/app/dashboard/templates/profiles/profile.html b/app/dashboard/templates/profiles/profile.html index 2b242d0ee01..c33b52f1922 100644 --- a/app/dashboard/templates/profiles/profile.html +++ b/app/dashboard/templates/profiles/profile.html @@ -303,15 +303,9 @@

- - diff --git a/app/grants/templates/grants/detail/index.html b/app/grants/templates/grants/detail/index.html index d6fa31af098..fd92846cbd3 100644 --- a/app/grants/templates/grants/detail/index.html +++ b/app/grants/templates/grants/detail/index.html @@ -78,13 +78,8 @@ - - diff --git a/app/grants/templates/grants/fund.html b/app/grants/templates/grants/fund.html index 387c3e60768..960e9ad2a14 100644 --- a/app/grants/templates/grants/fund.html +++ b/app/grants/templates/grants/fund.html @@ -323,11 +323,5 @@

Thanks for Contributing!
- - diff --git a/app/kudos/templates/kudos_details.html b/app/kudos/templates/kudos_details.html index 69933d5ef07..b9886946e09 100644 --- a/app/kudos/templates/kudos_details.html +++ b/app/kudos/templates/kudos_details.html @@ -133,15 +133,12 @@

{{ kudos.ui_name }} {% if kudos. {% include 'shared/analytics.html' %} {% include 'shared/footer_scripts.html' with slim=1 %} - - {% include 'shared/messages.html' %} diff --git a/app/retail/templates/bounties/contributor.html b/app/retail/templates/bounties/contributor.html index 0513397a1c2..56721fd1fd8 100644 --- a/app/retail/templates/bounties/contributor.html +++ b/app/retail/templates/bounties/contributor.html @@ -64,7 +64,7 @@ - + {% if activities|length %}
{% include 'bounties/contributor/activity.html' %} @@ -112,13 +112,6 @@

{% trans "All that's left

{% include 'shared/footer_scripts.html' with slim=1 %} - - - {% if tech_stack %} {% endif %} {% include 'shared/sentry.html' %} + + + + {% if not slim %} diff --git a/app/retail/templates/shared/footer_scripts_lite.html b/app/retail/templates/shared/footer_scripts_lite.html index 70dc730458a..ec437ac5995 100644 --- a/app/retail/templates/shared/footer_scripts_lite.html +++ b/app/retail/templates/shared/footer_scripts_lite.html @@ -33,9 +33,10 @@ From 10a97602ba6750ab8f397b527bf292662e8ef339 Mon Sep 17 00:00:00 2001 From: octavioamu Date: Tue, 2 Jul 2019 14:12:44 -0300 Subject: [PATCH 05/24] remove comments --- app/dashboard/templates/dashboard/index.html | 5 ----- app/retail/templates/home/index.html | 16 +--------------- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/app/dashboard/templates/dashboard/index.html b/app/dashboard/templates/dashboard/index.html index cf444bf21f9..8bcded5f593 100644 --- a/app/dashboard/templates/dashboard/index.html +++ b/app/dashboard/templates/dashboard/index.html @@ -108,9 +108,6 @@

{% trans "No results found." %}

{% include 'shared/messages.html' %} - - + - diff --git a/app/kudos/templates/kudos_about.html b/app/kudos/templates/kudos_about.html index 493d8e1322b..0993d725383 100644 --- a/app/kudos/templates/kudos_about.html +++ b/app/kudos/templates/kudos_about.html @@ -438,7 +438,6 @@
I have another question and it's not listed here.
setInterval(load_kudos_card_images, 300); }); - var bootstrapTooltip = $.fn.tooltip.noConflict() {% include 'shared/messages.html' %} diff --git a/app/kudos/templates/kudos_marketplace.html b/app/kudos/templates/kudos_marketplace.html index 7f69081497d..1e129eb8d24 100644 --- a/app/kudos/templates/kudos_marketplace.html +++ b/app/kudos/templates/kudos_marketplace.html @@ -111,7 +111,6 @@

UH-OH!

$(document).ready(function() { $("img").unveil(200); }); - var bootstrapTooltip = $.fn.tooltip.noConflict() {% include 'shared/messages.html' %} From 07f79f17239a0e1eb48a0c906abd39bd42e6897e Mon Sep 17 00:00:00 2001 From: octavioamu Date: Tue, 2 Jul 2019 18:18:36 -0300 Subject: [PATCH 08/24] remove empty lines --- app/assets/v2/js/shared.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/assets/v2/js/shared.js b/app/assets/v2/js/shared.js index 3f79126adfa..b8f8f541206 100644 --- a/app/assets/v2/js/shared.js +++ b/app/assets/v2/js/shared.js @@ -70,9 +70,6 @@ var loading_button = function(button) { button.prepend(''); }; - - - var update_metamask_conf_time_and_cost_estimate = function() { var confTime = 'unknown'; var ethAmount = 'unknown'; From be00a17a944a9d8007eba6fe755048718543dbbb Mon Sep 17 00:00:00 2001 From: Owocki Date: Tue, 9 Jul 2019 12:29:44 -0600 Subject: [PATCH 09/24] improves profile speed by moving the activity tab into lazy load --- app/assets/v2/js/pages/profile.js | 4 ++-- app/dashboard/templates/profiles/profile.html | 10 ++++++---- app/dashboard/views.py | 1 + 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/assets/v2/js/pages/profile.js b/app/assets/v2/js/pages/profile.js index 1549058daf9..9dc4ba2a8be 100644 --- a/app/assets/v2/js/pages/profile.js +++ b/app/assets/v2/js/pages/profile.js @@ -34,12 +34,12 @@ $(document).ready(function() { if (ignoreScrollOffset || window.scrollY >= tabSection.scrollHeight) { const activityName = activityContainer.id; - let page = parseInt(activityContainer.getAttribute('page')) || 1; + let page = parseInt(activityContainer.getAttribute('page')) || 0; fetchInProgress = true; loadingImg.className = loadingImg.className.replace('hidden', 'visible'); - fetch(location.href.replace(location.hash, '') + '?p=' + (++page) + '&a=' + activityName).then( + fetch(location.href.replace(location.hash, '') + '?p=' + (page++) + '&a=' + activityName).then( function(response) { if (response.status === 200) { response.text().then( diff --git a/app/dashboard/templates/profiles/profile.html b/app/dashboard/templates/profiles/profile.html index 2b242d0ee01..3b5657b587e 100644 --- a/app/dashboard/templates/profiles/profile.html +++ b/app/dashboard/templates/profiles/profile.html @@ -262,10 +262,12 @@

- {% if tab.type == 'activity' %} - {% include 'profiles/profile_activities.html' with activities=tab.objects %} - {% else %} - {% include 'profiles/profile_bounties.html' with bounties=tab.objects %} + {% if show_activity %} + {% if tab.type == 'activity' %} + {% include 'profiles/profile_activities.html' with activities=tab.objects %} + {% else %} + {% include 'profiles/profile_bounties.html' with bounties=tab.objects %} + {% endif %} {% endif %}
diff --git a/app/dashboard/views.py b/app/dashboard/views.py index 9f53d4ca923..df1d63681fa 100644 --- a/app/dashboard/views.py +++ b/app/dashboard/views.py @@ -2074,6 +2074,7 @@ def profile(request, handle): } return JsonResponse(msg, status=msg.get('status', 200)) + context['show_activity'] = request.GET.get('p', None) return TemplateResponse(request, 'profiles/profile.html', context, status=status) From 584d3e82513ebb24aff0ccca008efdae83d2660d Mon Sep 17 00:00:00 2001 From: Owocki Date: Tue, 9 Jul 2019 12:34:04 -0600 Subject: [PATCH 10/24] logic condition --- app/dashboard/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/dashboard/views.py b/app/dashboard/views.py index df1d63681fa..5f9cca39089 100644 --- a/app/dashboard/views.py +++ b/app/dashboard/views.py @@ -2074,7 +2074,7 @@ def profile(request, handle): } return JsonResponse(msg, status=msg.get('status', 200)) - context['show_activity'] = request.GET.get('p', None) + context['show_activity'] = request.GET.get('p', False) != False return TemplateResponse(request, 'profiles/profile.html', context, status=status) From 82c310ac7ab21d5dd1f9e6eeef6e64b2a733567a Mon Sep 17 00:00:00 2001 From: Owocki Date: Tue, 9 Jul 2019 13:10:27 -0600 Subject: [PATCH 11/24] increase profile speed --- .../migrations/0039_auto_20190709_1907.py | 22 ++++++++++ app/dashboard/models.py | 43 +++++++++++++++++-- 2 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 app/dashboard/migrations/0039_auto_20190709_1907.py diff --git a/app/dashboard/migrations/0039_auto_20190709_1907.py b/app/dashboard/migrations/0039_auto_20190709_1907.py new file mode 100644 index 00000000000..fdb09748f7d --- /dev/null +++ b/app/dashboard/migrations/0039_auto_20190709_1907.py @@ -0,0 +1,22 @@ +# Generated by Django 2.1.7 on 2019-07-09 19:07 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('dashboard', '0038_auto_20190627_1352'), + ] + + operations = [ + migrations.AlterField( + model_name='useraction', + name='action', + field=models.CharField(choices=[('Login', 'Login'), ('Logout', 'Logout'), ('Visit', 'Visit'), ('added_slack_integration', 'Added Slack Integration'), ('removed_slack_integration', 'Removed Slack Integration'), ('updated_avatar', 'Updated Avatar'), ('account_disconnected', 'Account Disconnected')], db_index=True, max_length=50), + ), + migrations.AlterIndexTogether( + name='useraction', + index_together={('profile', 'action')}, + ), + ] diff --git a/app/dashboard/models.py b/app/dashboard/models.py index f7004c53bc2..19e7ec1cb30 100644 --- a/app/dashboard/models.py +++ b/app/dashboard/models.py @@ -2825,10 +2825,15 @@ def to_dict(self, activities=True, leaderboards=True, network=None, tips=True): dict: The profile card context. """ + import time + counter = 1 + print(f"* {counter}", time.time()) params = {} network = network or self.get_network() query_kwargs = {'network': network} bounties = self.bounties + counter += 1 + print(f"* {counter}", time.time()) fulfilled_bounties = self.get_fulfilled_bounties(network=network) funded_bounties = self.get_funded_bounties(network=network) orgs_bounties = None @@ -2836,16 +2841,24 @@ def to_dict(self, activities=True, leaderboards=True, network=None, tips=True): if self.is_org: orgs_bounties = self.get_orgs_bounties(network=network) + counter += 1 + print(f"* {counter}", time.time()) sum_eth_funded = self.get_eth_sum(sum_type='funded', bounties=funded_bounties) sum_eth_collected = self.get_eth_sum(bounties=fulfilled_bounties) + counter += 1 + print(f"* {counter}", time.time()) works_with_funded = self.get_who_works_with(work_type='funded', bounties=funded_bounties) works_with_collected = self.get_who_works_with(work_type='collected', bounties=fulfilled_bounties) + counter += 1 + print(f"* {counter}", time.time()) sum_all_funded_tokens = self.get_all_tokens_sum(sum_type='funded', bounties=funded_bounties, network=network) sum_all_collected_tokens = self.get_all_tokens_sum( sum_type='collected', bounties=fulfilled_bounties, network=network ) # org only + counter += 1 + print(f"* {counter}", time.time()) count_bounties_on_repo = 0 sum_eth_on_repos = 0 works_with_org = [] @@ -2854,10 +2867,17 @@ def to_dict(self, activities=True, leaderboards=True, network=None, tips=True): sum_eth_on_repos = self.get_eth_sum(bounties=orgs_bounties) works_with_org = self.get_who_works_with(work_type='org', bounties=orgs_bounties) + counter += 1 + print(f"* {counter}", time.time()) #7 total_funded = funded_bounties.count() + print(f"* {counter}", time.time())#8 total_fulfilled = fulfilled_bounties.count() - desc = self.get_desc(funded_bounties, fulfilled_bounties) + print(f"* {counter}", time.time()) #9 + desc = self.get_desc(funded_bounties, fulfilled_bounties) + print(f"* {counter}", time.time()) #10 no_times_been_removed = self.no_times_been_removed_by_funder() + self.no_times_been_removed_by_staff() + self.no_times_slashed_by_staff() + counter += 1 + print(f"* {counter}", time.time()) #11 params = { 'title': f"@{self.handle}", 'active': 'profile_details', @@ -2881,17 +2901,25 @@ def to_dict(self, activities=True, leaderboards=True, network=None, tips=True): 'sum_all_collected_tokens': sum_all_collected_tokens } + counter += 1 + print(f"* {counter}", time.time()) if activities: params['activities'] = self.get_various_activities(network=network) if tips: params['tips'] = self.tips.filter(**query_kwargs).send_happy_path() + counter += 1 + print(f"* {counter}", time.time()) if leaderboards: params['scoreboard_position_contributor'] = self.get_contributor_leaderboard_index() + counter += 1 + print(f"* {counter}", time.time()) params['scoreboard_position_funder'] = self.get_funder_leaderboard_index() if self.is_org: params['scoreboard_position_org'] = self.get_org_leaderboard_index() + counter += 1 + print(f"* {counter}", time.time()) return params @@ -3005,14 +3033,21 @@ class UserAction(SuperModel): ('updated_avatar', 'Updated Avatar'), ('account_disconnected', 'Account Disconnected'), ] - action = models.CharField(max_length=50, choices=ACTION_TYPES) - user = models.ForeignKey(User, related_name='actions', on_delete=models.SET_NULL, null=True) - profile = models.ForeignKey('dashboard.Profile', related_name='actions', on_delete=models.CASCADE, null=True) + action = models.CharField(max_length=50, choices=ACTION_TYPES, db_index=True) + user = models.ForeignKey(User, related_name='actions', on_delete=models.SET_NULL, null=True, db_index=True) + profile = models.ForeignKey('dashboard.Profile', related_name='actions', on_delete=models.CASCADE, null=True, db_index=True) ip_address = models.GenericIPAddressField(null=True) location_data = JSONField(default=dict) metadata = JSONField(default=dict) utm = JSONField(default=dict, null=True) + class Meta: + """Define metadata associated with UserAction.""" + + index_together = [ + ["profile", "action"], + ] + def __str__(self): return f"{self.action} by {self.profile} at {self.created_on}" From 0eb8d0217c2b710e673f851bf995995e2b278760 Mon Sep 17 00:00:00 2001 From: Owocki Date: Tue, 9 Jul 2019 13:13:16 -0600 Subject: [PATCH 12/24] fix the model --- app/dashboard/models.py | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/app/dashboard/models.py b/app/dashboard/models.py index 19e7ec1cb30..56ab7f5959d 100644 --- a/app/dashboard/models.py +++ b/app/dashboard/models.py @@ -2825,15 +2825,10 @@ def to_dict(self, activities=True, leaderboards=True, network=None, tips=True): dict: The profile card context. """ - import time - counter = 1 - print(f"* {counter}", time.time()) params = {} network = network or self.get_network() query_kwargs = {'network': network} bounties = self.bounties - counter += 1 - print(f"* {counter}", time.time()) fulfilled_bounties = self.get_fulfilled_bounties(network=network) funded_bounties = self.get_funded_bounties(network=network) orgs_bounties = None @@ -2841,24 +2836,16 @@ def to_dict(self, activities=True, leaderboards=True, network=None, tips=True): if self.is_org: orgs_bounties = self.get_orgs_bounties(network=network) - counter += 1 - print(f"* {counter}", time.time()) sum_eth_funded = self.get_eth_sum(sum_type='funded', bounties=funded_bounties) sum_eth_collected = self.get_eth_sum(bounties=fulfilled_bounties) - counter += 1 - print(f"* {counter}", time.time()) works_with_funded = self.get_who_works_with(work_type='funded', bounties=funded_bounties) works_with_collected = self.get_who_works_with(work_type='collected', bounties=fulfilled_bounties) - counter += 1 - print(f"* {counter}", time.time()) sum_all_funded_tokens = self.get_all_tokens_sum(sum_type='funded', bounties=funded_bounties, network=network) sum_all_collected_tokens = self.get_all_tokens_sum( sum_type='collected', bounties=fulfilled_bounties, network=network ) # org only - counter += 1 - print(f"* {counter}", time.time()) count_bounties_on_repo = 0 sum_eth_on_repos = 0 works_with_org = [] @@ -2867,17 +2854,10 @@ def to_dict(self, activities=True, leaderboards=True, network=None, tips=True): sum_eth_on_repos = self.get_eth_sum(bounties=orgs_bounties) works_with_org = self.get_who_works_with(work_type='org', bounties=orgs_bounties) - counter += 1 - print(f"* {counter}", time.time()) #7 total_funded = funded_bounties.count() - print(f"* {counter}", time.time())#8 total_fulfilled = fulfilled_bounties.count() - print(f"* {counter}", time.time()) #9 desc = self.get_desc(funded_bounties, fulfilled_bounties) - print(f"* {counter}", time.time()) #10 no_times_been_removed = self.no_times_been_removed_by_funder() + self.no_times_been_removed_by_staff() + self.no_times_slashed_by_staff() - counter += 1 - print(f"* {counter}", time.time()) #11 params = { 'title': f"@{self.handle}", 'active': 'profile_details', @@ -2901,25 +2881,17 @@ def to_dict(self, activities=True, leaderboards=True, network=None, tips=True): 'sum_all_collected_tokens': sum_all_collected_tokens } - counter += 1 - print(f"* {counter}", time.time()) if activities: params['activities'] = self.get_various_activities(network=network) if tips: params['tips'] = self.tips.filter(**query_kwargs).send_happy_path() - counter += 1 - print(f"* {counter}", time.time()) if leaderboards: params['scoreboard_position_contributor'] = self.get_contributor_leaderboard_index() - counter += 1 - print(f"* {counter}", time.time()) params['scoreboard_position_funder'] = self.get_funder_leaderboard_index() if self.is_org: params['scoreboard_position_org'] = self.get_org_leaderboard_index() - counter += 1 - print(f"* {counter}", time.time()) return params From 711933f84c60de600a36e84ec91215524206e335 Mon Sep 17 00:00:00 2001 From: Owocki Date: Tue, 9 Jul 2019 13:13:50 -0600 Subject: [PATCH 13/24] fix the model --- app/dashboard/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/dashboard/models.py b/app/dashboard/models.py index 56ab7f5959d..0307c5a3d36 100644 --- a/app/dashboard/models.py +++ b/app/dashboard/models.py @@ -2856,7 +2856,7 @@ def to_dict(self, activities=True, leaderboards=True, network=None, tips=True): total_funded = funded_bounties.count() total_fulfilled = fulfilled_bounties.count() - desc = self.get_desc(funded_bounties, fulfilled_bounties) + desc = self.get_desc(funded_bounties, fulfilled_bounties) no_times_been_removed = self.no_times_been_removed_by_funder() + self.no_times_been_removed_by_staff() + self.no_times_slashed_by_staff() params = { 'title': f"@{self.handle}", From 34dc148d94b651d0014f173ac4250529b3072c1f Mon Sep 17 00:00:00 2001 From: Owocki Date: Tue, 9 Jul 2019 13:56:52 -0600 Subject: [PATCH 14/24] more profile speed improvments --- app/dashboard/models.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/app/dashboard/models.py b/app/dashboard/models.py index f7004c53bc2..089f8226c10 100644 --- a/app/dashboard/models.py +++ b/app/dashboard/models.py @@ -2641,8 +2641,7 @@ def get_eth_sum(self, sum_type='collected', network='mainnet', bounties=None): """ eth_sum = 0 - - if not bounties: + if bounties is None: if sum_type == 'funded': bounties = self.get_funded_bounties(network=network) elif sum_type == 'collected': @@ -2655,9 +2654,7 @@ def get_eth_sum(self, sum_type='collected', network='mainnet', bounties=None): try: if bounties.exists(): - eth_sum = bounties.aggregate( - Sum('value_in_eth') - )['value_in_eth__sum'] / 10**18 + eth_sum = sum([amount for amount in bounty.values_list("value_in_eth", flat=True)]) except Exception: pass @@ -2715,7 +2712,7 @@ def get_who_works_with(self, work_type='collected', network='mainnet', bounties= dict: list of the profiles that were worked with (key) and the number of times they occured """ - if not bounties: + if bounties is None: if work_type == 'funded': bounties = self.bounties_funded.filter(network=network) elif work_type == 'collected': From 223c89cd5eebfa0328597d23165fbff03bed4978 Mon Sep 17 00:00:00 2001 From: Owocki Date: Tue, 9 Jul 2019 14:36:40 -0600 Subject: [PATCH 15/24] profile perofrmance --- app/dashboard/views.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/app/dashboard/views.py b/app/dashboard/views.py index 9f53d4ca923..d133a86f85e 100644 --- a/app/dashboard/views.py +++ b/app/dashboard/views.py @@ -1983,18 +1983,29 @@ def profile(request, handle): context['ratings'] = range(0,5) tabs = [] + counts = all_activities.values('activity_type').order_by('activity_type').annotate(the_count=Count('activity_type')) + counts = {ele['activity_type']: ele['the_count'] for ele in counts} for tab, name in activity_tabs: - activities = profile_filter_activities(all_activities, tab) - activities_count = activities.count() + # this functions as profile_filter_activities does + # except w. aggregate counts + + if tab == 'all': + activities_count = sum([val for key, val in counts.items()]) + else: + activities_count = counts.get(tab, 0) + if tab == 'start_work': + activities_count += counts['worker_approved'] + + + # dont draw a tab where the activities count is 0 if activities_count == 0: continue - paginator = Paginator(activities, 10) - + # buidl dict obj = {'id': tab, 'name': name, - 'objects': paginator.get_page(1), + 'objects': [], 'count': activities_count, 'type': 'activity' } From bc0bce63b0de6ee2f5ff5c20af893d60c96acf25 Mon Sep 17 00:00:00 2001 From: Kevin Owocki Date: Tue, 9 Jul 2019 15:03:23 -0600 Subject: [PATCH 16/24] .get --- app/dashboard/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/dashboard/views.py b/app/dashboard/views.py index d133a86f85e..b05e1dc4ee8 100644 --- a/app/dashboard/views.py +++ b/app/dashboard/views.py @@ -1995,7 +1995,7 @@ def profile(request, handle): else: activities_count = counts.get(tab, 0) if tab == 'start_work': - activities_count += counts['worker_approved'] + activities_count += counts.get("worker_approved", 0) # dont draw a tab where the activities count is 0 From a736aa73d76c410490d4cfd4147c1639647cce2a Mon Sep 17 00:00:00 2001 From: octavioamu Date: Wed, 10 Jul 2019 22:04:28 -0300 Subject: [PATCH 17/24] add persona chooser to settings --- app/marketing/views.py | 4 ++++ app/retail/templates/settings/account.html | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/app/marketing/views.py b/app/marketing/views.py index 5b7f66c3b39..ae2f1a394f4 100644 --- a/app/marketing/views.py +++ b/app/marketing/views.py @@ -513,6 +513,10 @@ def account_settings(request): return login_redirect if request.POST: + if 'persona_is_funder' or 'persona_is_hunter' in request.POST.keys(): + profile.persona_is_funder = bool(request.POST.get('persona_is_funder', False)) + profile.persona_is_hunter = bool(request.POST.get('persona_is_hunter', False)) + profile.save() if 'preferred_payout_address' in request.POST.keys(): profile.preferred_payout_address = request.POST.get('preferred_payout_address', '') diff --git a/app/retail/templates/settings/account.html b/app/retail/templates/settings/account.html index dfc2b9d7622..5ed1c75cba0 100644 --- a/app/retail/templates/settings/account.html +++ b/app/retail/templates/settings/account.html @@ -51,7 +51,21 @@ border: 0.2rem solid #1AB56D; } -
+ +
+
{% trans "Account type" %}
+

{% trans "Let us know so we could optimize the best experience for you!" %}

+
+
+ + +
+
+ + +
+
+
{% trans "ETH Account Preferences" %}
From 8da8f254606cdbc6667e1ef509e946ba7db934de Mon Sep 17 00:00:00 2001 From: Owocki Date: Thu, 11 Jul 2019 16:05:42 -0600 Subject: [PATCH 18/24] v small profile fix --- app/assets/v2/js/pages/profile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/v2/js/pages/profile.js b/app/assets/v2/js/pages/profile.js index 9dc4ba2a8be..4d393092842 100644 --- a/app/assets/v2/js/pages/profile.js +++ b/app/assets/v2/js/pages/profile.js @@ -39,7 +39,7 @@ $(document).ready(function() { fetchInProgress = true; loadingImg.className = loadingImg.className.replace('hidden', 'visible'); - fetch(location.href.replace(location.hash, '') + '?p=' + (page++) + '&a=' + activityName).then( + fetch(location.href.replace(location.hash, '') + '?p=' + (++page) + '&a=' + activityName).then( function(response) { if (response.status === 200) { response.text().then( From 6147d8cb1f37c30913ff31f4cbd7b73222062914 Mon Sep 17 00:00:00 2001 From: octavioamu Date: Fri, 12 Jul 2019 00:02:07 -0300 Subject: [PATCH 19/24] fix condition --- app/assets/v2/js/base.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/v2/js/base.js b/app/assets/v2/js/base.js index fcf0516452d..3ab632685cc 100644 --- a/app/assets/v2/js/base.js +++ b/app/assets/v2/js/base.js @@ -280,7 +280,7 @@ const sendPersonal = (persona) => { $('#persona_modal').bootstrapModal('hide'); const urls = [ { - url: document.location.origin, + url: document.location.href, redirect: '/onboard/funder' }, { @@ -295,7 +295,7 @@ const sendPersonal = (persona) => { // TODO: CLEAN COMMENTS const checkUrl = (arr, val) => { return arr.some(arrObj => { - if (val.indexOf(arrObj.url) > 0) { + if (val.indexOf(arrObj.url) >= 0) { // window.location = arrObj.redirect; return true; } From f8fd8d0b34b37c75fda6c96340dcf0ca4bced0e9 Mon Sep 17 00:00:00 2001 From: KuhnChris Date: Tue, 16 Jul 2019 10:54:00 +0200 Subject: [PATCH 20/24] Check-In Tool (ambassador) API extension (#4750) * Added new set for checkin tool * Update router.py --- app/dashboard/router.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/dashboard/router.py b/app/dashboard/router.py index 0420c77abf1..00cf6980edc 100644 --- a/app/dashboard/router.py +++ b/app/dashboard/router.py @@ -193,6 +193,13 @@ class Meta: 'keywords', 'value_in_token', 'project_type', 'is_open', 'expires_date', 'latest_activity' ) +class BountySerializerCheckIn(BountySerializer): + class Meta: + model = Bounty + fields = ( + 'url', 'title', 'bounty_owner_name', 'status', 'github_url', 'created_on', 'standard_bounties_id', 'bounty_owner_github_username' + ) + class BountyViewSet(viewsets.ModelViewSet): """Handle the Bounty view behavior.""" queryset = Bounty.objects.prefetch_related('fulfillments', 'interested', 'interested__profile', 'activities', 'unsigned_nda') \ @@ -410,8 +417,12 @@ class BountyViewSetSlim(BountyViewSet): queryset = Bounty.objects.all().order_by('-web3_created') serializer_class = BountySerializerSlim +class BountyViewSetCheckIn(BountyViewSet): + queryset = Bounty.objects.all().order_by('standard_bounties_id') + serializer_class = BountySerializerCheckIn # Routers provide an easy way of automatically determining the URL conf. router = routers.DefaultRouter() router.register(r'bounties/slim', BountyViewSetSlim) router.register(r'bounties', BountyViewSet) +router.register(r'checkin', BountyViewSetCheckIn) From b0058ce6cc7cfd4f98ab9a00221b81f3c73eb2c3 Mon Sep 17 00:00:00 2001 From: octavioamu Date: Tue, 16 Jul 2019 11:05:11 -0300 Subject: [PATCH 21/24] review changes --- app/assets/v2/js/base.js | 11 ++------ app/dashboard/views.py | 29 ++++++++++------------ app/retail/templates/settings/account.html | 2 +- 3 files changed, 16 insertions(+), 26 deletions(-) diff --git a/app/assets/v2/js/base.js b/app/assets/v2/js/base.js index 3ab632685cc..13809eddfaf 100644 --- a/app/assets/v2/js/base.js +++ b/app/assets/v2/js/base.js @@ -156,7 +156,7 @@ const attach_close_button = function() { $('.alert').each(function(index) { if (index == 0) $(this).css('top', 0); else { - var new_top = (index * 66) + 'px'; + let new_top = (index * 66) + 'px'; $(this).css('top', new_top); } @@ -292,11 +292,10 @@ const sendPersonal = (persona) => { redirect: '/onboard/contributor' } ]; - // TODO: CLEAN COMMENTS + const checkUrl = (arr, val) => { return arr.some(arrObj => { if (val.indexOf(arrObj.url) >= 0) { - // window.location = arrObj.redirect; return true; } return false; @@ -304,9 +303,6 @@ const sendPersonal = (persona) => { }; if (response.persona === 'persona_is_funder') { - // if (!checkUrl(urls, document.location.href)) { - // return _alert(gettext('Thanks, you can read the guide here.'), 'info'); - // } if (checkUrl(urls, document.location.href)) { window.location = '/onboard/funder'; } else { @@ -314,9 +310,6 @@ const sendPersonal = (persona) => { } } else if (response.persona === 'persona_is_hunter') { - // if (!checkUrl(urls, document.location.href)) { - // return _alert(gettext('Thanks, you can read the guide here.'), 'info'); - // } if (checkUrl(urls, document.location.href)) { window.location = '/onboard/contributor'; } else { diff --git a/app/dashboard/views.py b/app/dashboard/views.py index b90a36351ec..e8e5059ccdf 100644 --- a/app/dashboard/views.py +++ b/app/dashboard/views.py @@ -2816,24 +2816,21 @@ def get_hackathons(request): @csrf_exempt @require_POST def choose_persona(request): - if request.is_ajax(): - if request.user.is_authenticated: - profile = request.user.profile if request.user.is_authenticated and hasattr(request.user, 'profile') else None - access_token = request.POST.get('access_token') - persona = request.POST.get('persona') - if persona == 'persona_is_funder': - profile.persona_is_funder = True - elif persona == 'persona_is_hunter': - profile.persona_is_hunter = True - profile.save() - else: - return JsonResponse( - {'error': _('You must be authenticated')}, - status=401) + if request.user.is_authenticated: + profile = request.user.profile if hasattr(request.user, 'profile') else None + access_token = request.POST.get('access_token') + persona = request.POST.get('persona') + if persona == 'persona_is_funder': + profile.persona_is_funder = True + elif persona == 'persona_is_hunter': + profile.persona_is_hunter = True + profile.save() else: - print('no ajax') - raise Http404 + return JsonResponse( + {'error': _('You must be authenticated')}, + status=401) + return JsonResponse( { diff --git a/app/retail/templates/settings/account.html b/app/retail/templates/settings/account.html index 5ed1c75cba0..05cb7cf567f 100644 --- a/app/retail/templates/settings/account.html +++ b/app/retail/templates/settings/account.html @@ -54,7 +54,7 @@
{% trans "Account type" %}
-

{% trans "Let us know so we could optimize the best experience for you!" %}

+

{% trans "Let us know your account type so we can optimize your experience" %}

From ac1401f6395a00d82616a608008803d48132f2f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Octavio=20Amuch=C3=A1stegui?= Date: Tue, 16 Jul 2019 12:29:01 -0300 Subject: [PATCH 22/24] add h1 to explorer (#4789) --- app/dashboard/templates/dashboard/index.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/dashboard/templates/dashboard/index.html b/app/dashboard/templates/dashboard/index.html index 25ebc87de3c..e923b73e4c6 100644 --- a/app/dashboard/templates/dashboard/index.html +++ b/app/dashboard/templates/dashboard/index.html @@ -71,6 +71,9 @@
{% endif %} From c1ef972f57bc8892beb8d8fe1599270f57a34dc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Octavio=20Amuch=C3=A1stegui?= Date: Wed, 17 Jul 2019 01:14:06 -0300 Subject: [PATCH 23/24] Check funds before popup metamask (#4742) * add balance checker * add featured bounties * fix msg when featured with token --- app/assets/v2/js/pages/new_bounty.js | 114 ++++++++++++++++++--------- 1 file changed, 75 insertions(+), 39 deletions(-) diff --git a/app/assets/v2/js/pages/new_bounty.js b/app/assets/v2/js/pages/new_bounty.js index fdff4db4f13..8a442eceb85 100644 --- a/app/assets/v2/js/pages/new_bounty.js +++ b/app/assets/v2/js/pages/new_bounty.js @@ -554,13 +554,7 @@ $('#submitBounty').validate({ var isETH = tokenAddress == '0x0000000000000000000000000000000000000000'; var token_contract = web3.eth.contract(token_abi).at(tokenAddress); var account = web3.eth.coinbase; - - if (!isETH) { - check_balance_and_alert_user_if_not_enough( - tokenAddress, - amount, - 'You do not have enough tokens to fund this bounty.'); - } + let amountNoDecimal = amount; amount = amount * decimalDivisor; // Create the bounty object. @@ -698,6 +692,7 @@ $('#submitBounty').validate({ indicateMetamaskPopup(true); if (error) { _alert({ message: gettext('Unable to pay bounty fee. Please try again.') }, 'error'); + unloading_button($('.js-submit')); } else { deductBountyAmount(fee, txnId); } @@ -794,12 +789,69 @@ $('#submitBounty').validate({ }); }; - if ($("input[type='radio'][name='repo_type']:checked").val() == 'private' && $('#issueNDA')[0].files[0]) { - uploadNDA(); - } else if (data.featuredBounty) { - payFeaturedBounty(); + function processBounty() { + if ($("input[type='radio'][name='repo_type']:checked").val() == 'private' && $('#issueNDA')[0].files[0]) { + uploadNDA(); + } else if (data.featuredBounty) { + payFeaturedBounty(); + } else { + do_bounty(); + } + } + + if (check_balance_and_alert_user_if_not_enough(tokenAddress, amountNoDecimal)) { + processBounty(); } else { - do_bounty(); + return unloading_button($('.js-submit')); + } + + function check_balance_and_alert_user_if_not_enough(tokenAddress, amount, msg) { + const token_contract = web3.eth.contract(token_abi).at(tokenAddress); + const from = web3.eth.coinbase; + const token_details = tokenAddressToDetails(tokenAddress); + const token_decimals = token_details['decimals']; + const token_name = token_details['name']; + let total = parseFloat(amount) + + parseFloat((parseFloat(amount) * FEE_PERCENTAGE).toFixed(4)) + + (data.featuredBounty ? ethFeaturedPrice : 0); + + const checkBalance = (balance, total, token_name) => { + + if (parseFloat(total) > balance) { + let isFeaturedToken = token_name !== 'ETH' && data.featuredBounty; + + total = isFeaturedToken ? total - ethFeaturedPrice : total; + const balance_rounded = Math.round(balance * 10) / 10; + let msg = gettext('You do not have enough tokens to fund this bounty. You have ') + + balance_rounded + ' ' + token_name + ' ' + gettext(' but you need ') + total + + ' ' + token_name; + + if (isFeaturedToken) { + msg += ` + ${ethFeaturedPrice} ETH`; + } + _alert(msg, 'warning'); + } else { + return processBounty(); + } + }; + var walletBalance; + + if (tokenAddress == '0x0000000000000000000000000000000000000000') { + let ethBalance = getBalance(from); + + ethBalance.then( + function(result) { + walletBalance = result.toNumber() / Math.pow(10, token_decimals); + return checkBalance(walletBalance, total, token_name); + } + ); + } else { + token_contract.balanceOf.call(from, function(error, result) { + if (error) return; + walletBalance = result.toNumber() / Math.pow(10, token_decimals); + return checkBalance(walletBalance, total, token_name); + }); + } } } }); @@ -815,34 +867,18 @@ $('[name=permission_type]').on('change', function() { } }); -/** - * Alerts funder if they don't have enough tokens while attempting to - * fund a bounty. - * @param {String} tokenAddress - * @param {Number} amount - */ -function check_balance_and_alert_user_if_not_enough(tokenAddress, amount) { - const token_contract = web3.eth.contract(token_abi).at(tokenAddress); - const from = web3.eth.coinbase; - const token_details = tokenAddressToDetails(tokenAddress); - const token_decimals = token_details['decimals']; - const token_name = token_details['name']; - - token_contract.balanceOf.call(from, function(error, result) { - if (error) return; - const balance = result.toNumber() / Math.pow(10, token_decimals); - const balance_rounded = Math.round(balance * 10) / 10; - const total = parseFloat(amount) + parseFloat((parseFloat(amount) * FEE_PERCENTAGE).toFixed(4)); - - if (parseFloat(total) > balance) { - const msg = gettext('You do not have enough tokens to fund this bounty. You have ') + - balance_rounded + ' ' + token_name + ' ' + gettext(' but you need ') + amount + - ' ' + token_name; - - _alert(msg, 'warning'); - } + +var getBalance = (address) => { + return new Promise (function(resolve, reject) { + web3.eth.getBalance(address, function(error, result) { + if (error) { + reject(error); + } else { + resolve(result); + } + }); }); -} +}; let usdFeaturedPrice = $('.featured-price-usd').text(); let ethFeaturedPrice; From f6e1f2eda147b9f59c20cf642170063b1bd7b1d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Octavio=20Amuch=C3=A1stegui?= Date: Wed, 17 Jul 2019 01:27:51 -0300 Subject: [PATCH 24/24] fix bad rounded value (#4788) --- app/assets/v2/js/shared.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/app/assets/v2/js/shared.js b/app/assets/v2/js/shared.js index 584d226f1d5..8dab273a350 100644 --- a/app/assets/v2/js/shared.js +++ b/app/assets/v2/js/shared.js @@ -1131,9 +1131,7 @@ function renderBountyRowsFromResults(results, renderForExplorer) { decimals = relatedTokenDetails.decimals; } - const divisor = Math.pow(10, decimals); - - result['rounded_amount'] = normalizeAmount(result['value_in_token'] / divisor, decimals); + result['rounded_amount'] = normalizeAmount(result['value_in_token'], decimals); const crowdfunding = result['additional_funding_summary']; @@ -1231,7 +1229,7 @@ function renderBountyRowsFromResults(results, renderForExplorer) { } else { result['hidden'] = (i > 4); } - + html += tmpl.render(result); } return html; @@ -1272,7 +1270,7 @@ const renderFeaturedBountiesFromResults = (results, renderForExplorer) => { decimals = relatedTokenDetails.decimals; } - result['rounded_amount'] = normalizeAmount(result['value_in_token'] / divisor, decimals); + result['rounded_amount'] = normalizeAmount(result['value_in_token'], decimals); html += tmpl.render(result); } @@ -1385,7 +1383,7 @@ function toggleExpandableBounty(evt, selector) { } function normalizeAmount(amount, decimals) { - return Math.round(amount * 10 ** decimals) / 10 ** decimals; + return Math.round((parseInt(amount) / Math.pow(10, decimals)) * 1000) / 1000; } function newTokenTag(amount, tokenName, tooltipInfo, isCrowdfunded) {