Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/stable'
Browse files Browse the repository at this point in the history
  • Loading branch information
thelostone-mc committed Dec 9, 2020
2 parents 37efe80 + 1aefe70 commit 6ffe770
Show file tree
Hide file tree
Showing 13 changed files with 105 additions and 53 deletions.
16 changes: 14 additions & 2 deletions app/assets/v2/js/grants/_detail-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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');

Expand Down Expand Up @@ -218,6 +223,10 @@ Vue.mixin({
});
});
},
changeColor() {
let vm = this;
vm.grant.image_css = `background-color: ${vm.logoBackground};`
},
onFileChange(e) {
let vm = this;

Expand Down Expand Up @@ -324,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');
}

Expand Down Expand Up @@ -427,6 +436,7 @@ Vue.component('grant-details', {
isStaff: isStaff,
logo: null,
logoPreview: null,
logoBackground: null,
relatedGrants: [],
rows: 0,
perPage: 4,
Expand Down Expand Up @@ -483,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: {
Expand Down
3 changes: 2 additions & 1 deletion app/assets/v2/js/pages/quests.helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ 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'
Expand Down
1 change: 1 addition & 0 deletions app/economy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion app/grants/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/grants/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion app/grants/templates/grants/cart-vue.html
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ <h2 class="middle-line mb-3"><span class="text-muted font-body">or</span></h2>

{% comment %} ===================== START ZKSYNC SCRIPTS ====================== {% endcomment %}
<script type="text/javascript" src="https://cdn.ethers.io/lib/ethers-5.0.umd.min.js"></script>
<script type="text/javascript" src="https://unpkg.com/[email protected].9/dist/main.js"></script>
<script type="text/javascript" src="https://unpkg.com/[email protected].10/dist/main.js"></script>
{% comment %} ====================== END ZKSYNC SCRIPTS ======================= {% endcomment %}

<script src="{% static "v2/js/lib/bootstrap-vue.min.js" %}"></script>
Expand Down
22 changes: 20 additions & 2 deletions app/grants/templates/grants/detail/template-grant-details.html
Original file line number Diff line number Diff line change
Expand Up @@ -326,13 +326,16 @@ <h5 class="font-weight-bold mb-3">Verify Grant Ownership with Twitter</h5>
<label class="font-caption letter-spacing text-black-60 text-uppercase" for="logo">
Project Logo
</label>

<div class="form__drop mt-0" id="js-drop">
<span v-if="!logoPreview">Drag & Drop or Browse</span>
<b-img-lazy v-if="logoPreview" id="preview" class="w-100 img-edit" :src="logoPreview" :class="{'blur-img':imgTransition}"></b-img-lazy>
<b-img-lazy v-if="logoPreview" id="preview" class="w-100 img-edit" :style="grant.image_css" :src="logoPreview" :class="{'blur-img':imgTransition}"></b-img-lazy>
<b-form-file @change="onFileChange($event)" v-model="logo" :state="Boolean(logo)" plain accept="image/*"></b-form-file>
</div>
</div>
<div class="col-12 mb-3 d-flex align-items-center">
<label class="font-caption letter-spacing text-black-60 text-uppercase mb-0 mr-3" for="title">Logo background color</label>
<input type="color" v-model="logoBackground" @input="changeColor">
</div>
<div class="col-12 mb-3">
<label class="font-caption letter-spacing text-black-60 text-uppercase" for="title">Title</label>
<span class="font-smaller-6 badge badge-greylight text-capitalize ml-2">Required</span>
Expand Down Expand Up @@ -514,6 +517,21 @@ <h4 class="alert-heading pt-2 mb-2">Cancel Your Grant</h4>
.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"
Expand Down
6 changes: 5 additions & 1 deletion app/grants/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('@')

Expand Down Expand Up @@ -2046,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],
Expand Down
9 changes: 8 additions & 1 deletion app/kudos/templates/kudos_marketplace.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@

<section class="container mt-5 pb-5 loader-container">
<div class="row justify-content-between p-3">
<div class="">{{listings.count}} Kudos available on <strong>{{ network }}</strong></div>
<div class="">{{listings.count}} Kudos available on <strong>{{ network }}</strong>
{% if network == 'mainnet' %}
<a href="/kudos/marketplace?q={{q}}&network=xdai">(Switch to xdai)
{% endif %}
{% if network == 'xdai' %}
<a href="/kudos/marketplace?q={{q}}&network=mainnet">(Switch to mainnet)
{% endif %}
</div>
{% if listings %}
<div>
<label for="">{% trans 'Sort by:' %}</label>
Expand Down
11 changes: 6 additions & 5 deletions app/kudos/templates/shared/kudos_searchbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<div class="input-group">

<input type="text" list="kudos-suggestions" class="form-control form-control-lg" name="q" id="kudos-search" placeholder="{% trans "Search for Kudos" %}">
<input type="hidden" name=network value={{network}}>
<datalist id="kudos-suggestions">
<option>rare</option>
<option>common</option>
Expand All @@ -43,11 +44,11 @@
</div>
<div class="mt-3 white">
<span class="white">Search suggestions:</span>
<a href="{% url 'kudos_marketplace' %}?q=rare">rare</a> -
<a href="{% url 'kudos_marketplace' %}?q=common">common</a> -
<a href="{% url 'kudos_marketplace' %}?q=ninja">ninja</a> -
<a href="{% url 'kudos_marketplace' %}?q=soft skills">soft skills</a> -
<a href="{% url 'kudos_marketplace' %}?q=programming">programming</a>
<a href="{% url 'kudos_marketplace' %}?q=rare&network={{network}}">rare</a> -
<a href="{% url 'kudos_marketplace' %}?q=common&network={{network}}">common</a> -
<a href="{% url 'kudos_marketplace' %}?q=ninja&network={{network}}">ninja</a> -
<a href="{% url 'kudos_marketplace' %}?q=soft skills&network={{network}}">soft skills</a> -
<a href="{% url 'kudos_marketplace' %}?q=programming&network={{network}}">programming</a>
</div>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions app/kudos/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')),
Expand Down
81 changes: 44 additions & 37 deletions app/quests/quest_types/quiz_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -54,44 +55,50 @@ def details(request, quest):

# process form submission
try:
payload = json.loads(request.body)
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)
Expand Down
2 changes: 1 addition & 1 deletion app/retail/templates/shared/onboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ <h2 class="h4 pt-0">Setup your profile</h2>
</div>
<div slot="body">

<p>Our tools are based on the principes of earn (πŸ’°), learn (πŸ“–), and meet (πŸ’¬).
<p>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.</p>
<div class="d-flex">
<div class="btn-group-toggle w-100">
Expand Down

0 comments on commit 6ffe770

Please sign in to comment.