Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stable -> master #5487

Merged
merged 21 commits into from
Nov 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions app/app/templates/shared/messages.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
document.messages = []
{% for message in messages %}
if (document.messages.indexOf('{{ message }}') == -1) {
setTimeout(function(){
_alert({message: gettext('{{ message }}')}, '{{ message.tags }}');
}, 1000);
document.messages.push('{{ message }}');
}
{% endfor %}
Expand Down
14 changes: 11 additions & 3 deletions app/app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@
# quests
re_path(r'^quests/?$', quests.views.index, name='quests_index'),
re_path(r'^quests/next?$', quests.views.next_quest, name='next_quest'),
re_path(r'^quests/(?P<obj_id>\d+)/feedback', quests.views.feedback, name='quest_feedback'),
re_path(r'^quests/(?P<obj_id>\d+)/(?P<name>\w*)', quests.views.details, name='quest_details'),
re_path(r'^quests/new/?', quests.views.editquest, name='newquest'),
re_path(r'^quests/edit/(?P<pk>\d+)/?', quests.views.editquest, name='editquest'),
Expand All @@ -187,7 +188,11 @@
path('hackathon/onboard/<str:hackathon>/', dashboard.views.hackathon_onboard, name='hackathon_onboard'),
path('hackathon/projects/<str:hackathon>/', dashboard.views.hackathon_projects, name='hackathon_projects'),
path('modal/new_project/<int:bounty_id>/', dashboard.views.hackathon_get_project, name='hackathon_get_project'),
path('modal/new_project/<int:bounty_id>/<int:project_id>/', dashboard.views.hackathon_get_project, name='hackathon_edit_project'),
path(
'modal/new_project/<int:bounty_id>/<int:project_id>/',
dashboard.views.hackathon_get_project,
name='hackathon_edit_project'
),
path('modal/save_project/', dashboard.views.hackathon_save_project, name='hackathon_save_project'),
re_path(r'^hackathon/?$/?', dashboard.views.hackathon, name='hackathon_idx'),
re_path(r'^hackathon/(.*)?$', dashboard.views.hackathon, name='hackathon_idx2'),
Expand Down Expand Up @@ -620,8 +625,11 @@
]

urlpatterns += [
re_path(r'^([a-z|A-Z|0-9|\.](?:[a-z\d]|-(?=[a-z\d]))+)/([a-z|A-Z|0-9|\.]+)/?$', dashboard.views.profile, name='profile_min'),

re_path(
r'^([a-z|A-Z|0-9|\.](?:[a-z\d]|-(?=[a-z\d]))+)/([a-z|A-Z|0-9|\.]+)/?$',
dashboard.views.profile,
name='profile_min'
),
re_path(r'^([a-z|A-Z|0-9|\.](?:[a-z\d]|-(?=[a-z\d]))+)/?$', dashboard.views.profile, name='profile_min'),
]

Expand Down
12 changes: 12 additions & 0 deletions app/assets/v2/css/quests.css
Original file line number Diff line number Diff line change
Expand Up @@ -360,12 +360,24 @@ body.quest_battle .modal-backdrop {
display: none !important;
}

.br a {
display: inline-block;
padding: 5px 5px;
margin: 4px 4px;
background-color: rgba(256,256,256,0.3);
}

body.quest_battle a,
body.quest_battle div,
body.quest_battle p {
color: white;
}

.br a:hover {
background-color: rgba(256,256,256,0.7);
text-decoration: none;
}

