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

mini CLR rounds on newsfeed - READY FOR REVIEW #5942

Merged
merged 20 commits into from
Feb 15, 2020
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: 3 additions & 0 deletions app/app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -755,3 +755,6 @@
RE_MARKET_LIMIT = env.int('RE_MARKET_LIMIT', default=2)
MINUTES_BETWEEN_RE_MARKETING = env.int('MINUTES_BETWEEN_RE_MARKETING', default=60)

MINICLR_ADDRESS = env('MINICLR_ADDRESS', default='0x00De4B13153673BCAE2616b67bf822500d325Fc3')
MINICLR_PRIVATE_KEY = env('MINICLR_PRIVATE_KEY', default='0x00De4B13153673BCAE2616b67bf822500d325Fc3')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably worth generating a throwaway keypair here for defaults


3 changes: 3 additions & 0 deletions app/app/travis.env
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ ENV=test
REDIS_URL=rediscache://localhost:6379/0?client_class=django_redis.client.DefaultClient
CACHEOPS_REDIS=redis://localhost:6379/0
GEOIP_PATH=/opt/GeoIP/
WEB3_HTTP_PROVIDER=https://rinkeby.infura.io/v3/e24d261245fa47d28f0bb4b0dda7a2cb
INFURA_USE_V3=True
INFURA_V3_PROJECT_ID=e24d261245fa47d28f0bb4b0dda7a2cb
1 change: 1 addition & 0 deletions app/app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@
retail.emails.no_applicant_reminder,
name='no_applicant_reminder'
),
re_path(r'^_administration/email/match_distribution$', retail.emails.match_distribution, name='match_distribution'),

# settings
re_path(r'^settings/email/(.*)', marketing.views.email_settings, name='email_settings'),
Expand Down
6 changes: 6 additions & 0 deletions app/assets/v2/css/activity_stream.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
.comment_container .fa-heart{
cursor: pointer;
}
.comment_container .fa-heart.open{
color: var(--gc-pink) !important;
}
#new_activity_notifier {
text-align: center;
background-color: #f5f5f9;
Expand Down
27 changes: 26 additions & 1 deletion app/assets/v2/css/town_square.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
.follow_button[member=true]{
display: none;
}
.tooltip-inner {
max-width: 450px;
}

