From 5a5bd10ac1a47d895fe0d34a07266d7fef6bfec2 Mon Sep 17 00:00:00 2001 From: octavioamu Date: Mon, 7 Dec 2020 15:00:22 -0300 Subject: [PATCH 01/11] add bg picker for grant logo --- app/assets/v2/js/grants/_detail-component.js | 10 +++++++++ .../grants/detail/template-grant-details.html | 22 +++++++++++++++++-- app/grants/views.py | 4 ++++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/app/assets/v2/js/grants/_detail-component.js b/app/assets/v2/js/grants/_detail-component.js index 292ce03ce8f..090fdde7eb9 100644 --- a/app/assets/v2/js/grants/_detail-component.js +++ b/app/assets/v2/js/grants/_detail-component.js @@ -77,6 +77,10 @@ Vue.mixin({ data.logo = vm.logo; } + if (vm.logoBackground) { + data.image_css = `background-color: ${vm.logoBackground};`; + } + $.ajax({ type: 'post', url: apiUrlGrant, @@ -90,6 +94,7 @@ Vue.mixin({ vm.grant.last_update = new Date(); vm.grant.description_rich = JSON.stringify(vm.$refs.myQuillEditor.quill.getContents()); vm.grant.description = vm.$refs.myQuillEditor.quill.getText(); + vm.grant.image_css = `background-color: ${vm.logoBackground};`; vm.$root.$emit('bv::toggle::collapse', 'sidebar-grant-edit'); _alert('Updated grant.', 'success'); @@ -218,6 +223,10 @@ Vue.mixin({ }); }); }, + changeColor() { + let vm = this; + vm.grant.image_css = `background-color: ${vm.logoBackground};` + }, onFileChange(e) { let vm = this; @@ -427,6 +436,7 @@ Vue.component('grant-details', { isStaff: isStaff, logo: null, logoPreview: null, + logoBackground: null, relatedGrants: [], rows: 0, perPage: 4, diff --git a/app/grants/templates/grants/detail/template-grant-details.html b/app/grants/templates/grants/detail/template-grant-details.html index 42a47379d04..e6da0872aad 100644 --- a/app/grants/templates/grants/detail/template-grant-details.html +++ b/app/grants/templates/grants/detail/template-grant-details.html @@ -326,13 +326,16 @@
Verify Grant Ownership with Twitter
-
Drag & Drop or Browse - +
+
+ + +
Required @@ -514,6 +517,21 @@

Cancel Your Grant

.grant-managment { grid-area: grant-managment; } + input[type=color]{ + width: 20px; + height: 20px; + border: none; + border-radius: 40px; + background: none; + padding: 0; + } + input[type="color"]::-webkit-color-swatch-wrapper { + padding: 0; + } + input[type="color"]::-webkit-color-swatch { + border: solid 1px rgb(58, 58, 58); + border-radius: 40px; + } .grid-template-sidebar { grid-template-areas: "grant-data" diff --git a/app/grants/views.py b/app/grants/views.py index 9936fdf6cfc..fab40c11db4 100644 --- a/app/grants/views.py +++ b/app/grants/views.py @@ -1556,6 +1556,10 @@ def grant_edit(request, grant_id): if logo: grant.logo = logo + image_css = request.POST.get('image_css', None) + if image_css: + grant.image_css = image_css + twitter_handle_1 = request.POST.get('handle1', '').strip('@') twitter_handle_2 = request.POST.get('handle2', '').strip('@') From 9ae2f2166dd8ec85fb6a3386dd2e0556492215f3 Mon Sep 17 00:00:00 2001 From: octavioamu Date: Mon, 7 Dec 2020 21:09:46 -0300 Subject: [PATCH 02/11] fix grants without description --- app/assets/v2/js/grants/_detail-component.js | 6 ++++-- app/grants/models.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/assets/v2/js/grants/_detail-component.js b/app/assets/v2/js/grants/_detail-component.js index 090fdde7eb9..a62af0f822b 100644 --- a/app/assets/v2/js/grants/_detail-component.js +++ b/app/assets/v2/js/grants/_detail-component.js @@ -333,7 +333,7 @@ Vue.mixin({ if (vm.grant.twitter_handle_2 && !(/^@?[a-zA-Z0-9_]{1,15}$/).test(vm.grant.twitter_handle_2)) { vm.$set(vm.errors, 'twitter_handle_2', 'Please enter your twitter handle e.g georgecostanza'); } - if (vm.grant.description_rich.length < 10) { + if (vm.grant.description_rich_edited.length < 10) { vm.$set(vm.errors, 'description', 'Please enter description for the grant'); } @@ -493,7 +493,9 @@ Vue.component('grant-details', { let vm = this; vm.grant.description_rich_edited = vm.grant.description_rich; - vm.editor.updateContents(JSON.parse(vm.grant.description_rich)); + if (vm.grant.description_rich_edited) { + vm.editor.updateContents(JSON.parse(vm.grant.description_rich)); + } vm.grantInCart(); }, watch: { diff --git a/app/grants/models.py b/app/grants/models.py index 30adbf9c22d..73ed18c06bb 100644 --- a/app/grants/models.py +++ b/app/grants/models.py @@ -816,7 +816,7 @@ def repr(self, user, build_absolute_uri): 'twitter_handle_1': self.twitter_handle_1, 'twitter_handle_2': self.twitter_handle_2, 'reference_url': self.reference_url, - 'github_project_url': self.github_project_url, + 'github_project_url': self.github_project_url or '', 'funding_info': self.funding_info, 'link_to_new_grant': self.link_to_new_grant.url if self.link_to_new_grant else self.link_to_new_grant, 'region': {'name':self.region, 'label':self.get_region_display()} if self.region and self.region != 'null' else None From 007113b116bcb9dd5dc16b17173b6040cb002823 Mon Sep 17 00:00:00 2001 From: owocki Date: Mon, 7 Dec 2020 22:08:31 -0700 Subject: [PATCH 03/11] https://github.com/gitcoinco/web/issues/8028 --- app/assets/v2/js/pages/quests.helpers.js | 4 +++- app/quests/quest_types/quiz_style.py | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/assets/v2/js/pages/quests.helpers.js b/app/assets/v2/js/pages/quests.helpers.js index b5df4c76582..5f38157003f 100644 --- a/app/assets/v2/js/pages/quests.helpers.js +++ b/app/assets/v2/js/pages/quests.helpers.js @@ -48,9 +48,11 @@ var post_state = async(data) => { const location = document.location.href.replace('#', ''); const settings = { method: 'POST', + cache: 'no-cache', headers: { Accept: 'application/json', - 'Content-Type': 'application/json' + 'Content-Type': 'application/json', + 'Answers': JSON.stringify(data), }, body: JSON.stringify(data) }; diff --git a/app/quests/quest_types/quiz_style.py b/app/quests/quest_types/quiz_style.py index daf9bf60835..420e28e3fd1 100644 --- a/app/quests/quest_types/quiz_style.py +++ b/app/quests/quest_types/quiz_style.py @@ -13,6 +13,7 @@ from django.utils import timezone from django.views.decorators.csrf import csrf_exempt +from json.decoder import JSONDecodeError from kudos.models import BulkTransferCoupon, BulkTransferRedemption, Token from quests.helpers import ( get_active_attempt_if_any, get_base_quest_view_params, get_leaderboard, max_ref_depth, process_start, process_win, @@ -54,7 +55,12 @@ def details(request, quest): # process form submission try: - payload = json.loads(request.body) + payload = {} + try: + payload = json.loads(request.body) + except JSONDecodeError: + payload = json.loads(request.headers['Answers']) + qn = payload.get('question_number') can_continue = True did_win = False From 0dda58be773c0bb52d057358abe155fee97d8f1e Mon Sep 17 00:00:00 2001 From: Aditya Anand M C Date: Tue, 8 Dec 2020 12:41:36 +0530 Subject: [PATCH 04/11] fix anon bug --- app/grants/tasks.py | 2 +- app/grants/views.py | 2 +- app/quests/quest_types/quiz_style.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/grants/tasks.py b/app/grants/tasks.py index 6e78a6999e9..d1c29ee39d9 100644 --- a/app/grants/tasks.py +++ b/app/grants/tasks.py @@ -217,7 +217,7 @@ def process_grant_contribution(self, grant_id, grant_slug, profile_id, package, profile.save() if 'anonymize_gitcoin_grants_contributions' in package: - profile.anonymize_gitcoin_grants_contributions = bool(package.get('anonymize_gitcoin_grants_contributions', False)) + profile.anonymize_gitcoin_grants_contributions = package.get('anonymize_gitcoin_grants_contributions') profile.save() activity_profile = profile if not profile.anonymize_gitcoin_grants_contributions else Profile.objects.get(handle='gitcoinbot') diff --git a/app/grants/views.py b/app/grants/views.py index fab40c11db4..066e057a87b 100644 --- a/app/grants/views.py +++ b/app/grants/views.py @@ -2050,7 +2050,7 @@ def bulk_fund(request): 'signature': request.POST.get('signature'), 'splitter_contract_address': request.POST.get('splitter_contract_address'), 'subscription_hash': request.POST.get('subscription_hash'), - 'anonymize_gitcoin_grants_contributions': request.POST.get('anonymize_gitcoin_grants_contributions'), + 'anonymize_gitcoin_grants_contributions': json.loads(request.POST.get('anonymize_gitcoin_grants_contributions', 'false')), # Values that vary by donation 'admin_address': request.POST.get('admin_address').split(',')[index], 'amount_per_period': request.POST.get('amount_per_period').split(',')[index], diff --git a/app/quests/quest_types/quiz_style.py b/app/quests/quest_types/quiz_style.py index 420e28e3fd1..92b9dc00773 100644 --- a/app/quests/quest_types/quiz_style.py +++ b/app/quests/quest_types/quiz_style.py @@ -3,6 +3,7 @@ import logging import random import re +from json.decoder import JSONDecodeError from django.conf import settings from django.contrib import messages @@ -13,7 +14,6 @@ from django.utils import timezone from django.views.decorators.csrf import csrf_exempt -from json.decoder import JSONDecodeError from kudos.models import BulkTransferCoupon, BulkTransferRedemption, Token from quests.helpers import ( get_active_attempt_if_any, get_base_quest_view_params, get_leaderboard, max_ref_depth, process_start, process_win, From b5c091eee58a25bb0de95595916b9b53c9dddc2f Mon Sep 17 00:00:00 2001 From: Matt Date: Tue, 8 Dec 2020 06:25:59 -0800 Subject: [PATCH 05/11] Bump zksync version (#8049) --- app/grants/templates/grants/cart-vue.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/grants/templates/grants/cart-vue.html b/app/grants/templates/grants/cart-vue.html index 4e78799da69..6eae8003f5c 100644 --- a/app/grants/templates/grants/cart-vue.html +++ b/app/grants/templates/grants/cart-vue.html @@ -757,7 +757,7 @@

or

{% comment %} ===================== START ZKSYNC SCRIPTS ====================== {% endcomment %} - + {% comment %} ====================== END ZKSYNC SCRIPTS ======================= {% endcomment %} From d90206089caf842b9bb6a6ac32bf8413bed528f6 Mon Sep 17 00:00:00 2001 From: Dan Lipert Date: Tue, 8 Dec 2020 23:33:21 +0900 Subject: [PATCH 06/11] fix typo in onboarding --- app/retail/templates/shared/onboard.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/retail/templates/shared/onboard.html b/app/retail/templates/shared/onboard.html index 6cef0968c43..c808fe8a47d 100644 --- a/app/retail/templates/shared/onboard.html +++ b/app/retail/templates/shared/onboard.html @@ -89,7 +89,7 @@

Setup your profile

-

Our tools are based on the principes of earn (💰), learn (📖), and meet (💬). +

Our tools are based on the principles of earn (💰), learn (📖), and meet (💬). Select the ones you are interested in. You can change it later in your settings.

From 5e22f4e69a0273f9abd840ba83fc6a77cbc4f41c Mon Sep 17 00:00:00 2001 From: owocki Date: Tue, 8 Dec 2020 12:46:49 -0700 Subject: [PATCH 07/11] better network state mgmt on kudos --- app/kudos/templates/kudos_marketplace.html | 9 ++++++++- app/kudos/templates/shared/kudos_searchbar.html | 11 ++++++----- app/kudos/views.py | 1 + 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/app/kudos/templates/kudos_marketplace.html b/app/kudos/templates/kudos_marketplace.html index fdd94d9fe0f..215f93d5422 100644 --- a/app/kudos/templates/kudos_marketplace.html +++ b/app/kudos/templates/kudos_marketplace.html @@ -17,7 +17,14 @@
diff --git a/app/kudos/views.py b/app/kudos/views.py index 8a4a33a0c8e..1e2c45af47c 100644 --- a/app/kudos/views.py +++ b/app/kudos/views.py @@ -175,6 +175,7 @@ def marketplace(request): 'is_outside': True, 'active': 'marketplace', 'title': title, + 'q': q, 'card_title': _('Each Kudos is a unique work of art.'), 'card_desc': _('It can be sent to highlight, recognize, and show appreciation.'), 'avatar_url': request.build_absolute_uri(static('v2/images/twitter_cards/tw_cards-06.png')), From 0bcaf1dd9b60ade26082ef2cbf8c159bf654aca5 Mon Sep 17 00:00:00 2001 From: owocki Date: Tue, 8 Dec 2020 14:37:02 -0700 Subject: [PATCH 08/11] fixes the way answers are submitted --- app/assets/v2/js/pages/quests.helpers.js | 2 +- app/quests/quest_types/quiz_style.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/v2/js/pages/quests.helpers.js b/app/assets/v2/js/pages/quests.helpers.js index 5f38157003f..bb587636592 100644 --- a/app/assets/v2/js/pages/quests.helpers.js +++ b/app/assets/v2/js/pages/quests.helpers.js @@ -52,7 +52,7 @@ var post_state = async(data) => { headers: { Accept: 'application/json', 'Content-Type': 'application/json', - 'Answers': JSON.stringify(data), + 'answers': JSON.stringify(data), }, body: JSON.stringify(data) }; diff --git a/app/quests/quest_types/quiz_style.py b/app/quests/quest_types/quiz_style.py index 92b9dc00773..45d8c49ba04 100644 --- a/app/quests/quest_types/quiz_style.py +++ b/app/quests/quest_types/quiz_style.py @@ -59,7 +59,7 @@ def details(request, quest): try: payload = json.loads(request.body) except JSONDecodeError: - payload = json.loads(request.headers['Answers']) + payload = json.loads(request.headers['answers']) qn = payload.get('question_number') can_continue = True From 600b1bde93b9924ff93390ddf101a70bea145f33 Mon Sep 17 00:00:00 2001 From: owocki Date: Tue, 8 Dec 2020 15:57:25 -0700 Subject: [PATCH 09/11] another pass at fixing the quest issue https://sentry.io/organizations/gitcoin/issues/2079867216/events/8af41c208ecb400e9e9fd1642417ba8f/?project=1398424&statsPeriod=14d --- app/assets/v2/js/pages/quests.helpers.js | 5 ++--- app/quests/quest_types/quiz_style.py | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/assets/v2/js/pages/quests.helpers.js b/app/assets/v2/js/pages/quests.helpers.js index bb587636592..9419076e67c 100644 --- a/app/assets/v2/js/pages/quests.helpers.js +++ b/app/assets/v2/js/pages/quests.helpers.js @@ -45,14 +45,13 @@ var random_taunt_effect = function(ele) { }; var post_state = async(data) => { - const location = document.location.href.replace('#', ''); + const location = document.location.href.replace('#', '') + '?answers=' + JSON.stringify(data); const settings = { method: 'POST', cache: 'no-cache', headers: { Accept: 'application/json', - 'Content-Type': 'application/json', - 'answers': JSON.stringify(data), + 'Content-Type': 'application/json' }, body: JSON.stringify(data) }; diff --git a/app/quests/quest_types/quiz_style.py b/app/quests/quest_types/quiz_style.py index 45d8c49ba04..120fb6f283a 100644 --- a/app/quests/quest_types/quiz_style.py +++ b/app/quests/quest_types/quiz_style.py @@ -59,7 +59,7 @@ def details(request, quest): try: payload = json.loads(request.body) except JSONDecodeError: - payload = json.loads(request.headers['answers']) + payload = json.loads(request.GET['answers']) qn = payload.get('question_number') can_continue = True From 53ae4bd48c1f6c1199ab8ada8649a63d07767d21 Mon Sep 17 00:00:00 2001 From: owocki Date: Tue, 8 Dec 2020 16:35:22 -0700 Subject: [PATCH 10/11] Revert "use blocknative without an API; according to Drew this is whta we should do" This reverts commit 187b4d538d3dfefe4f1af8609f7560301e09fe80. --- app/economy/utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/app/economy/utils.py b/app/economy/utils.py index ca1e831b082..384e16be819 100644 --- a/app/economy/utils.py +++ b/app/economy/utils.py @@ -128,6 +128,7 @@ def watch_txn(tx_id): import requests from django.conf import settings args = { + "apiKey": settings.BLOCKNATIVE_API, "hash": tx_id, "blockchain": "ethereum", "network": "main" From 1aefe703bf07d3801423c4cc7b215432bc243b43 Mon Sep 17 00:00:00 2001 From: owocki Date: Tue, 8 Dec 2020 16:56:34 -0700 Subject: [PATCH 11/11] still trying to track down the issue with https://github.com/gitcoinco/web/issues/8028#issuecomment-741206361 --- app/quests/quest_types/quiz_style.py | 85 ++++++++++++++-------------- 1 file changed, 43 insertions(+), 42 deletions(-) diff --git a/app/quests/quest_types/quiz_style.py b/app/quests/quest_types/quiz_style.py index 120fb6f283a..2151919b720 100644 --- a/app/quests/quest_types/quiz_style.py +++ b/app/quests/quest_types/quiz_style.py @@ -55,49 +55,50 @@ def details(request, quest): # process form submission try: - payload = {} - try: - payload = json.loads(request.body) - except JSONDecodeError: - payload = json.loads(request.GET['answers']) - - qn = payload.get('question_number') - can_continue = True - did_win = False - prize_url = False - if qn is not None and request.user.is_authenticated: - save_attempt = qn == 0 - if save_attempt: - process_start(request, quest) - else: - qa = get_active_attempt_if_any(request.user, quest, state=(qn-1)) - this_question = quest.questions[qn-1] - correct_answers = [ele['answer'] for ele in this_question['responses'] if ele['correct']] - their_answers = [unescape(ele) for ele in payload.get('answers')] - this_time_per_answer = time_per_answer - answer_level_seconds_to_respond = payload.get('seconds_to_respond', None) - if answer_level_seconds_to_respond: - this_time_per_answer = answer_level_seconds_to_respond - is_out_of_time = (timezone.now() - qa.modified_on).seconds > this_time_per_answer + time_per_answer_buffer - did_they_do_correct = set(correct_answers) == set(their_answers) or (this_question.get('any_correct', False) and len(their_answers)) - can_continue = did_they_do_correct and not is_out_of_time - if can_continue: - qa.state += 1 + if request.body or request.GET.get('answers'): + payload = {} + try: + payload = json.loads(request.body) + except JSONDecodeError: + payload = json.loads(request.GET['answers']) + + qn = payload.get('question_number') + can_continue = True + did_win = False + prize_url = False + if qn is not None and request.user.is_authenticated: + save_attempt = qn == 0 + if save_attempt: + process_start(request, quest) + else: + qa = get_active_attempt_if_any(request.user, quest, state=(qn-1)) + this_question = quest.questions[qn-1] + correct_answers = [ele['answer'] for ele in this_question['responses'] if ele['correct']] + their_answers = [unescape(ele) for ele in payload.get('answers')] + this_time_per_answer = time_per_answer + answer_level_seconds_to_respond = payload.get('seconds_to_respond', None) + if answer_level_seconds_to_respond: + this_time_per_answer = answer_level_seconds_to_respond + is_out_of_time = (timezone.now() - qa.modified_on).seconds > this_time_per_answer + time_per_answer_buffer + did_they_do_correct = set(correct_answers) == set(their_answers) or (this_question.get('any_correct', False) and len(their_answers)) + can_continue = did_they_do_correct and not is_out_of_time + if can_continue: + qa.state += 1 + qa.save() + did_win = can_continue and len(quest.questions) <= qn + if did_win: + prize_url = process_win(request, qa) qa.save() - did_win = can_continue and len(quest.questions) <= qn - if did_win: - prize_url = process_win(request, qa) - qa.save() - - response = { - "question": quest.questions_safe(qn), - "can_continue": can_continue, - "did_win": did_win, - "prize_url": prize_url, - } - response = JsonResponse(response) - #response['X-Frame-Options'] = x_frame_option - return response + + response = { + "question": quest.questions_safe(qn), + "can_continue": can_continue, + "did_win": did_win, + "prize_url": prize_url, + } + response = JsonResponse(response) + #response['X-Frame-Options'] = x_frame_option + return response except Exception as e: logger.exception(e)