#_hj_poll_container {
display: none;
}
Expand Down
3 changes: 2 additions & 1 deletion app/assets/v2/js/pages/bounty_details.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ var callbacks = {
if (!result.keywords || result.keywords.length == 0)
return [ 'issue_keywords', null ];

var keywords = result.keywords.split(',');

var keywords = result.keywords && result.keywords.split ? result.keywords.split(',') : result.keywords;
var tags = [];

keywords.forEach(function(keyword) {
Expand Down
27 changes: 27 additions & 0 deletions app/assets/v2/js/pages/quests.helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ var toggle_character_class = async function(sel, classes) {
function typeWriter() {
if (document.typewriter_i == 0) {
document.typewriter_offset = 0;
document.is_typewriter = true;
}
if (document.typewriter_offset + document.typewriter_i < document.typewriter_txt.length) {
var char = document.typewriter_txt.charAt(document.typewriter_i);
Expand All @@ -84,9 +85,17 @@ function typeWriter() {
document.getElementById(document.typewriter_id).innerHTML += char;
document.typewriter_i++;
setTimeout(typeWriter, document.typewriter_speed);
} else {
document.is_typewriter = false;
}
}

var wait_for_typewriter = async function() {
while (document.is_typewriter) {
await sleep(100);
}
};

var get_midi = function(name) {
return '/static/v2/audio/' + name + '.mid';
};
Expand Down Expand Up @@ -194,6 +203,24 @@ $(document).ready(function() {
});


$('.give_feedback').on('click', async function(e) {
e.preventDefault();
var feedback = prompt('Any comments for the quest author? (optional)', 'Is question #3 wrong? I tried everyhing!');
var polarity = $(this).data('direction');

var params = {
'polarity': polarity,
'feedback': feedback
};
var url = document.quest_feedback_url;

$.post(url, params, function(response) {
_alert('Thank you for your feedback on this quest.', 'success');
$('#vote_container').remove();
});
});


if (document.quest) {
start_quest();
}
Expand Down
29 changes: 17 additions & 12 deletions app/assets/v2/js/pages/quests.quest.quiz_style.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ var advance_to_state = async function(new_state) {
// -- individual transitions callbacks --

// 0 to 1
var new_html;

if (old_state == 0 && new_state == 1) {
await sleep(1000);
await $('#header').html('Quest Intro');
Expand All @@ -173,17 +175,18 @@ var advance_to_state = async function(new_state) {
document.typewriter_i = 0;
document.typewriter_txt = document.quest.game_schema.intro;
document.typewriter_speed = 30;

typeWriter();
await wait_for_typewriter();

var kudos_reward_html = " <BR><BR> If you're successful in this quest, you'll earn this limited edition <strong>" + document.kudos_reward['name'] + "</strong> Kudos: <BR> <BR> <img style='height: 250px;width: 220px;' src=" + document.kudos_reward['img'] + '>';

setTimeout(function() {
var new_html = $('#desc').html() + kudos_reward_html;
new_html = $('#desc').html() + kudos_reward_html;

$('#desc').html(new_html);
}, 4500);
$('#desc').html(new_html);

await $('#desc').removeClass('hidden').fadeIn();
await sleep(4000);
await sleep(1000);
await $('#cta_button a').html('Continue 🤟');
await $('#cta_button').removeClass('hidden').fadeIn();
}/* 1 to 2 */ else if (old_state == 1) {
Expand All @@ -201,7 +204,8 @@ var advance_to_state = async function(new_state) {
document.typewriter_txt = document.quest.game_schema.rules;
document.typewriter_speed = 50;
typeWriter();
await sleep(1500);
await wait_for_typewriter();
await sleep(500);
await $('#enemy').removeClass('hidden');
await toggle_character_class($('#enemy'), [ 'heal', 'harm' ]);
await $('#cta_button a').html('Got It 🤙');
Expand All @@ -224,19 +228,20 @@ var advance_to_state = async function(new_state) {
html += '<li><a href=' + ele.url + ' target=new>' + ele.title + '</a></li>';
}
html += '<BR> Take a moment and read through them. You will have limited time to look things up when the quest starts.';
setTimeout(function() {
var new_html = $('#desc').html() + html;

$('#desc').html(new_html);
}, 5000);

document.typewriter_id = 'desc';
document.typewriter_i = 0;
document.typewriter_txt = text;
document.typewriter_speed = 50;
typeWriter();

await $('#desc').removeClass('hidden').fadeIn();
await sleep(1000);
await wait_for_typewriter();
new_html = $('#desc').html() + html;

$('#desc').html(new_html);

await sleep(100);
await $('#cta_button a').html('Got It 🤙');
await $('#cta_button').removeClass('hidden').fadeIn();
}/* 3 to 4 */ else if (old_state == 3) {
Expand Down
2 changes: 1 addition & 1 deletion app/dashboard/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ def process_bounty_changes(old_bounty, new_bounty):
# Send an Email if this is a LowBall bounty
try:
if(not old_bounty or old_bounty.value_in_usdt != new_bounty.value_in_usdt):
if is_lowball_bounty(new_bounty.value_in_usdt):
if is_lowball_bounty(new_bounty.value_in_usdt) and new_bounty.network == 'mainnet':
notify_of_lowball_bounty(new_bounty)
except Exception as e:
logger.error(f'{e} during check for Lowball Bounty')
Expand Down
2 changes: 1 addition & 1 deletion app/dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2834,7 +2834,7 @@ def calc_reliability_ranking(self):

#calculate base rating
num_earnings = self.earnings.count() + self.sent_earnings.count()
if num_earnings == 0:
if num_earnings < 2:
return "Unproven"

if num_earnings > high_threshold:
Expand Down
4 changes: 2 additions & 2 deletions app/dashboard/templates/dashboard/hackathon/projects.html
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ <h1>{{hackathon.name}} Projects</h1>
{% if project.logo %}
<img class="card-project-logo m-auto mw-100 rounded shadow" height="200" width="200" src="{{MEDIA_URL}}{{project.logo}}" alt="Hackathon logo" />
{% else %}
<img class="card-project-logo m-auto mw-100 rounded shadow" height="200" width="200" src="{% firstof project.bounty.admin_override_org_logo or project.bounty.avatar_url %}" alt="Hackathon logo" />
<img class="card-project-logo m-auto mw-100 rounded shadow" height="200" width="200" src="{{ project.bounty.avatar_url }}" alt="{{project.bounty.org_name}}" />
{% endif %}
</div>
<div class="card-body">
Expand All @@ -179,7 +179,7 @@ <h5 class="card-title text-uppercase">{{ project.name }}</h5>
</div>
<div class="font-smaller-2">
<b class="text-muted">Sponsor</b>
<img class="" width="20" src="{% firstof project.bounty.admin_override_org_logo or project.bounty.avatar_url %}" alt="Hackathon logo" />
<img class="" width="20" src="{{ project.bounty.avatar_url }}" alt="{{project.bounty.org_name}}" />
<a href="{% url 'profile' project.bounty.org_name %}">{{project.bounty.org_name}}</a>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/dashboard/templates/shared/add_kudos.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</div>
<input type="hidden" name="keywords" value="{{keywords}}">
<div class="my-2">
<select name="{{name}}" filter_by_address="{{filter_by_address}}" class="kudos-search custom-select gc-border-blue" id="kudos-search">
<select name="{{name}}" filter_by_address="{{filter_by_address}}" class="kudos-search custom-select gc-border-blue">
<option></option>
</select>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/kudos/templates/kudos_details.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
{% endif %}
<h3 id="kudosName" class="kudos-details__title">{{ kudos.ui_name }} {% if kudos.generation %}<small class="lead">Gen {{ kudos.generation }}</small>{% endif %}</h3>
<div>Owner Address: <a target="_blank" href="https://etherscan.io/address/{{ kudos.owner_address }}" class="kudos-details__address" title="{{ kudos.owner_address }}">{{ kudos.owner_address|humanize_address }}</a></div>
{% if kudos.quests_reward %}
{% if kudos.quests_reward.count %}
Reward for beating
{% for quest in kudos.quests_reward.all %}
<a href="{{quest.url}}">{{quest.title}} Quest</a>
Expand Down
3 changes: 2 additions & 1 deletion app/kudos/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,8 +707,9 @@ def redeem_bulk_coupon(coupon, profile, address, ip_address, save_addr=False):
# send email
maybe_market_kudos_to_email(kudos_transfer)
except Exception as e:
logger.exception(e)
error = "Could not redeem your kudos. Please try again soon."
if "replacement transaction underpriced" in str(e):
error = "There is already an airdrop transfer in progress. Please try again in a minute or two.. (note: in the future we will add 'queue'-ing so you dont have to resubmit, as soon as this ticket (https://github.com/gitcoinco/web/issues/4976) is deployed)"
return None, error, None

return True, None, kudos_transfer
Expand Down
22 changes: 22 additions & 0 deletions app/marketing/mails.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,28 @@ def new_grant_admin(grant):
translation.activate(cur_language)


def send_user_feedback(quest, feedback, user):
to_email = quest.creator.email
from_email = user.email
cur_language = translation.get_language()
try:
setup_lang(to_email)
subject = f"New Gitcoin Quest Feedback: {quest.title}"
body_str = f"quest: {quest.title}\nurl: {quest.url}\nedit: {quest.edit_url}\n\n> {feedback}\n\nfrom: {user.email} ( {user.profile.url} )"
body = f"{body_str}"
if not should_suppress_notification_email(to_email, 'quest'):
send_mail(
from_email,
to_email,
subject,
body,
from_name=f"@{user.profile.handle} on gitcoin.co",
categories=['admin', func_name()],
)
finally:
translation.activate(cur_language)


def new_quest_request(quest, is_edit):
to_email = settings.PERSONAL_CONTACT_EMAIL
from_email = settings.SERVER_EMAIL
Expand Down
10 changes: 0 additions & 10 deletions app/marketing/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,6 @@ def email_settings(request, key):
if request.POST and request.POST.get('submit'):
email = request.POST.get('email')
level = request.POST.get('level')
preferred_language = request.POST.get('preferred_language')
validation_passed = True
try:
email_in_use = User.objects.filter(email=email) | User.objects.filter(profile__email=email)
Expand All @@ -326,16 +325,7 @@ def email_settings(request, key):
print(e)
validation_passed = False
msg = str(e)
if preferred_language:
if preferred_language not in [i[0] for i in settings.LANGUAGES]:
msg = _('Unknown language')
validation_passed = False
if validation_passed:
if profile:
profile.pref_lang_code = preferred_language
profile.save()
request.session[LANGUAGE_SESSION_KEY] = preferred_language
translation.activate(preferred_language)
if es:
key = get_or_save_email_subscriber(email, 'settings')
es.preferences['level'] = level
Expand Down
26 changes: 24 additions & 2 deletions app/quests/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
from django.utils.safestring import mark_safe

# Register your models here.
from .models import Quest, QuestAttempt, QuestPointAward
from .models import Quest, QuestAttempt, QuestFeedback, QuestPointAward


class QuestAdmin(admin.ModelAdmin):
raw_id_fields = ['kudos_reward', 'unlocked_by', 'creator']
ordering = ['-id']
list_display = ['created_on', '__str__']
readonly_fields = ['background_preview']
readonly_fields = ['feedback','background_preview']

def response_change(self, request, obj):
if "_approve_quest" in request.POST:
Expand Down Expand Up @@ -41,6 +41,20 @@ def response_change(self, request, obj):
self.message_user(request, f"Quest Approved + Points awarded + Made Live.")
return super().response_change(request, obj)

def feedback(self, instance):
fb = instance.feedbacks
html = f"""
<pre>
ratio: {fb['ratio']}

stats: {fb['stats']}

feedback: {fb['feedback']}

</pre>
"""
return mark_safe(html)

def background_preview(self, instance):
html = ''
for ext in ['png', 'jpg']:
Expand All @@ -54,11 +68,19 @@ class QuestAttemptAdmin(admin.ModelAdmin):
ordering = ['-id']
list_display = ['created_on', '__str__']


class QuestFeedbackAdmin(admin.ModelAdmin):
raw_id_fields = ['quest', 'profile']
ordering = ['-id']
list_display = ['created_on', '__str__']


class QuestPointAwardAdmin(admin.ModelAdmin):
raw_id_fields = ['questattempt', 'profile']
ordering = ['-id']
list_display = ['created_on', '__str__']

admin.site.register(QuestFeedback, QuestFeedbackAdmin)
admin.site.register(QuestPointAward, QuestPointAwardAdmin)
admin.site.register(Quest, QuestAdmin)
admin.site.register(QuestAttempt, QuestAttemptAdmin)
4 changes: 3 additions & 1 deletion app/quests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,14 @@ def get_base_quest_view_params(user, quest):
"""
profile = user.profile if user.is_authenticated else None
attempts = quest.attempts.filter(profile=profile) if profile else QuestAttempt.objects.none()

is_owner = quest.creator.pk == user.profile.pk if user.is_authenticated else False
params = {
'quest': quest,
'hide_col': True,
'attempt_count': attempts.count() + 1,
'success_count': attempts.filter(success=True).count(),
'is_owner': is_owner,
'is_owner_or_staff': is_owner or user.is_staff,
'body_class': 'quest_battle',
'title': "Play the *" + quest.title + (f"* Gitcoin Quest and win a *{quest.kudos_reward.humanized_name}* Kudos" if quest.kudos_reward else ""),
'avatar_url': quest.avatar_url_png,
Expand Down
Loading