.announce{
border-radius: 5px;

Expand Down Expand Up @@ -680,7 +687,25 @@ body.green.offer_view .announce {
margin-bottom: 2px;
margin-top: 2px;
}

.clr_container{
text-align: left;
}
.clr_container td{
font-size: 12px;
padding: 3px;
}
.clr_container tr.title{
background-color: #eee;
font-weight: bold;
}
.clr_container tr:nth-child(even){
background-color: #f5f5f5;
}
.clr_container tr img{
width: 50px;
height: 50px;
border-radius: 25px;
}
.townsquare_main .search-area {
padding-left: 0;
}
Expand Down
1 change: 1 addition & 0 deletions app/assets/v2/images/earnlearn.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/v2/images/rainbow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 29 additions & 5 deletions app/assets/v2/js/activity.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ $(document).ready(function() {
the_comment = urlify(the_comment);
the_comment = linkify(the_comment);
var timeAgo = timedifferenceCvrt(new Date(comment['created_on']));
var show_tip = document.contxt.is_alpha_tester || comment['tip_able'];
var show_tip = true;
var html = `
<div class="row p-2">
<div class="col-1 activity-avatar mt-1">
Expand All @@ -363,10 +363,13 @@ $(document).ready(function() {
<span class="grey"><a class=grey href="/profile/${comment['profile_handle']}">
@${comment['profile_handle']}
</a></span>
${show_tip ? `
<a href="#" class="tip_on_comment font-smaller-5 text-dark" data-pk="${comment['id']}" data-username="${comment['profile_handle']}"> ( <i class="fab fa-ethereum grey"></i> <span class="amount grey">${Math.round(100 * comment['tip_count_eth']) / 100}</span>)
</a>
` : ''}
${comment['match_this_round'] ? `
<span class="tip_on_comment" data-pk="${comment['id']}" data-username="${comment['profile_handle']}" style="border-radius: 3px; border: 1px solid white; color: white; background-color: black; cursor:pointer; padding: 2px; font-size: 10px;" data-placement="bottom" data-toggle="tooltip" data-html="true" title="@${comment['profile_handle']} is estimated to be earning ${comment['match_this_round']} in this week's CLR Round. <BR><BR><strong>Send a tip to @${comment['profile_handle']}</strong> to increase their take of the matching pool. <br><br>Want to learn more? Go to gitcoin.co/townsquare and checkout the CLR Matching Round Leaderboard.">
<i class="fab fa-ethereum mr-0" aria-hidden="true"></i>
$${comment['match_this_round']}
</span>

` : ' '}
</span>
<span class="d-none d-sm-inline grey font-smaller-5 float-right">
${timeAgo}
Expand All @@ -375,6 +378,15 @@ $(document).ready(function() {
<div class="activity_comments_main_comment">
${comment['comment']}
</div>
<span class="font-smaller-5 float-right">
${show_tip ? `
<span class="action">
<i class="far fa-heart grey"></i>
</span> |
<a href="#" class="tip_on_comment text-dark" data-pk="${comment['id']}" data-username="${comment['profile_handle']}"> <i class="fab fa-ethereum grey"></i> <span class="amount grey">${Math.round(100 * comment['tip_count_eth']) / 100}</span>
</a>
` : ''}
<span>
</div>

</div>
Expand Down Expand Up @@ -402,6 +414,18 @@ $(document).ready(function() {
});
};


// post comment activity
$(document).on('click', '.comment_container .fa-heart', function(e) {
e.preventDefault();
if ($(this).hasClass('open')) {
$(this).removeClass('open');
} else {
$(this).addClass('open');
}
});


// post comment activity
$(document).on('click', '.comment_activity', function(e) {
e.preventDefault();
Expand Down
5 changes: 3 additions & 2 deletions app/assets/v2/js/pages/join_tribe.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
const joinTribe = () => {
$('[data-jointribe]').each(function(index, elem) {

$(elem).on('click', function() {
$(elem).on('click', function(e) {
$(elem).attr('disabled', true);

e.preventDefault();
const tribe = $(elem).data('jointribe');
const url = `/tribe/${tribe}/join/`;
const sendJoin = fetchData (url, 'POST', {}, {'X-CSRFToken': $("input[name='csrfmiddlewaretoken']").val()});

$.when(sendJoin).then(function(response) {
$(elem).attr('disabled', false);
$(elem).attr('member', response.is_member);
response.is_member ? $(elem).text('Leave Tribe') : $(elem).text('Join Tribe');

}).fail(function(error) {
Expand Down
4 changes: 3 additions & 1 deletion app/dashboard/export.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from grants.models import Grant
from rest_framework import serializers

from .models import Activity, Bounty, FeedbackEntry, Tip
from grants.models import Grant


class ProfileExportSerializer(serializers.BaseSerializer):
"""Handle serializing the exported Profile object."""
Expand Down
16 changes: 15 additions & 1 deletion app/dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2022,6 +2022,7 @@ class Activity(SuperModel):
('beat_quest', 'Beat Quest'),
('created_quest', 'Created Quest'),
('updated_avatar', 'Updated Avatar'),
('mini_clr_payout', 'Mini CLR Payout'),
]

profile = models.ForeignKey(
Expand Down Expand Up @@ -2183,6 +2184,7 @@ def view_props(self):
'created_human_time',
'humanized_name',
'url',
'match_this_round',
]
activity = self.to_standard_dict(properties=properties)
activity['pk'] = self.pk
Expand Down Expand Up @@ -2558,6 +2560,16 @@ class Profile(SuperModel):
def quest_level(self):
return self.quest_attempts.filter(success=True).distinct('quest').count() + 1

@property
def match_this_round(self):
from townsquare.models import MatchRound
mr = MatchRound.objects.current().first()
if mr:
mr = mr.ranking.filter(profile=self).first()
if mr:
return mr.match_total
return 0

@property
def quest_caste(self):
castes = [
Expand Down Expand Up @@ -4602,8 +4614,10 @@ class TribeMember(SuperModel):
('pending', 'pending'),
('rejected', 'rejected'),
]
#from
profile = models.ForeignKey('dashboard.Profile', related_name='follower', on_delete=models.CASCADE)
org = models.ForeignKey('dashboard.Profile', related_name='org', on_delete=models.CASCADE)
# to
org = models.ForeignKey('dashboard.Profile', related_name='org', on_delete=models.CASCADE, null=True, blank=True)
leader = models.BooleanField(default=False, help_text=_('tribe leader'))
title = models.CharField(max_length=255, blank=True, default='')
status = models.CharField(
Expand Down
10 changes: 10 additions & 0 deletions app/dashboard/templates/profiles/header_details.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,13 @@ <h1 class="profile-header__handle">
<i class="fa fa-briefcase mr-2" aria-hidden="true"></i>{{ profile.job_status_verbose }}
</div>
{% endif %}

{% if profile.match_this_round %}
<div class="my-2" >
<span style="border-radius: 3px; border: 1px solid black; padding: 5px;" data-placement="bottom" data-toggle="tooltip" data-html="true" title="@{{profile.handle}} is estimated to be earning ${{profile.match_this_round|floatformat:2}} in this week's CLR Round. Want to learn more? Go to gitcoin.co/townsquare and checkout the CLR Matching Round Leaderboard.">
<i class="fab fa-ethereum mr-2" aria-hidden="true"></i>
${{profile.match_this_round|floatformat:2}} in Matching Payout This Week.
</span>
</div>
{% endif %}

6 changes: 6 additions & 0 deletions app/dashboard/tip_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ def send_tip_4(request):
metadata__address=destinationAccount,
metadata__salt=params['salt'],
)

is_authenticated_for_this_via_login = (tip.from_username and tip.from_username == from_username)
is_authenticated_for_this_via_ip = tip.ip == get_ip(request)
is_authed = is_authenticated_for_this_via_ip or is_authenticated_for_this_via_login
Expand All @@ -249,6 +250,11 @@ def send_tip_4(request):
)
tip.save()

from townsquare.models import MatchRound
mr = MatchRound.objects.current().first()
mr.process()


# notifications
maybe_market_tip_to_github(tip)
maybe_market_tip_to_slack(tip, 'New tip')
Expand Down
36 changes: 28 additions & 8 deletions app/marketing/mails.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@
render_bounty_request, render_bounty_startwork_expire_warning, render_bounty_unintersted, render_comment,
render_faucet_rejected, render_faucet_request, render_featured_funded_bounty, render_funder_payout_reminder,
render_funder_stale, render_gdpr_reconsent, render_gdpr_update, render_grant_cancellation_email,
render_grant_update, render_kudos_email, render_match_email, render_mention, render_new_bounty,
render_new_bounty_acceptance, render_new_bounty_rejection, render_new_bounty_roundup, render_new_grant_email,
render_new_supporter_email, render_new_work_submission, render_no_applicant_reminder, render_nth_day_email_campaign,
render_quarterly_stats, render_reserved_issue, render_share_bounty, render_start_work_applicant_about_to_expire,
render_start_work_applicant_expired, render_start_work_approved, render_start_work_new_applicant,
render_start_work_rejected, render_subscription_terminated_email, render_successful_contribution_email,
render_support_cancellation_email, render_thank_you_for_supporting_email, render_tip_email,
render_unread_notification_email_weekly_roundup, render_wallpost, render_weekly_recap,
render_grant_update, render_kudos_email, render_match_distribution, render_match_email, render_mention,
render_new_bounty, render_new_bounty_acceptance, render_new_bounty_rejection, render_new_bounty_roundup,
render_new_grant_email, render_new_supporter_email, render_new_work_submission, render_no_applicant_reminder,
render_nth_day_email_campaign, render_quarterly_stats, render_reserved_issue, render_share_bounty,
render_start_work_applicant_about_to_expire, render_start_work_applicant_expired, render_start_work_approved,
render_start_work_new_applicant, render_start_work_rejected, render_subscription_terminated_email,
render_successful_contribution_email, render_support_cancellation_email, render_thank_you_for_supporting_email,
render_tip_email, render_unread_notification_email_weekly_roundup, render_wallpost, render_weekly_recap,
)
from sendgrid.helpers.mail import Content, Email, Mail, Personalization
from sendgrid.helpers.stats import Category
Expand Down Expand Up @@ -810,6 +810,26 @@ def funder_payout_reminder(to_email, bounty, github_username, live):
return html


def match_distribution(mr):
from_email = settings.PERSONAL_CONTACT_EMAIL
subject = f"Match Distribution of ${mr.amount} for @{mr.profile.handle}"
html, text = render_match_distribution(mr)
try:
send_mail(
from_email,
to_email,
subject,
text,
html,
from_name="Gitcoin",
categories=['marketing', func_name()],
)
except Exception as e:
logger.warning(e)
return False
return html


def no_applicant_reminder(to_email, bounty):
from_email = settings.SERVER_EMAIL
subject = "Get more applicants on your bounty"
Expand Down
19 changes: 19 additions & 0 deletions app/retail/emails.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,15 @@ def render_funder_payout_reminder(**kwargs):
return response_html, response_txt


def render_match_distribution(mr):
params = {
'mr': mr,
}
response_html = premailer_transform(render_to_string("emails/match_distribution.html"))
response_txt = ''
return response_html, response_txt


def render_no_applicant_reminder(bounty):
params = {
'bounty': bounty,
Expand Down Expand Up @@ -1335,6 +1344,16 @@ def no_applicant_reminder(request):
return HttpResponse(response_html)


@staff_member_required
def match_distribution(request):
from townsquare.models import MatchRanking
mr = MatchRanking.objects.last()
response_html, _ = render_match_distribution(mr)
return HttpResponse(response_html)




@staff_member_required
def funder_stale(request):
"""Display the stale funder email template.
Expand Down
35 changes: 35 additions & 0 deletions app/retail/templates/emails/match_distribution.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{% extends 'emails/template.html' %}
{% comment %}
Copyright (C) 2017 Gitcoin Core

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

{% endcomment %}
{% load i18n humanize static %}

{% block content %}

<h1>{% trans "You've got ETH!" %}</h1>


<p style="color: #4A4A4A; line-height:2;">

You just got a distribution of {{mr.amount}} DAI via <a href="https://etherscan.io/tx/{{mr.payout_txid}}">{{mr.payout_txid}}</a>

</p>

<br>


{% endblock %}
17 changes: 12 additions & 5 deletions app/retail/templates/shared/activity.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,24 @@
</div>
</div>
<div class="col-10 col-sm-8 pl-4 px-sm-0 activity_detail">

<div>
<b>{% firstof row.profile.data.name or row.profile.handle %}</b>
<span class="grey"><a class="grey" href="/profile/{{ row.profile.handle }}">@{{ row.profile.handle }}</a></span>
<div class="">
<b>{% firstof row.profile.data.name or row.profile.handle %}</b>
<span class="grey"><a class="grey" href="/profile/{{ row.profile.handle }}">@{{ row.profile.handle }}</a></span>
{% if row.profile.match_this_round %}
<span style="border-radius: 3px; border: 1px solid white; color: white; background-color: black; padding: 2px; font-size: 10px;" data-placement="bottom" data-toggle="tooltip" data-html="true" title="@{{row.profile.handle}} is estimated to be earning ${{row.profile.match_this_round|floatformat:2}} in this week's CLR Round. <br><br>Want to learn more? Go to gitcoin.co/townsquare and checkout the CLR Matching Round Leaderboard.">
<i class="fab fa-ethereum mr-0" aria-hidden="true"></i>
${{row.profile.match_this_round|floatformat:2}}
</span>
{% endif %}
</div>
<div class="activity_detail_content font-body pb-2">
{% if row.activity_type == 'new_tip' %}
{% trans "tipped" %}
<a href="https://gitcoin.co/profile/{{ row.metadata.to_username }}" >
@{{ row.metadata.to_username }}
</a>
{% elif row.activity_type == 'mini_clr_payout' %}
{% trans "got a distribution of" %} of <strong>${{row.metadata.amount|floatformat:2}}<strong>
{% elif row.activity_type == 'new_kudos' %}
{% trans "sent a" %}
Kudos
Expand Down Expand Up @@ -185,7 +192,7 @@
{% endif %}

{% if not hide_likes %}
{% if is_alpha_tester or row.metadata.tip_able %}
{% if is_alpha_tester %}
<a data-pk={{row.pk}} data-username={{row.profile.handle}} class="tip_activity" href="#"
data-toggle="tooltip" title="This activity feed has generated {{ row.tip_count_eth|floatformat:2 }} ETH (${{row.tip_count_usd|floatformat:2}}) in Tips."
>
Expand Down
Loading